Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use semconv exception attributes for record exceptions in spans #3979

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading