ref(opentelemetry): Vendor minimal TraceState implementation#21192
Open
mydea wants to merge 2 commits into
Open
ref(opentelemetry): Vendor minimal TraceState implementation#21192mydea wants to merge 2 commits into
TraceState implementation#21192mydea wants to merge 2 commits into
Conversation
Getting rid of this usage from `@opentelemetry/core`.
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>
Contributor
size-limit report 📦
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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