get_instrumentation_help
Get guidance for instrumenting code with OpenTelemetry traces and logs. Provides advice on improving existing instrumentation or creating new telemetry.
Instructions
Provides important guidance for how to instrument code with OpenTelemetry traces and logs. It is intended to be used when someone wants to instrument their code, or improve instrumentation (such as getting advice on improving their logs or tracing, or creating new instrumentation). It is BEST used after inspecting existing code and telemetry data to understand some operational characteristics. However, if there is no telemetry data to read from Honeycomb, it can still provide guidance on how to instrument code.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| language | No | Programming language of the code to instrument | |
| filepath | No | Path to the file being instrumented |
Implementation Reference
- The main execution logic for the 'get_instrumentation_help' tool. It retrieves a predefined instrumentation guidance template, customizes it with the provided language and filepath parameters, and returns it formatted as tool content. Errors are handled via handleToolError.handler: async (params: z.infer<typeof InstrumentationGuidanceSchema>) => { try { // Get the instrumentation guidance template const guidance = getInstrumentationGuidance(); const language = params?.language || "your code"; const filepath = params?.filepath ? ` for ${params.filepath}` : ""; return { content: [ { type: "text", text: `# Instrumentation Guidance for ${language}${filepath}\n\n${guidance}`, }, ], }; } catch (error) { return handleToolError(error, "get_instrumentation_help"); } }
- Zod schema defining the optional input parameters 'language' and 'filepath' for the tool.export const InstrumentationGuidanceSchema = z.object({ language: z.string().optional().describe("Programming language of the code to instrument"), filepath: z.string().optional().describe("Path to the file being instrumented") });
- src/tools/index.ts:57-57 (registration)The tool is instantiated via createInstrumentationGuidanceTool and added to the array of tools registered with the MCP server in the registerTools function.createInstrumentationGuidanceTool(api)
- src/prompts/guidance.ts:130-132 (helper)Helper function that returns the static string template containing OpenTelemetry instrumentation guidance, which is used by the tool handler.export function getInstrumentationGuidance(): string { return INSTRUMENTATION_GUIDANCE; }
- src/tools/instrumentation-guidance.ts:22-22 (registration)The tool name is defined here in the returned tool object.name: "get_instrumentation_help",