From 065f068cfe7604605030969095382cbe7ec68f37 Mon Sep 17 00:00:00 2001 From: emdneto <9735060+emdneto@users.noreply.github.com> Date: Tue, 18 Jun 2024 12:35:41 -0300 Subject: [PATCH 1/2] fix: use semconv exception attributes in record exception --- .../src/opentelemetry/sdk/trace/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py index 99c0825f9e5..4c34b8e9d5a 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py @@ -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 @@ -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) From 45483d14c0a74482b4e3347466d67795fa6cadab Mon Sep 17 00:00:00 2001 From: emdneto <9735060+emdneto@users.noreply.github.com> Date: Tue, 18 Jun 2024 12:47:41 -0300 Subject: [PATCH 2/2] add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12514078c63..83e9f4d5d13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - enable mypy and fix detected issues - allow to drop specific attributes in preparation for Semantic Conventions v1.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)