ref(opentelemetry): Vendor minimal `TraceState` implementation (#21192)
## Summary
- Adds a small in-tree `TraceState` class under
`packages/opentelemetry/src/utils/TraceState.ts` implementing
`api.TraceState` from `@opentelemetry/api`.
- Swaps the four `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 (raw `tracestate` header 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/core` from a heavily-imported file without behavior
change.
## Deliberately dropped from upstream
- Raw-string parsing in the constructor — the W3C `tracestate` header is
parsed by OTel's own `W3CTraceContextPropagator`, which uses its own
`TraceState`. Our class is never constructed from a raw header.
- Key/value validation — we only `set` known `SENTRY_TRACE_STATE_*`
constants.
- `MAX_TRACE_STATE_ITEMS` / `MAX_TRACE_STATE_LEN` truncation — only
relevant when parsing input.
`@opentelemetry/core` remains a dependency because `propagator.ts`,
`resource.ts`, `trace.ts`, and `utils/suppressTracing.ts` still use
`isTracingSuppressed`, `W3CBaggagePropagator`, `SDK_INFO`, and
`suppressTracing`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> F
Francesco Gringl-Novy committed
7e2443ecc3c4ac980f3d011b7187c8845ba6fab8
Parent: 5df0161
Committed by GitHub <noreply@github.com>
on 5/29/2026, 6:58:48 AM