Add opt-in support for emitting exceptions as log signals#16259
Open
trask wants to merge 11 commits intoopen-telemetry:mainfrom
Open
Add opt-in support for emitting exceptions as log signals#16259trask wants to merge 11 commits intoopen-telemetry:mainfrom
trask wants to merge 11 commits intoopen-telemetry:mainfrom
Conversation
e5ccd7d to
bc09a65
Compare
trask
commented
Feb 22, 2026
bc09a65 to
161b795
Compare
161b795 to
0d2f88b
Compare
3 tasks
laurit
reviewed
Mar 2, 2026
| if (emitExceptionAsSpanEvents()) { | ||
| span.recordException(error); | ||
| } | ||
| if (emitExceptionAsLogs() && exceptionEventExtractor != null) { |
Contributor
There was a problem hiding this comment.
If the extractor is not set the exception would be lost. Is there a plan to introduce a default extractor or do we need to change the instrumenter api to force user to always provide an extractor?
Member
Author
There was a problem hiding this comment.
Member
Author
There was a problem hiding this comment.
changed the default to
- name:
"exception" - severity:
WARN
laurit
reviewed
Mar 2, 2026
…-signal # Conflicts: # instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java
ab473e9 to
d06b0e9
Compare
laurit
reviewed
Mar 3, 2026
| assertThat(log.getAttributes().get(EXCEPTION_TYPE)) | ||
| .isEqualTo("java.lang.IllegalStateException"); | ||
| assertThat(log.getAttributes().get(EXCEPTION_MESSAGE)).isEqualTo("test"); | ||
| assertThat(log.getAttributes().get(EXCEPTION_STACKTRACE)).isNotNull(); |
Contributor
There was a problem hiding this comment.
OpenTelemetryAssertions.assertThat(logs.get(0))
// Should be WARN (from setExceptionEventExtractor), not ERROR (from CONSUMER span kind)
.hasSeverity(Severity.WARN)
.hasEventName("messaging.client.operation.exception")
.hasAttributesSatisfyingExactly(equalTo(EXCEPTION_TYPE, "java.lang.IllegalStateException"),
equalTo(EXCEPTION_MESSAGE, "test"),
satisfies(EXCEPTION_STACKTRACE, AbstractAssert::isNotNull));
laurit
approved these changes
Mar 3, 2026
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.
Span events are in the process of being deprecated.
This starts to add opt-in support for emitting exceptions as logs (as opposed to span events).
Follows semantic conventions proposal: open-telemetry/semantic-conventions#3414
See #16049 for how this will be used, this PR is just laying the foundation.