Repository navigation
Initialize OTEL tracing at app startup for /v1/agents/run - #50
Merged
Merged
Conversation
cloud-agents' step/workflow executors only emit spans once a global TracerProvider is set. workflow.executor_factory already calls init_tracing() for /v1/workflows/run, but /v1/agents/run (agents.py) uses the step executors directly and never triggered it, so agent-ephemeral (and agent-none/agent-local) never exported traces even with OTEL_EXPORTER_OTLP_ENDPOINT set. init_tracing is idempotent and a no-op when that env var is unset, so calling it once at startup covers every code path with no behavior change when tracing isn't configured. Verified against a local Jaeger instance: agent-none/agent-local now show full nested spans (tools/list, chat, execute_tool, invoke_agent), and agent-ephemeral now creates its sandbox.step root span, which it previously created none of at all. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No JIRA ticket yet — pr-title-checker will fail until one is added; rename the title once available.
Summary
cloud-agents' step/workflow executors only emit OTEL spans once a globalTracerProvideris set — otherwise every span is silently dropped through a NoOp tracer, even whenOTEL_EXPORTER_OTLP_ENDPOINTis configured.workflow.executor_factory.create_workflow_runner()already callsinit_tracing("workflow-runner")for/v1/workflows/run, but/v1/agents/run(app/endpoints/agents.py) uses the step executors directly and never triggers it — soagent-ephemeral/agent-none/agent-localnever exported any traces at all.init_tracing("workflow-runner")once inapp.main's lifespan at startup.init_tracingis idempotent (module-level guard) and a no-op whenOTEL_EXPORTER_OTLP_ENDPOINTis unset, so this covers every code path with zero behavior change when tracing isn't configured.Test plan
uv run make format; targetedpylint/pyright/ruff/pydocstyleonmain.pyclean (the remaining pylintE1101findings on unrelated pre-existing lines are confirmed identical on unmodifiedharnessHEAD)uv run make test-unit— 3391 passed, 1 skipped, 90.22% coverageagent-ephemeralcreated zero traces.agent-ephemeralcreates asandbox.steproot span;agent-none/agent-localshow full nested spans (tools/list,chat gpt-5-mini,execute_tool,invoke_agent).