Skip to content

Commit

Permalink
record_exception: Accept BaseException
Browse files Browse the repository at this point in the history
This makes it possible to call on the exception returned by
[sys.exc_info], which is a BaseException.

For ecosystem prior art, the [equivalent in Java] accepts a Throwable
rather than Exception.

[sys.exc_info]: https://docs.python.org/3/library/sys.html#sys.exc_info
[equivalent in Java]: https://github.com/open-telemetry/opentelemetry-java/blob/7b8608591e1737ea0727d2373ddd813bc18cdaaa/api/all/src/main/java/io/opentelemetry/api/trace/Span.java#L344-L351
  • Loading branch information
kamalmarhubi committed Jun 21, 2023
1 parent 6b9f389 commit 4144797
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Add max_scale option to Exponential Bucket Histogram Aggregation [#3323](https://github.com/open-telemetry/opentelemetry-python/pull/3323))
- Use BoundedAttributes instead of raw dict to extract attributes from LogRecord and Support dropped_attributes_count in LogRecord ([#3310](https://github.com/open-telemetry/opentelemetry-python/pull/3310))
- Accept BaseException in record_exception, allowing it to be called with the
exception returned by `sys.exc_info()`
([#3354](https://github.com/open-telemetry/opentelemetry-python/pull/3354))

## Version 1.18.0/0.39b0 (2023-05-04)

Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-api/src/opentelemetry/trace/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def set_status(
@abc.abstractmethod
def record_exception(
self,
exception: Exception,
exception: BaseException,
attributes: types.Attributes = None,
timestamp: typing.Optional[int] = None,
escaped: bool = False,
Expand Down Expand Up @@ -537,7 +537,7 @@ def set_status(

def record_exception(
self,
exception: Exception,
exception: BaseException,
attributes: types.Attributes = None,
timestamp: typing.Optional[int] = None,
escaped: bool = False,
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ def __exit__(

def record_exception(
self,
exception: Exception,
exception: BaseException,
attributes: types.Attributes = None,
timestamp: Optional[int] = None,
escaped: bool = False,
Expand Down

0 comments on commit 4144797

Please sign in to comment.