googleapis/mcp-toolbox · error
unable to create telemetry instrumentation: %w
Error message
unable to create telemetry instrumentation: %w
What it means
After OTel is set up, Setup calls telemetry.CreateTelemetryInstrumentation(opts.Cfg.Version) to build the instrumentation used to annotate the context. If that construction fails, the error is wrapped with this message and startup aborts, returning the shutdownFunc so callers can still clean up OTel.
Source
Thrown at cmd/internal/options.go:128
if err != nil {
errMsg := fmt.Errorf("error setting up OpenTelemetry: %w", err)
logger.ErrorContext(ctx, errMsg.Error())
return ctx, nil, errMsg
}
shutdownFunc := func(ctx context.Context) error {
err := otelShutdown(ctx)
if err != nil {
errMsg := fmt.Errorf("error shutting down OpenTelemetry: %w", err)
logger.ErrorContext(ctx, errMsg.Error())
return err
}
return nil
}
instrumentation, err := telemetry.CreateTelemetryInstrumentation(opts.Cfg.Version)
if err != nil {
errMsg := fmt.Errorf("unable to create telemetry instrumentation: %w", err)
logger.ErrorContext(ctx, errMsg.Error())
return ctx, shutdownFunc, errMsg
}
ctx = util.WithInstrumentation(ctx, instrumentation)
return ctx, shutdownFunc, nil
}
// GetCustomConfigFiles retrieves the list of custom config file paths
func (opts *ToolboxOptions) GetCustomConfigFiles(ctx context.Context) ([]string, bool, error) {
// Determine if Custom Files should be loaded
// Check for explicit custom flags
isCustomConfigured := opts.Config != "" || len(opts.Configs) > 0 || opts.ConfigFolder != ""
logger, err := util.LoggerFromContext(ctx)
if err != nil {
return nil, isCustomConfigured, errView on GitHub (pinned to 8cc6e09de2)
Solutions
- Check the wrapped root cause from CreateTelemetryInstrumentation
- Run go mod tidy / update the OpenTelemetry SDK to a compatible version
- Verify no custom resource/instrument registration conflicts in telemetry config
- Rebuild with the project's supported Go version (1.23+)
Example fix
// before go get go.opentelemetry.io/otel@v1.0.0 // old incompatible SDK // after go get go.opentelemetry.io/otel@latest && go mod tidy
Defensive patterns
Strategy: validation
Validate before calling
// pin a compatible OTel SDK and verify build go mod tidy && go build ./... go list -m go.opentelemetry.io/otel
Try / catch
instrumentation, err := telemetry.CreateTelemetryInstrumentation(version)
if err != nil {
return fmt.Errorf("unable to create telemetry instrumentation: %w", err)
} Prevention
- Keep the OpenTelemetry SDK at a version compatible with the toolbox go.mod
- Run go mod tidy after dependency upgrades
- Test startup with telemetry enabled in CI
When it happens
Trigger: telemetry.CreateTelemetryInstrumentation returns an error — internal tracer/meter instrumentation construction fails (e.g., instrument naming or registration problem with the OTel SDK).
Common situations: A corrupted or incompatible OpenTelemetry SDK version in the dependency graph, or an OTel instrument registration failure after a library upgrade.
Related errors
- error setting up OpenTelemetry: %w
- unable to initialize logger: %w
- error shutting down OpenTelemetry: %w
- failed to discover OIDC config: %w
- unable to initialize tool %q: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/9dce6d3c44d4b2e8.
Report an issue: GitHub.