Skip to main content
Glama
ryu1maniwa

OpenTelemetry Documentation MCP Server

by ryu1maniwa
opentelemetry_instrumentation_raw.html3.5 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Instrumentation | OpenTelemetry</title> </head> <body> <div class="td-content"> <h1>Instrumentation</h1> <p><em>Instrumentation</em> is the act of adding observability code to an app yourself.</p> <p>When you develop an app, you might instrument it by adding OpenTelemetry API calls to send telemetry from your app to OpenTelemetry. Then, you can use the OpenTelemetry SDK to export that telemetry to an observability backend.</p> <h2>Automatic Instrumentation</h2> <p>Automatic instrumentation with OpenTelemetry allows you to collect telemetry data from your application without having to manually instrument every part of your code. This is achieved through the use of instrumentation libraries that automatically detect and instrument popular frameworks and libraries.</p> <div class="note"> <p><strong>Note:</strong> The availability of automatic instrumentation varies by language. Some languages have more comprehensive automatic instrumentation than others.</p> </div> <h2>Manual Instrumentation</h2> <p>Manual instrumentation involves explicitly adding OpenTelemetry API calls to your application code. This gives you fine-grained control over what telemetry data is collected and how it's structured.</p> <h3>Creating Spans</h3> <p>Here's an example of creating a span manually in JavaScript:</p> <pre><code class="language-javascript"> const { trace } = require('@opentelemetry/api'); function doWork() { const tracer = trace.getTracer('my-service-tracer'); const span = tracer.startSpan('doWork'); try { // Do some work span.setAttributes({ 'work.type': 'important', 'work.id': '12345' }); // Simulate some work for (let i = 0; i < 1000000; i++) { // busy work } span.setStatus({ code: trace.SpanStatusCode.OK }); } catch (error) { span.recordException(error); span.setStatus({ code: trace.SpanStatusCode.ERROR, message: error.message }); } finally { span.end(); } } </code></pre> <h3>Adding Metrics</h3> <p>You can also manually create metrics:</p> <pre><code class="language-javascript"> const { metrics } = require('@opentelemetry/api'); const meter = metrics.getMeter('my-service-meter'); const requestCounter = meter.createCounter('requests_total', { description: 'Total number of requests' }); function handleRequest() { requestCounter.add(1, { method: 'GET', route: '/api/users' }); } </code></pre> <h2>Best Practices</h2> <ul> <li>Start with automatic instrumentation when available</li> <li>Add manual instrumentation for business-specific logic</li> <li>Use semantic conventions for consistent attribute naming</li> <li>Don't over-instrument - focus on meaningful telemetry</li> <li>Consider the performance impact of instrumentation</li> </ul> <p>For more detailed information about instrumentation in your specific language, check the language-specific documentation in the OpenTelemetry docs.</p> </div> </body> </html>

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ryu1maniwa/opentelemetry-documentation-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server