Skip to content

Initialize OTEL tracing at app startup for /v1/agents/run - #50

Merged
jameswnl merged 1 commit into
harnessfrom
rspeed-agent-run-otel-tracing
Sep 9, 2026
Merged

jameswnl merged 1 commit into
harnessfrom
rspeed-agent-run-otel-tracing

Conversation

@jameswnl

@jameswnl jameswnl commented Sep 9, 2026

Copy link
Copy Markdown
Owner

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 global TracerProvider is set — otherwise every span is silently dropped through a NoOp tracer, even when OTEL_EXPORTER_OTLP_ENDPOINT is configured.
  • workflow.executor_factory.create_workflow_runner() already calls init_tracing("workflow-runner") for /v1/workflows/run, but /v1/agents/run (app/endpoints/agents.py) uses the step executors directly and never triggers it — so agent-ephemeral/agent-none/agent-local never exported any traces at all.
  • Fix: call init_tracing("workflow-runner") once in app.main's lifespan at startup. init_tracing is idempotent (module-level guard) and a no-op when OTEL_EXPORTER_OTLP_ENDPOINT is unset, so this covers every code path with zero behavior change when tracing isn't configured.

Test plan

  • uv run make format; targeted pylint/pyright/ruff/pydocstyle on main.py clean (the remaining pylint E1101 findings on unrelated pre-existing lines are confirmed identical on unmodified harness HEAD)
  • uv run make test-unit — 3391 passed, 1 skipped, 90.22% coverage
  • Live verification against a local Jaeger instance:
    • Before: agent-ephemeral created zero traces.
    • After: agent-ephemeral creates a sandbox.step root span; agent-none/agent-local show full nested spans (tools/list, chat gpt-5-mini, execute_tool, invoke_agent).

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>
@jameswnl
jameswnl merged commit f4f5f6e into harness Sep 9, 2026
3 checks passed
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