Skip to content

Commit e32431a

Browse files
authored
Merge branch '3.12' into backport-14456-to-3.12
2 parents a8f0963 + 6e4b335 commit e32431a

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

ddtrace/_trace/_span_pointer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def __post_init__(self):
6464
def __repr__(self):
6565
return (
6666
f"SpanPointer(trace_id={self.trace_id}, span_id={self.span_id}, kind={self.kind}, "
67-
f"direction={self.direction}, hash={self.hash}, attributes={self.attributes})"
67+
f"direction={self.attributes.get('ptr.dir')}, hash={self.attributes.get('ptr.hash')}, "
68+
f"attributes={self.attributes})"
6869
)
6970

7071

ddtrace/debugging/_exception/replay.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,16 @@ def _capture_tb_frame_for_span(
266266
return snapshot is not None
267267

268268
def on_span_exception(
269-
self, span: Span, _exc_type: t.Type[BaseException], exc: BaseException, tb: t.Optional[TracebackType]
269+
self, span: Span, _exc_type: t.Type[BaseException], exc: BaseException, traceback: t.Optional[TracebackType]
270270
) -> None:
271271
if span.get_tag(DEBUG_INFO_TAG) == "true" or not can_capture(span):
272272
# Debug info for span already captured or no budget to capture
273273
return
274274

275+
# Prioritize the traceback from the exception, if available. Some
276+
# frameworks (like celery) may modify the traceback object that is
277+
# passed to the exception handler.
278+
tb = exc.__traceback__ or traceback
275279
chain, exc_id = unwind_exception_chain(exc, tb)
276280
if not chain or exc_id is None:
277281
# No exceptions to capture
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
exception replay: fixed an issue that prevented snapshots from retrieving
5+
local variables from traceback frames from exception thrown by Celery tasks.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fixes:
2+
- |
3+
tracing: Fixes a bug where calling __repr__ on SpanPointer objected raised an AttributeError. This caused aws_lambdas to crash when debug logging was enabled.

tests/tracer/test_span.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ def test_span_pprint():
855855
root.set_metric("m", 1.0)
856856
root._add_event("message", {"importance": 10}, 16789898242)
857857
root.set_link(trace_id=99, span_id=10, attributes={"link.name": "s1_to_s2", "link.kind": "scheduled_by"})
858+
root._add_span_pointer("test_kind", _SpanPointerDirection.DOWNSTREAM, "test_hash_123", {"extra": "attr"})
858859

859860
root.finish()
860861
actual = root._pprint()
@@ -867,9 +868,11 @@ def test_span_pprint():
867868
assert "metrics={'m': 1.0}" in actual
868869
assert "events=[SpanEvent(name='message', time=16789898242, attributes={'importance': 10})]" in actual
869870
assert (
870-
"[SpanLink(trace_id=99, span_id=10, attributes={'link.name': 's1_to_s2', 'link.kind': 'scheduled_by'}, "
871-
"tracestate=None, flags=None, dropped_attributes=0)]"
871+
"SpanLink(trace_id=99, span_id=10, attributes={'link.name': 's1_to_s2', 'link.kind': 'scheduled_by'}, "
872+
"tracestate=None, flags=None, dropped_attributes=0)"
872873
) in actual
874+
assert "SpanPointer(trace_id=0, span_id=0, kind=span-pointer" in actual
875+
assert "direction=d, hash=test_hash_123" in actual
873876
assert (
874877
f"context=Context(trace_id={root.trace_id}, span_id={root.span_id}, _meta={{}}, "
875878
"_metrics={}, _span_links=[], _baggage={}, _is_remote=False)"

0 commit comments

Comments
 (0)