Documentation Index
Fetch the complete documentation index at: https://sedataai.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
TelemetryManager, wires up the OpenTelemetry Node SDK, then
calls McpServerInstrumentation.instrument() to patch
server.registerTool so every subsequent tool registration produces spans
and metrics automatically.
Parameters
An instance of
McpServer from @modelcontextprotocol/sdk/server/mcp.
Must be passed before any tools are registered (instrumentation only
applies to tools registered after this call).Configuration for the telemetry pipeline. See the
TelemetryConfig reference for
every field.Returns
An object with helpers for custom instrumentation and shutdown:
startActiveSpan(name, attributes, fn)getHistogram(name, options)getIncrementCounter(name, options)processTelemetryAttributes(data)shutdown(): Promise<void>
ObservabilityInstance.Example
Side effects
CallinginstrumentServer does several things at once:
- Validates the config via
ConfigValidator.validate(config). Throws on invalid input (missing endpoint, bad sampling rate, malformed auth). - Stores the API key for the safety-check API. The token from
exporterAuth.apiKeyorexporterAuth.tokenis forwarded. - Starts the OpenTelemetry Node SDK with trace + metric exporters, sampler, and resource detectors.
- Patches
server.registerToolto wrap every handler in an instrumented function.
When to call it
Always immediately after constructing theMcpServer, before any
registerTool:
instrumentServer are not instrumented.
Errors
| Error | Cause |
|---|---|
exporterEndpoint is required | exporterEndpoint missing and exporterType is not 'console'. |
samplingRate must be between 0 and 1 | Out-of-range samplingRate. |
metricExportIntervalMs must be >0 | Non-positive interval. |
batchTimeout must be >=0 | Non-positive timeout. |
Bearer token is required when using bearer auth | exporterAuth.type === 'bearer' with no token. |
API key is required when using apiKey auth | exporterAuth.type === 'apiKey' with no apiKey. |
Username and password are required when using basic auth | basic auth with missing fields. |
See also
TelemetryConfig
Every config field with defaults.
ObservabilityInstance
The object returned by this function.