Skip to content

Commit f36d96b

Browse files
authored
Merge branch 'main' into 2024/add/tokenTyping
2 parents 791bff3 + 1bd9ec6 commit f36d96b

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
([#4444](https://github.com/open-telemetry/opentelemetry-python/pull/4444))
2525
- Updated `tracecontext-integration-test` gitref to `d782773b2cf2fa4afd6a80a93b289d8a74ca894d`
2626
([#4448](https://github.com/open-telemetry/opentelemetry-python/pull/4448))
27+
- Make `trace_api.use_span()` record `BaseException` as well as `Exception`
28+
([#4406](https://github.com/open-telemetry/opentelemetry-python/pull/4406))
2729

2830
## Version 1.30.0/0.51b0 (2025-02-03)
2931

opentelemetry-api/src/opentelemetry/trace/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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:

opentelemetry-api/tests/trace/test_globals.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)