MCP Server Framework - v1.0.0
    Preparing search index...

    Module server/telemetry

    Telemetry Module

    OpenTelemetry integration for distributed tracing and metrics.

    Enable telemetry with environment variables:

    OTEL_ENABLED=true
    OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318

    All OTEL settings are routed through the config system (env vars + config file):

    • OTEL_EXPORTER_OTLP_ENDPOINT — OTLP endpoint URL
    • OTEL_TRACES_EXPORTER — Trace exporter: otlp (default), console, none
    • OTEL_LOG_LEVEL — SDK diagnostic log level
    • OTEL_METRIC_EXPORT_INTERVAL — Metric export interval (ms)

    Framework-managed env vars:

    • OTEL_METRICS_EXPORTER — otlp, prometheus, console, none (default: otlp,prometheus)
    import { initializeTelemetry, withSpan, getTraceContext, serverMetrics } from './telemetry/index.js';

    // Initialize at startup
    initializeTelemetry();

    // Create spans
    await withSpan('myOperation', async (span) => {
    span.setAttribute('key', 'value');
    return await doSomething();
    });

    // Get trace context for propagation
    const ctx = getTraceContext();

    // Record metrics
    serverMetrics.recordRequest('tool_name', 150, true);

    Classes

    ServerMetricsManager

    Interfaces

    Attributes
    Context
    Span
    TraceContext
    Tracer

    Type Aliases

    AsyncSpanCallback
    SpanCallback

    Variables

    FrameworkSpanKind
    FrameworkSpanStatusCode
    METRIC_ATTRIBUTES
    METRIC_DESCRIPTIONS
    METRIC_NAMES
    METRIC_UNITS
    SdkLogMessages
    TELEMETRY_DEFAULTS
    TELEMETRY_ENV_VARS
    TELEMETRY_LOG_COMPONENTS
    TRANSPORT_TYPES

    Functions

    addSpanAttributes
    addSpanEvent
    createConnectionTelemetry
    createServerMetrics
    getActiveSpan
    getPrometheusExporter
    getServerMetrics
    getTelemetryConfig
    getTraceContext
    isSdkInitialized

    References

    getTracer → getTracer
    initializeTelemetry → initializeTelemetry
    isTelemetryEnabled → isTelemetryEnabled
    MCP_ATTRIBUTES → MCP_ATTRIBUTES
    ServerMetrics → ServerMetrics
    ServerStats → ServerStats
    shutdownTelemetry → shutdownTelemetry
    SpanKind → FrameworkSpanKind
    SpanOptions → SpanOptions
    SpanStatusCode → FrameworkSpanStatusCode
    TelemetryConfig → TelemetryConfig
    withSpan → withSpan
    withSpanSync → withSpanSync