Skip to content

fix(runtime): add OpenTelemetry tracer to runtime initialization#2505

Open
tdabasinskas wants to merge 1 commit intodocker:mainfrom
cogvel:fix/otel-tracer-mcp-server
Open

fix(runtime): add OpenTelemetry tracer to runtime initialization#2505
tdabasinskas wants to merge 1 commit intodocker:mainfrom
cogvel:fix/otel-tracer-mcp-server

Conversation

@tdabasinskas
Copy link
Copy Markdown
Contributor

Wire an OpenTelemetry tracer into the runtime instances created by the non-interactive entry points so they emit spans like the CLI already does:

  • Agent-to-agent adapter runtime
  • MCP server tool handler runtime
  • Session manager runtime

Without this, LocalRuntime.startSpan sees r.tracer == nil and silently returns a noop, so users running in MCP, API or A2A mode with OTEL_EXPORTER_OTLP_ENDPOINT set get an initialized SDK that never emits anything.

It uses the same "cagent" scope as cmd/root/run.go for consistency. No behavior change when OTel is disabled — the global tracer provider is a noop until initOTelSDK runs.

Initialize runtime instances with an OpenTelemetry tracer named "cagent" to enable distributed tracing across agent invocations.

This ensures consistent tracing instrumentation in:
- Agent-to-agent adapter runtime
- MCP server tool handler runtime
- Session manager runtime
@tdabasinskas tdabasinskas requested a review from a team as a code owner April 24, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant