Skip to content

Commit 0d350a2

Browse files
committed
convenience function
1 parent 63e0c67 commit 0d350a2

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

sentry_sdk/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"start_session",
5151
"end_session",
5252
"set_transaction_name",
53+
"update_current_span",
5354
]
5455

5556
# Initialize the debug support after everything is loaded

sentry_sdk/api.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def overload(x):
8585
"start_session",
8686
"end_session",
8787
"set_transaction_name",
88+
"update_current_span",
8889
]
8990

9091

@@ -473,3 +474,27 @@ def end_session():
473474
def set_transaction_name(name, source=None):
474475
# type: (str, Optional[str]) -> None
475476
return get_current_scope().set_transaction_name(name, source)
477+
478+
479+
def update_current_span(op=None, name=None, attributes=None):
480+
# type: (Optional[str], Optional[str], Optional[dict[str, Union[str, int, float, bool]]]) -> None
481+
"""
482+
Update the current span with the given parameters.
483+
:param op: The operation of the span.
484+
:param name: The name of the span.
485+
:param attributes: The attributes of the span.
486+
"""
487+
current_span = get_current_span()
488+
489+
if current_span is None:
490+
return
491+
492+
if op is not None:
493+
current_span.op = op
494+
495+
if name is not None:
496+
# internally it is still description
497+
current_span.description = name
498+
499+
if attributes is not None:
500+
current_span.update_data(attributes)

0 commit comments

Comments
 (0)