Skip to content

Commit 9c21889

Browse files
committed
fix: Write description and op into trace
1 parent 668fb74 commit 9c21889

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

sentry_sdk/tracing.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def __init__(
6565
self.same_process_as_parent = same_process_as_parent
6666
self.sampled = sampled
6767
self.transaction = transaction
68+
self.op = op
69+
self.description = description
6870
self._tags = {} # type: Dict[str, str]
6971
self._data = {} # type: Dict[str, Any]
7072
self._finished_spans = [] # type: List[Span]
@@ -165,14 +167,21 @@ def to_json(self):
165167
"span_id": self.span_id,
166168
"parent_span_id": self.parent_span_id,
167169
"transaction": self.transaction,
170+
"op": self.op,
171+
"description": self.description,
168172
"tags": self._tags,
169173
"data": self._data,
170174
"start_timestamp": self.start_timestamp,
171175
"timestamp": self.timestamp,
172176
}
173177

174178
def get_trace_context(self):
175-
return {"trace_id": self.trace_id, "span_id": self.span_id}
179+
return {
180+
"trace_id": self.trace_id,
181+
"span_id": self.span_id,
182+
"op": self.op,
183+
"description": self.description,
184+
}
176185

177186

178187
@contextlib.contextmanager

tests/test_tracing.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ def test_basic(sentry_init, capture_events, sample_rate):
1111

1212
with Hub.current.trace(transaction="hi"):
1313
with pytest.raises(ZeroDivisionError):
14-
with Hub.current.span():
14+
with Hub.current.span(op='foo', description='foodesc'):
1515
1 / 0
1616

17-
with Hub.current.span():
17+
with Hub.current.span(op='bar', description='bardesc'):
1818
pass
1919

2020
if sample_rate:
@@ -23,7 +23,11 @@ def test_basic(sentry_init, capture_events, sample_rate):
2323
span1, span2 = event["spans"]
2424
parent_span = event
2525
assert span1["tags"]["error"]
26+
assert span1['op'] == 'foo'
27+
assert span1['description'] == 'foodesc'
2628
assert not span2["tags"]["error"]
29+
assert span2['op'] == 'bar'
30+
assert span2['description'] == 'bardesc'
2731
assert parent_span["transaction"] == "hi"
2832
else:
2933
assert not events

0 commit comments

Comments
 (0)