Skip to content

Commit 95090ea

Browse files
committed
Some more detail
1 parent 7faa9a6 commit 95090ea

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

docs/adr/001_error_handling.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
## Date
44
17 Feb 2025
55

6+
## Accepted Option
7+
8+
**Option 3**
9+
610
## Context and Problem Statement
711
There is uncertainty around how to model errors in the `opentelemetry-rust` public API interfaces - that is, APIs that are exposed to users of the project's published crates. This is for example the case with the exporter traits - [SpanExporter](https://github.com/open-telemetry/opentelemetry-rust/blob/eca1ce87084c39667061281e662d5edb9a002882/opentelemetry-sdk/src/trace/export.rs#L18), [LogExporter](https://github.com/open-telemetry/opentelemetry-rust/blob/eca1ce87084c39667061281e662d5edb9a002882/opentelemetry-sdk/src/logs/export.rs#L115), and [PushMetricExporter](https://github.com/open-telemetry/opentelemetry-rust/blob/eca1ce87084c39667061281e662d5edb9a002882/opentelemetry-sdk/src/metrics/exporter.rs#L11) which form part of the API surface of `opentelemetry-sdk`.
812

@@ -12,6 +16,7 @@ There are various ways to handle errors on trait methods, including swallowing t
1216

1317
This was discussed extensively in #2571.
1418

19+
1520
## Related Work
1621

1722
* #2564
@@ -95,6 +100,8 @@ pub trait SpanExporter {
95100

96101
```
97102

103+
### When to box custom errors
104+
98105
Note above that we do not box anything into `InternalFailure`. Our rule here is that if the caller cannot reasonably be expected to handle a particular error variant, we will use a simplified interface that returns only a descriptive string. In the concrete example we are using with the exporters, we have a [strong signal in the opentelemetry-specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md#export) that indicates concretely that the error types are not actionable by the caller.
99106

100107
If the caller may potentially recover from an error, we will follow [canonical's rust best practices](https://canonical.github.io/rust-best-practices/error-and-panic-discipline.html) and instead preserve the nested error.

0 commit comments

Comments
 (0)