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 — Lazily evaluate ExceptionEventData exception.* attributes by jack-berg · Pull Request #7172 · open-telemetry/opentelemetry-java

Conversation

@jack-berg

@jack-berg jack-berg commented Mar 4, 2025

Copy link
Copy Markdown
Member

Currently, we compute exception.* span event attributes immediately when recordException is called.

With this PR, those attributes are computed lazily at the time of export. This should shift CPU / memory from hot path to export background threads.

Sorry, something went wrong.

Uh oh!

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

All reactions
@jack-berg
Lazily evaluate ExceptionEventData exception.* attributes
bbaa9e5
@jack-berg
jack-berg requested a review from a team as a code owner March 4, 2025 22:41
jack-berg
jack-berg commented Mar 4, 2025
View reviewed changes
Comment thread sdk/trace/src/main/java/io/opentelemetry/sdk/trace/internal/data/LazyExceptionEventData.java

abstract SpanLimits getSpanLimits();

public abstract Attributes getAdditionalAttributes();

@jack-berg jack-berg Mar 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.

cc @HaloFour I believe this should be a (temporary) workaround to the changes in #6795. To restore the behavior you were relying on, you should be able to:

  • Check if eventData instanceOf LazyExceptionEventData
  • If so, access the attributes via LazyExceptionEventData#getAdditionalAttributes() without rendering the exception.*

I'd like to followup with this PRs change with:

  • Add SDK customization hook for defining your own exception rendering logic
  • Introduce API for setting exception on logs LogRecordBuilder#setException
  • Improve the default exception rendering logic to be attribute limits aware, so that if attributes can't be longer than 1000 characters we don't waste resources rendering the stacktrace past this limit

Sorry, something went wrong.

Uh oh!

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

All reactions
@codecov

codecov Bot commented Mar 4, 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 94.59459% with 2 lines in your changes missing coverage. Please review.

Project coverage is 89.94%. Comparing base (9cb6365) to head (081960d).

Files with missing lines Patch % Lines
...dk/trace/internal/data/LazyExceptionEventData.java 93.93% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7172      +/-   ##
============================================
+ Coverage     89.92%   89.94%   +0.01%     
- Complexity     6721     6728       +7     
============================================
  Files           765      766       +1     
  Lines         20277    20305      +28     
  Branches       1985     1988       +3     
============================================
+ Hits          18234    18263      +29     
- Misses         1448     1449       +1     
+ Partials        595      593       -2     

☔ 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
jack-berg commented Mar 6, 2025
View reviewed changes
Comment thread sdk/trace/src/main/java/io/opentelemetry/sdk/trace/internal/data/LazyExceptionEventData.java Resolved

Uh oh!

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

@jack-berg jack-berg mentioned this pull request Mar 6, 2025
Add ExtendedLogRecordBuilder#setException #7182
Merged
trask
trask reviewed Apr 10, 2025
View reviewed changes
Comment thread sdk/trace/src/main/java/io/opentelemetry/sdk/trace/internal/data/LazyExceptionEventData.java Resolved

Uh oh!

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

jack-berg added 2 commits April 10, 2025 15:56
@jack-berg
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
c77f5ab
…y-java into lazy-evaluate-exception
@jack-berg
Compute exception.message on initialization
37e47a2
@trask

trask commented Apr 10, 2025

Copy link
Copy Markdown
Member

is there a connection or overlap between this PR and #7182?

All reactions

Sorry, something went wrong.

Uh oh!

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

@jack-berg

jack-berg commented Apr 10, 2025

Copy link
Copy Markdown
Member Author

is there a connection or overlap between this PR and #7182?

They solve separate problems but there will be merge conflicts I'll need to resolve regardless of which is merged first

All reactions

Sorry, something went wrong.

Uh oh!

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

@trask

trask commented Apr 10, 2025

Copy link
Copy Markdown
Member

Sounds good I'll review this one second

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…
081960d
…y-java into lazy-evaluate-exception
@jack-berg

jack-berg commented Apr 11, 2025

Copy link
Copy Markdown
Member Author

Sounds good I'll review this one second

Should be good to go now that #7182 is merged

All reactions

Sorry, something went wrong.

Uh oh!

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

trask
trask reviewed Apr 11, 2025
View reviewed changes
Comment thread sdk/trace/src/main/java/io/opentelemetry/sdk/trace/internal/data/LazyExceptionEventData.java Resolved

Uh oh!

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

jack-berg added 2 commits April 11, 2025 10:49
@jack-berg
Remove extra code from merge
2fe4233
@jack-berg
Use precomputed exception message
a7931ca
trask
trask reviewed Apr 11, 2025
View reviewed changes
Comment thread sdk/trace/src/main/java/io/opentelemetry/sdk/trace/internal/data/LazyExceptionEventData.java
// - exception.type
// - exception.message
// - exception.stacktrace
return getAdditionalAttributes().size() + 3;

@trask trask Apr 11, 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.

for users of this method does it matter that there could be overlap and so this calculation could overcount (e.g. a user overriding exception.message)?

Sorry, something went wrong.

Uh oh!

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

All reactions

@jack-berg jack-berg Apr 11, 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.

Oh great point. Need to think this through a little more

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

@jkwatson jkwatson Sep 11, 2025

Copy link
Copy Markdown
Contributor

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.

should we move this to a Draft until you're ready to get this figured out?

Sorry, something went wrong.

Uh oh!

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

All reactions
@jack-berg jack-berg mentioned this pull request Apr 11, 2025
Configurable exception.* attribute resolution #7266
Merged
@jack-berg

jack-berg commented Dec 12, 2025

Copy link
Copy Markdown
Member Author

Now that #7266 and #7281 are merged, I think the value of this is diminished. Closing and can keep it in mind if related issues come up in the future.

All reactions

Sorry, something went wrong.

Uh oh!

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

@jack-berg jack-berg closed this Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@trask trask trask left review comments
@jkwatson jkwatson jkwatson left review comments

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.

Uh oh!

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

3 participants

@jack-berg @trask @jkwatson
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.