Skip to content

feat(tracing): Add convenience function update_current_span. #4673

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

Merged
merged 3 commits into from
Aug 5, 2025

Conversation

antonpirker
Copy link
Member

@antonpirker antonpirker commented Aug 5, 2025

Manually setting data on spans for our insights modules can be made easier. This PR introduces a convenience function.

Right now users need to do some like this:

import sentry_sdk

span = sentry_sdk.get_current_span()
if span is not None:
    span.description = f"Some {dynamic} name"
    span.set_attribute("key1", "value1")
    span.set_attribute("key2", "value2")

With this new convenience function a user can do:

import sentry_sdk

sentry_sdk.update_current_span(
    name=f"Some {dynamic} name",
    attributes={
        "key1": "value1",
        "key2": "value2",
    },
)

Copy link

codecov bot commented Aug 5, 2025

Codecov Report

❌ Patch coverage is 53.33333% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.07%. Comparing base (63e0c67) to head (c422241).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
sentry_sdk/api.py 53.33% 4 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4673      +/-   ##
==========================================
+ Coverage   85.02%   85.07%   +0.04%     
==========================================
  Files         156      156              
  Lines       15809    15824      +15     
  Branches     2671     2677       +6     
==========================================
+ Hits        13442    13462      +20     
+ Misses       1586     1583       -3     
+ Partials      781      779       -2     
Files with missing lines Coverage Δ
sentry_sdk/__init__.py 100.00% <ø> (ø)
sentry_sdk/api.py 86.57% <53.33%> (-3.73%) ⬇️

... and 7 files with indirect coverage changes

@antonpirker antonpirker marked this pull request as ready for review August 5, 2025 09:46
@antonpirker antonpirker requested a review from a team as a code owner August 5, 2025 09:46
@antonpirker antonpirker changed the title Add convenience function update_current_span. feat(tracing): Add convenience function update_current_span. Aug 5, 2025
@antonpirker antonpirker merged commit 19914cd into master Aug 5, 2025
138 checks passed
@antonpirker antonpirker deleted the antonpirker/update_current_span branch August 5, 2025 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants