File tree 3 files changed +15
-1
lines changed
3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
22
22
([ #4444 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/4444 ) )
23
23
- Updated ` tracecontext-integration-test ` gitref to ` d782773b2cf2fa4afd6a80a93b289d8a74ca894d `
24
24
([ #4448 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/4448 ) )
25
+ - Make ` trace_api.use_span() ` record ` BaseException ` as well as ` Exception `
26
+ ([ #4406 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/4406 ) )
25
27
26
28
## Version 1.30.0/0.51b0 (2025-02-03)
27
29
Original file line number Diff line number Diff line change @@ -590,7 +590,7 @@ def use_span(
590
590
finally :
591
591
context_api .detach (token )
592
592
593
- except Exception as exc : # pylint: disable=broad-exception-caught
593
+ except BaseException as exc : # pylint: disable=broad-exception-caught
594
594
if isinstance (span , Span ) and span .is_recording ():
595
595
# Record the exception as an event
596
596
if record_exception :
Original file line number Diff line number Diff line change @@ -133,6 +133,18 @@ class TestUseSpanException(Exception):
133
133
134
134
self .assertEqual (test_span .recorded_exception , exception )
135
135
136
+ def test_use_span_base_exception (self ):
137
+ class TestUseSpanBaseException (BaseException ):
138
+ pass
139
+
140
+ test_span = SpanTest (trace .INVALID_SPAN_CONTEXT )
141
+ exception = TestUseSpanBaseException ("test exception" )
142
+ with self .assertRaises (TestUseSpanBaseException ):
143
+ with trace .use_span (test_span ):
144
+ raise exception
145
+
146
+ self .assertEqual (test_span .recorded_exception , exception )
147
+
136
148
def test_use_span_set_status (self ):
137
149
class TestUseSpanException (Exception ):
138
150
pass
You can’t perform that action at this time.
0 commit comments