ref(opentelemetry): Vendor minimal TraceState implementation#21192
Conversation
size-limit report 📦
|
There was a problem hiding this comment.
LGTM.
Just on a note, this PR contains more than just TraceState changes, they also include time changes to our @sentry/core helpers (they have a different type signature, but should be alright as these functions are only internal
Edit: I just saw that these are anyways 2 separate commits, maybe they went in by accident
oops, yeah that was on accident, will rebase/remote the other stuff! |
Replaces the `TraceState` import from `@opentelemetry/core` with a small in-tree implementation under `packages/opentelemetry/src/utils/`. The SDK only ever calls `new TraceState()` and chains `.set()`/`.get()`/ `.serialize()` on it, so the vendored version drops raw-string parsing, key/value validation, and the W3C length/item caps — none of which apply to keys we control. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
c15ac25 to
6c4a3e5
Compare
Summary
TraceStateclass underpackages/opentelemetry/src/utils/TraceState.tsimplementingapi.TraceStatefrom@opentelemetry/api.import { TraceState } from '@opentelemetry/core'sites (sampler.ts,makeTraceState.ts, and three test files) to use the vendored version.Why
The SDK only ever calls
new TraceState()and chains.set(),.get(),.unset(), and.serialize()on the result — none of the upstream class's heavier behavior (rawtracestateheader parsing, key/value validation, W3C length/item caps) ever runs against our inputs. Inlining the ~40 lines we actually use lets us drop one consumer of@opentelemetry/corefrom a heavily-imported file without behavior change.Deliberately dropped from upstream
tracestateheader is parsed by OTel's ownW3CTraceContextPropagator, which uses its ownTraceState. Our class is never constructed from a raw header.setknownSENTRY_TRACE_STATE_*constants.MAX_TRACE_STATE_ITEMS/MAX_TRACE_STATE_LENtruncation — only relevant when parsing input.@opentelemetry/coreremains a dependency becausepropagator.ts,resource.ts,trace.ts, andutils/suppressTracing.tsstill useisTracingSuppressed,W3CBaggagePropagator,SDK_INFO, andsuppressTracing.🤖 Generated with Claude Code