Skip to content

fix(otel): relax semantic-conventions upper bound - #605

Merged
verdie-g merged 1 commit into
mainfrom
relax-otel-semconv-upper-bound
Aug 10, 2026
Merged

fix(otel): relax semantic-conventions upper bound#605
verdie-g merged 1 commit into
mainfrom
relax-otel-semconv-upper-bound

Conversation

@verdie-g

@verdie-g verdie-g commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Why

opentelemetry-semantic-conventions (>=0.60b1,<0.61) capped the whole OpenTelemetry stack for downstream consumers, not just semconv.

OTel ships semconv and the instrumentation-* packages as a lockstep set pinned with ==, and semconv itself requires an exact api version:

opentelemetry-semantic-conventions 0.65b0 -> ['opentelemetry-api==1.44.0', ...]
opentelemetry-sdk 1.44.0                  -> ['opentelemetry-semantic-conventions==0.65b0', ...]

So <0.61 held consumers' opentelemetry-api and -sdk at the 1.39.x generation. A floor keeps the caution without letting a library dictate the application's whole observability stack.

Changes

File Change
pyproject.toml ceiling → floor on semantic-conventions and instrumentation-httpx
_hooks/traceparent.py sampled-flag check is now a bitmask test
tests/test_traceparent_hook.py assertion follows suit

The bug the cap was hiding

W3C trace-context level 2 adds RANDOM_TRACE_ID = 0x02, so from opentelemetry-api 1.44.0 a sampled span serializes as -03, not -01:

if not traceparent.endswith("-01"):     # reads "-03" as unsampled
    trace_id = random.getrandbits(128)  # discards the real context

Every workflow /execute call would silently start a new trace, orphaning worker traces from their caller. Latent today only because the cap kept api at 1.39.1, so relaxing the cap without this fix would ship the regression.

Verification

  • All 39 semconv symbols the SDK references resolve in both 0.60b1 and 0.65b0, and every resolved value is byte-identical — no attribute names shift.
  • Full extra suite: 260 passed on semconv 0.60b1 / api 1.39.1 and on 0.65b0 / api 1.44.0, so the floor stays genuinely supported rather than just the ceiling raised.
  • ruff and mypy clean.

Note on generated code

pyproject.toml is listed in .genignore, and none of the three files appear in gen.lock's tracked manifest, so no gen.yaml change is needed. I could not complete speakeasy run locally — it aborts during source validation, identically on a pristine tree — so that is worth confirming on a CI generation run.

The `<0.61` cap pinned the whole OpenTelemetry stack for downstream
consumers, not just semconv. OTel ships semconv and the instrumentation
packages as a lockstep set pinned with `==`, and semconv itself requires
an exact opentelemetry-api version, so the ceiling held consumers' api
and sdk at the 1.39.x generation.

Replace the ceiling with a floor on semantic-conventions and
instrumentation-httpx. All 39 semconv symbols the SDK references resolve
to identical values in 0.60b1 and 0.65b0, so no span attribute names
change.

Lifting the cap surfaced a latent bug. W3C trace-context level 2 adds the
random-trace-id flag (0x02), so a sampled span serializes as "-03" from
opentelemetry-api 1.44.0. TraceparentInjectionHook compared the flags byte
with `endswith("-01")`, read that as unsampled, and discarded the
propagated context, starting a new trace on every workflow /execute call.
Test the sampled bit as a bitmask instead.

Verified on semconv 0.60b1 / api 1.39.1 and semconv 0.65b0 / api 1.44.0.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
@verdie-g
verdie-g force-pushed the relax-otel-semconv-upper-bound branch from 821b686 to 70f3677 Compare August 10, 2026 14:06
@verdie-g verdie-g changed the title fix(otel): relax semantic-conventions upper bound, fix traceparent sampling check fix(otel): relax semantic-conventions upper bound Aug 10, 2026

@andreaonofrei01 andreaonofrei01 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@verdie-g
verdie-g merged commit 504bcfc into main Aug 10, 2026
11 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.

2 participants