Skip to content

Commit

Permalink
Use semconv exception attributes for record exceptions in spans (open…
Browse files Browse the repository at this point in the history
  • Loading branch information
emdneto authored Jun 20, 2024
1 parent 3ed6303 commit e2da5a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#3973](https://github.com/open-telemetry/opentelemetry-python/pull/3966))
- Update semantic conventions to version 1.26.0.
([#3964](https://github.com/open-telemetry/opentelemetry-python/pull/3964))
- Use semconv exception attributes for record exceptions in spans
([#3979](https://github.com/open-telemetry/opentelemetry-python/pull/3979))

## Version 1.25.0/0.46b0 (2024-05-30)

Expand Down
14 changes: 10 additions & 4 deletions opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
InstrumentationInfo,
InstrumentationScope,
)
from opentelemetry.semconv.attributes.exception_attributes import (
EXCEPTION_ESCAPED,
EXCEPTION_MESSAGE,
EXCEPTION_STACKTRACE,
EXCEPTION_TYPE,
)
from opentelemetry.trace import NoOpTracer, SpanContext
from opentelemetry.trace.status import Status, StatusCode
from opentelemetry.util import types
Expand Down Expand Up @@ -1016,10 +1022,10 @@ def record_exception(
else qualname
)
_attributes: MutableMapping[str, types.AttributeValue] = {
"exception.type": exception_type,
"exception.message": str(exception),
"exception.stacktrace": stacktrace,
"exception.escaped": str(escaped),
EXCEPTION_TYPE: exception_type,
EXCEPTION_MESSAGE: str(exception),
EXCEPTION_STACKTRACE: stacktrace,
EXCEPTION_ESCAPED: str(escaped),
}
if attributes:
_attributes.update(attributes)
Expand Down

0 comments on commit e2da5a7

Please sign in to comment.