Skip to content

Add ExtendedLogRecordBuilder#setException#7182

Merged
jack-berg merged 5 commits intoopen-telemetry:mainfrom
jack-berg:logbuilder-set-exception
Apr 11, 2025
Merged

Add ExtendedLogRecordBuilder#setException#7182
jack-berg merged 5 commits intoopen-telemetry:mainfrom
jack-berg:logbuilder-set-exception

Conversation

@jack-berg
Copy link
Member

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

See comment

  • Add LogRecordBuilder#setException - All log appenders have code like this to translate an exception to equivalent exception.*. Standardizing in the SDK "DRY"s up the instrumentation code, and provides a more familiar log API experience.
  • Make exception.* resolution configurable - 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. see comment
@jack-berg jack-berg requested a review from a team as a code owner March 6, 2025 18:44
@codecov
Copy link

codecov bot commented Mar 6, 2025

Codecov Report

Attention: Patch coverage is 82.14286% with 5 lines in your changes missing coverage. Please review.

Project coverage is 89.97%. Comparing base (d7fb208) to head (7f06c87).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...a/io/opentelemetry/sdk/internal/AttributeUtil.java 89.47% 0 Missing and 2 partials ⚠️
...io/opentelemetry/sdk/logs/SdkLogRecordBuilder.java 50.00% 1 Missing and 1 partial ⚠️
...etry/api/incubator/logs/ExtendedDefaultLogger.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7182      +/-   ##
============================================
- Coverage     89.98%   89.97%   -0.02%     
- Complexity     6685     6689       +4     
============================================
  Files           749      749              
  Lines         20191    20200       +9     
  Branches       1977     1977              
============================================
+ Hits          18168    18174       +6     
- Misses         1431     1433       +2     
- Partials        592      593       +1     

☔ 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.
@jack-berg
Copy link
Member Author

Per conversation in the 4/10/25 java SIG, I've broken out the configurable exception.* attribute value resolution into a separate PR, #7266.

@trask trask changed the title Add ExtendedLogRecordBuilder#setException, make exception.* resolution configurable Apr 10, 2025
@jack-berg jack-berg merged commit 4e243f2 into open-telemetry:main Apr 11, 2025
28 checks passed
github-merge-queue bot pushed a commit to open-telemetry/opentelemetry-specification that referenced this pull request Jan 23, 2026
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 <pellared@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants