Skip to content

Commit e9f38aa

Browse files
author
Liudmila Molkova
committed
feedback
1 parent f5d5691 commit e9f38aa

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

oteps/4333-recording-exceptions-on-logs.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
- [API changes](#api-changes)
99
- [Examples](#examples)
1010
* [Logging exception from client library in a user application](#logging-exception-from-client-library-in-a-user-application)
11-
* [Logging error inside the library (native instrumentation)](#logging-error-inside-the-library-native-instrumentation)
11+
* [Logging error inside the natively instrumented Library](#logging-error-inside-the-natively-instrumented-library)
1212
* [Logging errors in messaging processor](#logging-errors-in-messaging-processor)
13-
+ [Native instrumentation](#native-instrumentation)
13+
+ [Natively instrumented library](#natively-instrumented-library)
1414
+ [Instrumentation library](#instrumentation-library)
1515
- [Trade-offs and mitigations](#trade-offs-and-mitigations)
1616
- [Prior art and alternatives](#prior-art-and-alternatives)
@@ -51,8 +51,13 @@ starting point, but they are encouraged to adjust it to their needs.
5151
This guidance boils down to the following:
5252

5353
Instrumentations should record exception information (along with other context) on the log record and
54-
use appropriate severity - only unhandled exceptions should be recorded as `Error` or higher. Instrumentations
55-
should strive to report each exception once.
54+
use appropriate severity - only unhandled exceptions should be recorded as `Error` or higher.
55+
56+
> [!NOTE]
57+
>
58+
> As a result of applying this guidance, only top-level instrumentations (native and non-native) should record exceptions at `Error` (or higher) severity.
59+
60+
Instrumentations should strive to report each exception once.
5661

5762
Instrumentations should provide the whole exception instance to the OTel SDK (instead of individual attributes)
5863
and the SDK should, based on configuration, decide which information to record. As a default,
@@ -66,17 +71,13 @@ this OTEP proposes to record exception stack traces on logs with `Error` or high
6671
2. Instrumentations for incoming requests, message processing, background job execution, or others that wrap user code and usually create local root spans, should record logs
6772
for unhandled exceptions with `Error` severity.
6873

69-
> [!NOTE]
70-
>
71-
> Only top-level instrumentations (native and non-native) should record exceptions at `Error` (or higher) severity.
72-
7374
Some runtimes provide global exception handler that can be used to log exceptions.
7475
Priority should be given to the instrumentation point where the operation context is available.
7576
Language SIGs are encouraged to give runtime-specific guidance. For example, here is the
76-
[.NET guidance](https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/docs/trace/reporting-exceptions#unhandled-exception)
77+
[.NET guidance](https://github.com/open-telemetry/opentelemetry-dotnet/blob/610045298873397e55e0df6cd777d4901ace1f63/docs/trace/reporting-exceptions/README.md#unhandled-exception)
7778
for recording exceptions on traces.
7879

79-
3. Native instrumentations should record log describing an error and the context it happened in
80+
3. Natively instrumented libraries should record log describing an error and the context it happened in
8081
when this error is detected (or where the most context is available).
8182

8283
4. It's not recommended to record the same error as it propagates through the stack trace or
@@ -156,7 +157,7 @@ try {
156157
}
157158
```
158159

159-
### Logging error inside the instrumented Library (native instrumentation)
160+
### Logging error inside the natively instrumented Library
160161

161162
It's a common practice to record exceptions using logging libraries. Client libraries that are natively instrumented with OpenTelemetry should
162163
leverage OTel Events/Logs API for their exception logging purposes.
@@ -218,7 +219,7 @@ public class NetworkClient {
218219

219220
### Logging errors in messaging processor
220221

221-
#### Native instrumentation
222+
#### Natively instrumented library
222223

223224
In this example, application code provides the callback to the messaging processor to
224225
execute for each message.
@@ -242,7 +243,7 @@ MessageContext context = retrieveNext();
242243
try {
243244
processMessage.accept(context)
244245
} catch (Throwable t) {
245-
// This native instrumentation may use OTel log API or another logging library such as slf4j.
246+
// This natively instrumented library may use OTel log API or another logging library such as slf4j.
246247
// Here we use Error severity since this exception was not handled by the application code.
247248
logger.atError()
248249
.addKeyValuePair("messaging.message.id", context.getMessageId())
@@ -253,7 +254,7 @@ try {
253254
}
254255
```
255256

256-
If native instrumentation supports tracing, it should capture the error in the scope of the processing
257+
If this instrumentation supports tracing, it should capture the error in the scope of the processing
257258
span.
258259

259260
#### Instrumentation library

0 commit comments

Comments
 (0)