-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add opt-in support for emitting exceptions as log signals #16259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
trask
wants to merge
11
commits into
open-telemetry:main
Choose a base branch
from
trask:exceptions-over-log-signal
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0d2f88b
Add opt-in support for emitting exceptions as log signals
trask ca470b9
Merge branch 'main' into exceptions-over-log-signal
trask 5732f14
Merge remote-tracking branch 'upstream/main' into exceptions-over-log…
trask d06b0e9
Add default ExceptionEventExtractor
trask 9b2df30
update assertion pattern
trask 79d41ef
Merge branch 'main' into exceptions-over-log-signal
trask 02f15a8
update
trask 7964b79
Merge remote-tracking branch 'upstream/main' into exceptions-over-log…
trask 1df0fb1
update
trask 078fb6b
update fallback event name based on latest semconv PR updates
trask bc15ede
spotless
trask File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
40 changes: 40 additions & 0 deletions
40
.../io/opentelemetry/instrumentation/api/incubator/instrumenter/ExceptionEventExtractor.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.api.incubator.instrumenter; | ||
|
|
||
| import io.opentelemetry.api.logs.LogRecordBuilder; | ||
| import io.opentelemetry.api.logs.Severity; | ||
| import io.opentelemetry.context.Context; | ||
| import io.opentelemetry.instrumentation.api.internal.InternalExceptionEventExtractor; | ||
|
|
||
| /** | ||
| * Extractor that populates the exception event {@link LogRecordBuilder} for a request. This allows | ||
| * instrumentations to set the event name, severity, and any additional attributes on the exception | ||
| * log event. | ||
| * | ||
| * <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
| * at any time. | ||
| */ | ||
| @FunctionalInterface | ||
| public interface ExceptionEventExtractor<REQUEST> extends InternalExceptionEventExtractor<REQUEST> { | ||
|
|
||
| /** | ||
| * Returns an {@link ExceptionEventExtractor} that always sets the given event name and severity. | ||
| */ | ||
| static <REQUEST> ExceptionEventExtractor<REQUEST> create(String eventName, Severity severity) { | ||
| return (logRecordBuilder, context, request) -> { | ||
| logRecordBuilder.setEventName(eventName); | ||
| logRecordBuilder.setSeverity(severity); | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Populates the exception event {@link LogRecordBuilder} with the event name, severity, and any | ||
| * additional attributes for the given context and request. | ||
| */ | ||
| @Override | ||
| void extract(LogRecordBuilder logRecordBuilder, Context context, REQUEST request); | ||
| } |
25 changes: 25 additions & 0 deletions
25
...io/opentelemetry/instrumentation/api/incubator/semconv/db/DbExceptionEventExtractors.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.api.incubator.semconv.db; | ||
|
|
||
| import io.opentelemetry.api.logs.Severity; | ||
| import io.opentelemetry.instrumentation.api.incubator.instrumenter.ExceptionEventExtractor; | ||
|
|
||
| /** | ||
| * {@link ExceptionEventExtractor} constants for DB client instrumentations. | ||
| * | ||
| * <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
| * at any time. | ||
| */ | ||
| public final class DbExceptionEventExtractors { | ||
|
|
||
| /** Exception event extractor for DB client spans. */ | ||
| public static <REQUEST> ExceptionEventExtractor<REQUEST> client() { | ||
| return ExceptionEventExtractor.create("db.client.operation.exception", Severity.WARN); | ||
| } | ||
|
|
||
| private DbExceptionEventExtractors() {} | ||
| } |
25 changes: 25 additions & 0 deletions
25
...ntelemetry/instrumentation/api/incubator/semconv/genai/GenAiExceptionEventExtractors.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.api.incubator.semconv.genai; | ||
|
|
||
| import io.opentelemetry.api.logs.Severity; | ||
| import io.opentelemetry.instrumentation.api.incubator.instrumenter.ExceptionEventExtractor; | ||
|
|
||
| /** | ||
| * {@link ExceptionEventExtractor} constants for GenAI client instrumentations. | ||
| * | ||
| * <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
| * at any time. | ||
| */ | ||
| public final class GenAiExceptionEventExtractors { | ||
|
|
||
| /** Exception event extractor for GenAI client spans. */ | ||
| public static <REQUEST> ExceptionEventExtractor<REQUEST> client() { | ||
| return ExceptionEventExtractor.create("gen_ai.client.operation.exception", Severity.WARN); | ||
| } | ||
|
|
||
| private GenAiExceptionEventExtractors() {} | ||
| } |
30 changes: 30 additions & 0 deletions
30
...pentelemetry/instrumentation/api/incubator/semconv/http/HttpExceptionEventExtractors.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.api.incubator.semconv.http; | ||
|
|
||
| import io.opentelemetry.api.logs.Severity; | ||
| import io.opentelemetry.instrumentation.api.incubator.instrumenter.ExceptionEventExtractor; | ||
|
|
||
| /** | ||
| * {@link ExceptionEventExtractor} constants for HTTP client and server instrumentations. | ||
| * | ||
| * <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
| * at any time. | ||
| */ | ||
| public final class HttpExceptionEventExtractors { | ||
|
|
||
| /** Exception event extractor for HTTP client spans. */ | ||
| public static <REQUEST> ExceptionEventExtractor<REQUEST> client() { | ||
| return ExceptionEventExtractor.create("http.client.request.exception", Severity.WARN); | ||
| } | ||
|
|
||
| /** Exception event extractor for HTTP server spans. */ | ||
| public static <REQUEST> ExceptionEventExtractor<REQUEST> server() { | ||
| return ExceptionEventExtractor.create("http.server.request.exception", Severity.ERROR); | ||
| } | ||
|
|
||
| private HttpExceptionEventExtractors() {} | ||
| } |
30 changes: 30 additions & 0 deletions
30
...ry/instrumentation/api/incubator/semconv/messaging/MessagingExceptionEventExtractors.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.api.incubator.semconv.messaging; | ||
|
|
||
| import io.opentelemetry.api.logs.Severity; | ||
| import io.opentelemetry.instrumentation.api.incubator.instrumenter.ExceptionEventExtractor; | ||
|
|
||
| /** | ||
| * {@link ExceptionEventExtractor} constants for messaging instrumentations. | ||
| * | ||
| * <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
| * at any time. | ||
| */ | ||
| public final class MessagingExceptionEventExtractors { | ||
|
|
||
| /** Exception event extractor for messaging client operation spans. */ | ||
| public static <REQUEST> ExceptionEventExtractor<REQUEST> client() { | ||
| return ExceptionEventExtractor.create("messaging.client.operation.exception", Severity.WARN); | ||
| } | ||
|
|
||
| /** Exception event extractor for messaging process spans. */ | ||
| public static <REQUEST> ExceptionEventExtractor<REQUEST> process() { | ||
| return ExceptionEventExtractor.create("messaging.process.exception", Severity.ERROR); | ||
| } | ||
|
|
||
| private MessagingExceptionEventExtractors() {} | ||
| } |
30 changes: 30 additions & 0 deletions
30
.../opentelemetry/instrumentation/api/incubator/semconv/rpc/RpcExceptionEventExtractors.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.api.incubator.semconv.rpc; | ||
|
|
||
| import io.opentelemetry.api.logs.Severity; | ||
| import io.opentelemetry.instrumentation.api.incubator.instrumenter.ExceptionEventExtractor; | ||
|
|
||
| /** | ||
| * {@link ExceptionEventExtractor} constants for RPC client and server instrumentations. | ||
| * | ||
| * <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
| * at any time. | ||
| */ | ||
| public final class RpcExceptionEventExtractors { | ||
|
|
||
| /** Exception event extractor for RPC client spans. */ | ||
| public static <REQUEST> ExceptionEventExtractor<REQUEST> client() { | ||
| return ExceptionEventExtractor.create("rpc.client.call.exception", Severity.WARN); | ||
| } | ||
|
|
||
| /** Exception event extractor for RPC server spans. */ | ||
| public static <REQUEST> ExceptionEventExtractor<REQUEST> server() { | ||
| return ExceptionEventExtractor.create("rpc.server.call.exception", Severity.ERROR); | ||
| } | ||
|
|
||
| private RpcExceptionEventExtractors() {} | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
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?
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.
added a default
name is
{instrumentationName}.exceptionseverity is WARN
cc @lmolkova
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.
changed the default to
"exception"WARNbased on open-telemetry/semantic-conventions#3311