GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Configurable exception.* attribute resolution by jack-berg · Pull Request #7266 · open-telemetry/opentelemetry-java

Conversation

@jack-berg

@jack-berg jack-berg commented Apr 10, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Resolves #5187.

Make exception.* resolution configurable. With #7182, exception.* attributes are now resolved and attached to both span events and log records. This is an edge cases where the SDK specification has a dependency on the semantic conventions. It seems appropriate to make this a configurable extension point, so that users can customize things like the exception.stacktrace resolution, and whether they even want exception attributes included at all.

Broken out from #7182. Leaving as a draft because this makes the most sense after merging #7182.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jack-berg added 5 commits March 6, 2025 12:37
@jack-berg
Add ExtendedLogRecordBuilder#setException, make exception.* resolutio…
9f2ecde
…n configurable
@jack-berg
Use System.lineSeparator() instead of \n to fix build
1b0a28e
@jack-berg
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
7a62f68
…y-java into logbuilder-set-exception
@jack-berg
Remove ExtendedLogRecordBuilder#setException
daa8e38
@jack-berg
Restore werror
64ea76d
@jack-berg jack-berg mentioned this pull request Apr 10, 2025
Add ExtendedLogRecordBuilder#setException #7182
Merged
@codecov

codecov Bot commented Apr 10, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 83.33333% with 12 lines in your changes missing coverage. Please review.

Project coverage is 89.75%. Comparing base (90e030f) to head (09b99a5).
Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
...ntelemetry/sdk/internal/ExtendedAttributesMap.java 20.00% 3 Missing and 1 partial ⚠️
...a/io/opentelemetry/sdk/internal/AttributesMap.java 50.00% 1 Missing and 1 partial ⚠️
...dk/internal/DefaultExceptionAttributeResolver.java 86.66% 0 Missing and 2 partials ⚠️
...metry/sdk/logs/internal/SdkLoggerProviderUtil.java 75.00% 2 Missing ⚠️
...etry/sdk/trace/internal/SdkTracerProviderUtil.java 75.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7266      +/-   ##
============================================
- Coverage     89.83%   89.75%   -0.08%     
- Complexity     6895     6977      +82     
============================================
  Files           786      797      +11     
  Lines         20793    21165     +372     
  Branches       2026     2056      +30     
============================================
+ Hits          18679    18997     +318     
- Misses         1469     1505      +36     
- Partials        645      663      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jack-berg
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
bf7ab7d
…y-java into exception-attribute-resolver
@jack-berg
jack-berg marked this pull request as ready for review April 11, 2025 20:13
@jack-berg
jack-berg requested a review from a team as a code owner April 11, 2025 20:13
jack-berg
jack-berg commented Apr 11, 2025
View reviewed changes
Comment thread sdk/common/src/main/java/io/opentelemetry/sdk/internal/ExceptionAttributeResolver.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

fandreuz
fandreuz reviewed Apr 18, 2025
View reviewed changes
Comment thread sdk/logs/src/main/java/io/opentelemetry/sdk/logs/internal/SdkLoggerProviderUtil.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@trask

trask commented Apr 18, 2025

Copy link
Copy Markdown
Member

cc @HaloFour

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

HaloFour
HaloFour reviewed Apr 18, 2025
View reviewed changes
Comment thread sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkSpan.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

HaloFour
HaloFour reviewed Apr 18, 2025
View reviewed changes
Comment thread sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkSpan.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

jack-berg added 4 commits May 30, 2025 16:05
@jack-berg
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
c31ba99
…y-java into exception-attribute-resolver
@jack-berg
Consolidate to single ExceptionAttributeResolver method
8c5e2f6
@jack-berg
cleanup
84d78c7
@jack-berg
More cleanup
06f974d
@jack-berg

jack-berg commented May 30, 2025

Copy link
Copy Markdown
Member Author

Alright I've refactored this to reflect the recommendation from this convo to consolidate into a single method. Please take another look when you can @trask! Would love to get this merged to unblock #7281, which I think will make a nice positive perf impact for many users.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

