fix(span): enforce StatusCode precedence rules in setStatus per specification#6461
Merged
trentm merged 7 commits intoopen-telemetry:mainfrom Mar 5, 2026
Merged
Conversation
…fication Signed-off-by: h6o <48004352+newbee1939@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6461 +/- ##
=======================================
Coverage 95.70% 95.70%
=======================================
Files 364 364
Lines 11772 11777 +5
Branches 2743 2747 +4
=======================================
+ Hits 11266 11271 +5
Misses 506 506
🚀 New features to boost your workflow:
|
Signed-off-by: h6o <48004352+newbee1939@users.noreply.github.com>
…tatusCode precedence rules in setStatus Signed-off-by: h6o <48004352+newbee1939@users.noreply.github.com>
…tatusCode precedence Signed-off-by: h6o <48004352+newbee1939@users.noreply.github.com>
Signed-off-by: h6o <48004352+newbee1939@users.noreply.github.com>
…nce rules Signed-off-by: h6o <48004352+newbee1939@users.noreply.github.com>
…nd precedence rules Signed-off-by: h6o <48004352+newbee1939@users.noreply.github.com>
trentm
approved these changes
Mar 3, 2026
Contributor
trentm
left a comment
There was a problem hiding this comment.
LGTM. Thanks!
I'll leave it for a day or two in case others might want to review it as well.
Contributor
|
Thank you for your contribution @newbee1939! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. |
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.
Which problem is this PR solving?
SpanImpl#setStatus()does not enforce StatusCode precedence rules defined in the Trace API spec — Set Status.Specifically:
messageis not ignored forOk/Unset— Spec requires: "Description MUST be IGNORED for StatusCode Ok & Unset values."Ok > Error > Unset) is not enforced — OnceOkis set,ErrororUnsetcan still overwrite it.Unsetis not ignored.Fixes #6455
Short description of the changes
Span.ts: RewritesetStatus()to enforce spec-defined precedence (Ok > Error > Unset).Unsetis always ignored,Okis final, andmessageis only kept forError.span.ts(API): Update JSDoc to document the status precedence rules and message behavior.Span.test.ts: Add comprehensive tests for all status transitions and consolidate existingsetStatustests into a dedicateddescribe('setStatus')block.Type of change
How Has This Been Tested?
Ok > Error > Unset)Ok/Unset, kept forError, non-string dropped with warning)span.end()Checklist: