Skip to content

Add setup-span helpers for product setup - #246

Draft
jat255 wants to merge 1 commit into
mainfrom
jat255/wbx8-span-helpers
Draft

Add setup-span helpers for product setup#246
jat255 wants to merge 1 commit into
mainfrom
jat255/wbx8-span-helpers

Conversation

@jat255

@jat255 jat255 commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

First piece of M7 tracing (kata bvcv), and the one everything else in the milestone builds on. Nothing calls it yet: the span names commons actually records arrive with the modules that record them, and the exporter that turns spans into files is the next task.

commons_span() opens a span that stays current for a with block, so spans opened inside it become its children. Attributes known up front go in at creation, because samplers see only those and Connect snapshots a span's attributes when it opens. Values the covered work produces, a row count for instance, go on the yielded span. pkg-r/R/tracing.R has the counterparts, local_commons_span() and commons_span_set_attribute(); Python folds the second into the span object because a context manager already gives it back.

These spans cover product setup rather than conversation content, so they are not gated behind an agent's log argument and open on every agent. That is affordable because the OpenTelemetry API is inert until an SDK provider is configured. A test pins it by running a fresh interpreter and asserting the span does not record.

The API import is unguarded, so opentelemetry-api becomes a plain dependency. It arrived through chatlas before, which is not something to rest on: the version floor permits a chatlas release that drops it. Only the SDK and the exporters stay in the tracing extra, and a packaging test pins both halves.

The tracing tests skip when the SDK is absent. CI installs every extra, so they run there.

@jat255
jat255 marked this pull request as draft September 2, 2026 00:18
@jat255 jat255 added the py Affects the Python implementation label Sep 2, 2026
`commons_span()` opens a span that is current for the duration of a `with`
block, so spans opened inside it become its children. Attributes known up
front are passed at creation, because samplers see only those and Connect
snapshots a span's attributes when it opens; the yielded span takes values the
covered work produces.

Setup spans cover building a data source or constructing an agent rather than
conversation content, so they are not gated behind an agent's `log` argument
and open on every agent. That is affordable because the OpenTelemetry API is
inert until an SDK provider is configured, which a test pins by running a
fresh interpreter and asserting the span does not record.

The API is imported unguarded, so commons now requires `opentelemetry-api`
outright rather than receiving it through chatlas, which is free to drop it in
any release the version floor allows. Only the SDK and the exporters stay
optional in the `tracing` extra. A packaging test pins both halves of that.

The tracer is resolved once at import. With no provider configured that is a
proxy which re-checks the global provider each time a span opens, so a
provider installed later still takes effect.

Part of kata bvcv (M7). Closes kata wbx8.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

py Affects the Python implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant