instrumentServer.
Implemented by TelemetryManager.
Methods
startActiveSpan(name, attributes, fn)
Open an active span and execute fn inside it. The session id is added
automatically.
fn receives an OpenTelemetry Span — call span.end() when done.
getHistogram(name, options)
Create or reuse a histogram instrument. Returns a recorder function. Reuse the
recorder across calls — don’t recreate per call.
getIncrementCounter(name, options)
Create or reuse a counter. Returns an increment function.
processTelemetryAttributes(data)
Run a value through every configured dataProcessor in order. Useful if
you’re building log lines that should share the same redaction logic as your
spans.
shutdown(): Promise<void>
Records mcp.server.session.duration and shuts down the OpenTelemetry SDK.
Always call on graceful exit.
See also
instrumentServer
Returns this object.
Custom instrumentation
Patterns for using these methods.