trask
trask reviewed Jun 4, 2025
View reviewed changes
Comment thread sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkTracerProviderTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread sdk/common/src/main/java/io/opentelemetry/sdk/internal/AttributesMap.java
Comment on lines -61 to +63
public Object put(AttributeKey<?> key, Object value) {
public Object put(AttributeKey<?> key, @Nullable Object value) {
if (value == null) {
return null;

@trask trask Jun 4, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this change have any effect on existing behaviors that we should be aware of?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jack-berg jack-berg Jun 4, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it shouldn't.

I wasn't quite remembering why I added this in the first place, so I retraced my steps and determined:

  • ExceptionAttributeResolver.AttributeSetter#setAttribute accepts a @Nullable T value. We want this because we recently updated Span, LogRecord setAttribute methods to accept @Nullable values.
  • AttributeMap#putIfCapacity acts as the implementation for this method
  • AttributeMap#putIfCapacity delegates to AttributeMap#put (I want both methods to reduce accidental mistakes of bypassing the validation, as discussed in the javadoc of this class)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

trask reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@jack-berg
feedback
09b99a5
trask
trask approved these changes Jun 5, 2025
View reviewed changes
@jack-berg
jack-berg merged commit b11316b into open-telemetry:main Jun 5, 2025
@philsttr

philsttr commented Aug 20, 2025

Copy link
Copy Markdown

Hey Folks, as a followup to this PR, is there work planned to make the log4j / logback appenders use the ExtendedLogRecordBuilder.setException(..) method that uses the new ExceptionAttributeResolver introduced in this PR rather than setting the exception.* attributes directly ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trask

trask commented Aug 21, 2025

Copy link
Copy Markdown
Member

hi @philsttr, can you open an issue in the java instrumentation repo where those appenders live? thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@philsttr philsttr mentioned this pull request Aug 21, 2025
Utilize ExceptionAttributeResolver in log4j/logback appenders open-telemetry/opentelemetry-java-instrumentation#14485
Closed
@philsttr

philsttr commented Aug 21, 2025

Copy link
Copy Markdown

Done! open-telemetry/opentelemetry-java-instrumentation#14485

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Dec 12, 2025
Lazily evaluate ExceptionEventData exception.* attributes #7172
Closed
Adds option to SpanLimits to exclude exception.stacktrace attribute #7133
Closed
@jack-berg jack-berg mentioned this pull request Dec 19, 2025
Moving the rendering of the exception back into SdkSpan makes exception attribute rendering unavoidable and is expensive #7129
Closed
@trask trask mentioned this pull request Jan 7, 2026
Add optional Exception parameter to Emit LogRecord open-telemetry/opentelemetry-specification#4824
Merged
github-merge-queue Bot pushed a commit to open-telemetry/opentelemetry-specification that referenced this pull request Jan 23, 2026
@trask @pellared
Add optional Exception parameter to Emit LogRecord (#4824)
e0a5864
Part of [OTEP
4430](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/4430-span-event-api-deprecation-plan.md).

This could be considered "just a convenience", but (in addition to a
very nice convenience) it also unlocks two additional features:
- Performance optimization since the SDK can take
`OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT` into consideration when generating
large `exception.stacktrace` attributes (a very real issue in the Java
world: open-telemetry/opentelemetry-java#7281)
- (Future) customization of exception stacktraces (we have experimental
support for this in Java, e.g. to support "smarter" truncation of long
`exception.stacktrace` attributes:
open-telemetry/opentelemetry-java#7266)

Prototype:
open-telemetry/opentelemetry-java#7182

---------

Co-authored-by: Robert Pająk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@trask trask trask approved these changes
+2 more reviewers
@fandreuz fandreuz fandreuz left review comments
@HaloFour HaloFour HaloFour left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Exception stack trace to string conversion customization

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@jack-berg @trask @philsttr @fandreuz @HaloFour
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.