Skip to content

Commit 5e7d44b

Browse files
committed
Merge branch 'master' into antonpirker/manual-instrumentation
2 parents c2d47bc + 0d569d2 commit 5e7d44b

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

sentry_sdk/tracing.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,10 @@ def set_data(self, key=None, value=None):
619619
# Traditional calling pattern: set_data(key, value)
620620
self._data[key] = value
621621

622+
def update_data(self, data):
623+
# type: (Dict[str, Any]) -> None
624+
self._data.update(data)
625+
622626
def set_flag(self, flag, result):
623627
# type: (str, bool) -> None
624628
if len(self._flags) < self._flags_capacity:
@@ -1292,6 +1296,10 @@ def set_data(self, key=None, value=None):
12921296
# type: (Optional[Union[str, Dict[str, Any]]], Optional[Any]) -> None
12931297
pass
12941298

1299+
def update_data(self, data):
1300+
# type: (Dict[str, Any]) -> None
1301+
pass
1302+
12951303
def set_status(self, value):
12961304
# type: (str) -> None
12971305
pass

tests/tracing/test_misc.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,3 +509,34 @@ def test_transaction_not_started_warning(sentry_init):
509509
"The transaction will not be sent to Sentry. To fix, start the transaction by"
510510
"passing it to sentry_sdk.start_transaction."
511511
)
512+
513+
514+
def test_span_set_data_update_data(sentry_init, capture_events):
515+
sentry_init(traces_sample_rate=1.0)
516+
517+
events = capture_events()
518+
519+
with sentry_sdk.start_transaction(name="test-transaction"):
520+
with start_span(op="test-span") as span:
521+
span.set_data("key0", "value0")
522+
span.set_data("key1", "value1")
523+
524+
span.update_data(
525+
{
526+
"key1": "updated-value1",
527+
"key2": "value2",
528+
"key3": "value3",
529+
}
530+
)
531+
532+
(event,) = events
533+
span = event["spans"][0]
534+
535+
assert span["data"] == {
536+
"key0": "value0",
537+
"key1": "updated-value1",
538+
"key2": "value2",
539+
"key3": "value3",
540+
"thread.id": mock.ANY,
541+
"thread.name": mock.ANY,
542+
}

0 commit comments

Comments
 (0)