Have user supplied attributes take precedence over exception-derived attributes#7993
Open
trask wants to merge 3 commits intoopen-telemetry:mainfrom
Open
Have user supplied attributes take precedence over exception-derived attributes#7993trask wants to merge 3 commits intoopen-telemetry:mainfrom
trask wants to merge 3 commits intoopen-telemetry:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7993 +/- ##
============================================
+ Coverage 89.99% 90.17% +0.18%
- Complexity 7079 7482 +403
============================================
Files 803 834 +31
Lines 21419 22564 +1145
Branches 2086 2240 +154
============================================
+ Hits 19276 20348 +1072
- Misses 1479 1514 +35
- Partials 664 702 +38 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jack-berg
reviewed
Jan 27, 2026
| ((ExtendedLogRecordBuilder) logger.logRecordBuilder()) | ||
| .setException(new Exception("error")) | ||
| .setAttribute(EXCEPTION_MESSAGE, "custom message") | ||
| .emit(); |
Member
There was a problem hiding this comment.
The user exception.message should take priority regardless of the invocation order yeah?
jack-berg
reviewed
Jan 27, 2026
| @@ -46,7 +45,7 @@ public ExtendedSdkLogRecordBuilder setException(Throwable throwable) { | |||
| loggerSharedState | |||
| .getExceptionAttributeResolver() | |||
| .setExceptionAttributes( | |||
| this::setAttribute, | |||
| new ExceptionAttributeSetterWithPrecedence(), | |||
Member
There was a problem hiding this comment.
Could add a private method setExceptionAttribute (or similar) with the same signature as setAttribute. This would avoid allocating the extra ExceptionAttributeSetterWithPrecedence object. Not that its hugely important because we're in the setException code path which is allocation-heavy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to open-telemetry/opentelemetry-specification#4824 (comment)