Repository navigation
feat(telemetry): send pydantic-ai spans through the exporter seam - #4538
Conversation
Checks and the live checkLocal runs
Live check after release (a person, after the new image runs in In Grafana Explore, Tempo data source, run: Expected: at least one trace. Open it: To check the nesting and the cache tokens in one query: For the runner Job, use Also watch No ConfigMap, Secret or manifest change is necessary: the spans use Notes
|
pydantic-ai, the MCP client and the gateway client make their spans through the OpenTelemetry API, and no process set an SDK tracer provider, so Tempo held no agent, model, tool or MCP span. library_spans sets one SDK provider for each process when the process builds its first pydantic-ai model. Its exporter encodes each batch with the official OTLP encoder and gives the protobuf body to the exporter of the process's tracer, so the spans take the egress-checked client and are not sent in a dry run. The own spans keep their ids in the OpenTelemetry API context, so library spans nest under them. Only the gateway client gets the httpx instrumentor. logfire_agent_turn, AgentTurnHandle and `devops telemetry test --logfire` are deleted: the agent spans replace them. Refs #4515
The bridge test ran the real logfire.configure, which patches the executors of the process, so a later context test saw a span. The test now puts the processors of the bridge on its own provider. The reset shuts the library provider down, the telemetry document names the option of the review commands, and the swallowed-failures ceilings of tracer.py and logfire.py go down. Refs #4515
logfire.configure patches submit of ThreadPoolExecutor and ProcessPoolExecutor for the whole process. Now that the own spans live in the OpenTelemetry context, the patch carried a span into the worker of a later test in the same process. The test puts the originals back at teardown. Refs #4515
fb5275a to
64540f6
Compare
The review of #4538 found two channels that the owner decision of 2026-11-11 does not allow. The Logfire bridge set send_to_logfire=True when a token was set, and Logfire adds its stock OTLP exporter when an OTEL_EXPORTER_OTLP_*ENDPOINT variable is set. The bridge now runs Logfire as a local SDK: it sets send_to_logfire=False, passes no token and does not start while such a variable is set. telemetry.logfire_token, telemetry.logfire_send_to_logfire, get_logfire_token and the logfire_token keyring entry are deleted. An own span is now in the OpenTelemetry API context, so the MCP SDK and fastmcp put traceparent and baggage in the _meta of each MCP request. The global propagator now injects nothing and still extracts, and the gateway client injects with its own propagator in the request hook of the httpx instrumentor. Refs #4515
64540f6 to
7b64c6d
Compare
Review findings: what I didCommit 1. major: the
|
The review of #4538 found two channels that the owner decision of 2026-11-11 does not allow. The Logfire bridge set send_to_logfire=True when a token was set, and Logfire adds its stock OTLP exporter when an OTEL_EXPORTER_OTLP_*ENDPOINT variable is set. The bridge now runs Logfire as a local SDK: it sets send_to_logfire=False, passes no token and does not start while such a variable is set. telemetry.logfire_token, telemetry.logfire_send_to_logfire, get_logfire_token and the logfire_token keyring entry are deleted. An own span is now in the OpenTelemetry API context, so the MCP SDK and fastmcp put traceparent and baggage in the _meta of each MCP request. The global propagator now injects nothing and still extracts, and the gateway client injects with its own propagator in the request hook of the httpx instrumentor. Refs #4515
7b64c6d to
64abfd2
Compare
Update after the first check run
|
🤖 I have created a release *beep* *boop* --- ## [0.112.0](v0.111.0...v0.112.0) (2026-11-11) ### Features * **k8s:** export gateway spans without key metadata ([#4520](#4520)) ([7234d71](7234d71)) * **k8s:** set the homelab domain in container env values ([#4608](#4608)) ([a3bcf7c](a3bcf7c)) * **telemetry:** send pydantic-ai spans through the exporter seam ([#4538](#4538)) ([fcf2a7a](fcf2a7a)) ### Bug Fixes * **ai:** price cached prompt tokens of chat calls ([#4584](#4584)) ([f84bbe6](f84bbe6)) * **devcontainer:** stop uv noise lines in agent shells ([#4592](#4592)) ([9ba375c](9ba375c)) * **k8s:** delete gateway management bodies from spans ([#4551](#4551)) ([b835d3c](b835d3c)) * **k8s:** set the kube context and namespace on devops pods ([#4514](#4514)) ([9087b39](9087b39)) * **roadmap:** a refused spec after the archive is a plan defect ([#4549](#4549)) ([1db29f7](1db29f7)) * **roadmap:** count and log the reason of a left-out stage item ([#4541](#4541)) ([5600179](5600179)) * **roadmap:** default the step ceiling to twice the budget ([#4556](#4556)) ([1dfb6c8](1dfb6c8)) * **roadmap:** explain --trace shows the argument digest ([#4526](#4526)) ([c92195f](c92195f)) * **roadmap:** explain totals count dropped model events ([#4543](#4543)) ([fe0e979](fe0e979)) * **roadmap:** give each eval verify run its own report file ([#4534](#4534)) ([ad27f2d](ad27f2d)) * **roadmap:** one event loop and a time limit for decide_all ([#4585](#4585)) ([ec51e01](ec51e01)) * **roadmap:** scoped updates send requests with no row scope ([#4531](#4531)) ([5f75d25](5f75d25)) * **roadmap:** the caller gate reads an added parameter span ([#4548](#4548)) ([1ba07c1](1ba07c1)) * **roadmap:** the implement shell waits for its command ([#4536](#4536)) ([571e044](571e044)) * **roadmap:** the module-test and caller gates read imports and calls ([#4490](#4490)) ([8a22e82](8a22e82)) * **service:** put trace ids on Service JSON log lines ([#4511](#4511)) ([0d7a0d2](0d7a0d2)) ### Performance Improvements * **ai:** keep intake embeddings between CLI runs ([#4546](#4546)) ([812871e](812871e)) * **roadmap:** intake reads only the issues that changed ([#4552](#4552)) ([7dfd155](7dfd155)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
pydantic-ai, the MCP client and the LLM gateway client make their spans through the OpenTelemetry API, and no process set an SDK tracer provider, so Tempo held no agent, model, tool or MCP span.
A process that builds a pydantic-ai model with telemetry export on now sets one SDK provider. It sends each batch as OTLP protobuf through the exporter seam of #1319, so the egress check and the dry-run rule apply. Prompt and tool text follow
telemetry.capture_llm_content. Agent spans nest under the row span.Trace context goes to the LLM gateway only; MCP requests carry none. The
--logfirebridge sends nothing to Logfire's cloud and does not start while anOTEL_EXPORTER_OTLP_*ENDPOINTvariable is set. Its token setting is deleted.logfire_agent_turn,AgentTurnHandleanddevops telemetry test --logfireare deleted: they wrote ungated prompt text.Closes #4515
Change:
openspec/changes/archive/2026-11-11-4515-send-pydantic-ai-spans-through-the/