-
Notifications
You must be signed in to change notification settings - Fork 542
fix(tracing): widen Span.set_tag value annotation to match implementation #19814
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
Closed
+22
−7
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
8 changes: 8 additions & 0 deletions
8
releasenotes/notes/widen-set-tag-value-typing-40a41e0a8804ec18.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| fixes: | ||
| - | | ||
| tracing: This fix resolves an issue where type checkers rejected valid application code passing | ||
| non-string values to ``Span.set_tag`` (for example ``span.set_tag("custom.tag", True)``). The | ||
| ``value`` parameter was annotated as ``Optional[str]``, but the implementation accepts the | ||
| historic domain: booleans and bytes are stringified into tags, and numeric values are stored | ||
| as metrics. |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For integers outside the signed 64-bit range or non-finite floats, this new public documentation is incorrect:
extract_attributeinsrc/native/span/span_data.rsstringifies overflowing integers and drops NaN/Infinity rather than storing them as metrics. Callers relying on this documented guarantee will therefore find a string tag or no value at all, so the sentence should state the supported numeric range and finite-value restriction. This docstring is customer-facing becauseSpanis exposed throughddtrace.trace.AGENTS.md reference: AGENTS.md:L25-L30
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed — thanks, this is a fair catch on a line I added. Fixed in a79c7c6.
I verified it against
extract_attributeinsrc/native/span/span_data.rs(overflowing ints fall through to thestr()fallback; NaN/Infreturn None) and then measured it through the publicset_tagpath on 4.13.1:So integers beyond the signed 64-bit range become string tags, and NaN/infinite floats are dropped from both
get_metrics()andget_tags()— my unqualified sentence was wrong on both counts.One addition: there is a third exception the comment doesn't mention.
http.status_codehas a dedicated always-stringify path inextract_attribute, so an int there is also not stored as a metric:The docstring now states the 64-bit range, the finite-value restriction, and the
http.status_codecase.