Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not validate tracestate #790

Open
dyladan opened this issue Feb 18, 2020 · 3 comments · May be fixed by #5499
Open

Do not validate tracestate #790

dyladan opened this issue Feb 18, 2020 · 3 comments · May be fixed by #5499
Assignees
Labels

Comments

@dyladan
Copy link
Member

dyladan commented Feb 18, 2020

Right now we are parsing and validating tracestate on every span regardless of if it is used or not (we currently do not use it for anything except exporting to the collector). This is an unnecessary cost and complexity (parse does a split, reverse, and reduce). Further, we allow arbitrary keys to be overwritten by calling traceState.set despite the fact that we should not be modifying other vendor keys.

Propose that we remove all parsing and validation of tracestate until it is actually modified, and change our default behavior to simply propagate unchanged. Further, set should be changed such that it doesn't parse all values into a map, but simply searches the list for our key/value and splices it out, then sets a new value at the front.

There is currently an open issue on trace context to change the language from MAY to SHOULD NOT validate tracestate w3c/trace-context#384

pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this issue Dec 15, 2023
@pichlermarc
Copy link
Member

@dyladan do you think this may be relevant for SDK 2.0? Looks like it would signficantly change behavior.

I think the relevant code is still there:

if (rawTraceState.length > MAX_TRACE_STATE_LEN) return;
this._internalState = rawTraceState
.split(LIST_MEMBERS_SEPARATOR)
.reverse() // Store in reverse so new keys (.set(...)) will be placed at the beginning
.reduce((agg: Map<string, string>, part: string) => {
const listMember = part.trim(); // Optional Whitespace (OWS) handling
const i = listMember.indexOf(LIST_MEMBER_KEY_VALUE_SPLITTER);
if (i !== -1) {
const key = listMember.slice(0, i);
const value = listMember.slice(i + 1, part.length);
if (validateKey(key) && validateValue(value)) {
agg.set(key, value);
} else {
// TODO: Consider to add warning log
}
}
return agg;
}, new Map());

@dyladan dyladan added this to the OpenTelemetry SDK 2.0 milestone Mar 8, 2024
@dyladan dyladan added the triage label Mar 8, 2024
@david-luna
Copy link
Contributor

@dyladan @pichlermarc I'll have a look into this

@trentm
Copy link
Contributor

trentm commented Feb 26, 2025

Maintainers were discussing this earlier today.

For now we decided to punt on this issue being in "SDK 2.0". The changes proposed here are not breaking, so can be done anytime after 2.0.

@trentm trentm removed this from the OpenTelemetry SDK 2.0 milestone Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants