File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed
Expand file tree Collapse file tree 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
2222 ([ #4444 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/4444 ) )
2323- Updated ` tracecontext-integration-test ` gitref to ` d782773b2cf2fa4afd6a80a93b289d8a74ca894d `
2424 ([ #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 ) )
2527
2628## Version 1.30.0/0.51b0 (2025-02-03)
2729
Original file line number Diff line number Diff line change @@ -590,7 +590,7 @@ def use_span(
590590 finally :
591591 context_api .detach (token )
592592
593- except Exception as exc : # pylint: disable=broad-exception-caught
593+ except BaseException as exc : # pylint: disable=broad-exception-caught
594594 if isinstance (span , Span ) and span .is_recording ():
595595 # Record the exception as an event
596596 if record_exception :
Original file line number Diff line number Diff line change @@ -133,6 +133,18 @@ class TestUseSpanException(Exception):
133133
134134 self .assertEqual (test_span .recorded_exception , exception )
135135
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+
136148 def test_use_span_set_status (self ):
137149 class TestUseSpanException (Exception ):
138150 pass
You can’t perform that action at this time.
0 commit comments