open-telemetry / open-telemetry/opentelemetry-cpp

[API] TraceState::Set does not overwrite existing entries

Open Beginner friendly
#4,583 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug spec-compliance triage/accepted
Dominant language
C++
Stars
1.4k
Forks
632
Avg merge
1d 13h
Merged PRs (30d)
75

Description

The TraceState::Set method does not overwrite values of existing entries when the key matches. This is required by the W3C trace-context standard and OTel spec.

Only one entry per key is allowed because the entry represents that last position in the trace. Hence vendors must overwrite their entry upon reentry to their tracing system.

The impact is that values are appended to the trace state up to the limit TraceState::kMaxKeyValuePairs and then dropped silently. This may occur now with the "ot" values appended to TraceState by the composite and probability samplers.

The fix is to update the Set method to copy all entries that do not match the input key from the input trace state prior to appending the new key/value entry.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the TraceState::Set method and its existing tests. Verify how entries are copied and appended, then update the behavior so an existing matching key is replaced while nonmatching entries remain. Done means duplicate keys are not retained and the behavior follows the cited W3C trace-context and OpenTelemetry requirements.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, distributed-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.