-
Notifications
You must be signed in to change notification settings - Fork 508
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
feat: OTLP Exporter builders to return specific Error type #2790
feat: OTLP Exporter builders to return specific Error type #2790
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2790 +/- ##
=======================================
+ Coverage 79.6% 80.2% +0.5%
=======================================
Files 124 123 -1
Lines 23315 23334 +19
=======================================
+ Hits 18582 18720 +138
+ Misses 4733 4614 -119 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR refactors the OTLP Exporter builders to return a well-defined error type (ExporterBuildError) instead of a generic or signal‐specific error, thereby improving error handling clarity and consistency. It also removes an unused Error enum from the Log SDK and updates tests, examples, and changelogs to reflect these breaking changes.
- Update error type definitions and conversions across tonic and http exporters.
- Remove the unused Log SDK error enum.
- Adjust tests, examples, and changelogs to document the breaking changes.
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
opentelemetry-otlp/src/exporter/tonic/mod.rs | Updated error conversions and function signatures to use ExporterBuildError. |
opentelemetry-otlp/src/exporter/mod.rs | Updated error handling in trait implementations and FromStr. |
opentelemetry-otlp/src/exporter/http/mod.rs | Switched error type to ExporterBuildError and added a TODO for thread-spawn handling. |
opentelemetry-sdk/CHANGELOG.md & opentelemetry-otlp/CHANGELOG.md | Documented breaking changes for the new error handling approach. |
Various exporter and span modules, examples, and tests | Modified build functions and tests to accommodate the updated error type. |
Comments suppressed due to low confidence (1)
opentelemetry-otlp/src/exporter/http/mod.rs:171
- Consider handling errors from thread spawning instead of using unwrap, to prevent potential panics. Propagate a proper ExporterBuildError instead of unwrapping the thread result.
.join().unwrap(), // TODO: Return ExporterBuildError::ThreadSpawnFailed
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.
I just took a brief look, and overall I agree with these changes and think its a good direction to go.
the only small comment I have currently is asserting the errors are of the expected variant for the builder errors
Thanks. I expect to add more tests in a follow up. Tests require some combinations of feature flags to ensure it validates what we want it to validate! |
use opentelemetry_sdk::Resource; | ||
|
||
use std::error::Error; | ||
|
||
fn init_tracer_provider() -> Result<opentelemetry_sdk::trace::SdkTracerProvider, TraceError> { | ||
fn init_tracer_provider() -> Result<opentelemetry_sdk::trace::SdkTracerProvider, ExporterBuildError> |
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.
unintended change for the {
?
pub enum ExporterBuildError { | ||
/// Spawning a new thread failed. | ||
#[error("Spawning a new thread failed. Unable to create Reqwest-Blocking client.")] | ||
ThreadSpawnFailed, |
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.
This will only happens if reqwest-blocking is used right? If so can we guard it in feature flag?
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.
yes, thats why I put a big TODO on this. we definitely need to refine it and see which ones makes sense and remove others.
|
||
/// Feature required to use the specified compression algorithm. | ||
#[cfg(any(not(feature = "gzip-tonic"), not(feature = "zstd-tonic")))] | ||
#[error("feature '{0}' is required to use the compression algorithm '{1}'")] |
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.
Hmm looks like a little bit inconsistent if the first letter is upper case across the variant?
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.
yes will address them in follow ups.
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.
Nothing blocking. LGTM once the comments are addressed
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.
LGTM - Spent some time to review, and realized it is merged meanwhile :)
Fixes #2561
Also removes now unused Error enum from Log SDK. Another set of cleanup required to clean Metrics, Traces completely.
Also, the newly introduced enum ExporterBuildError is not fully refined, this can be done in follow ups. This is necessary to unblock Log SDK Stable Release.
Note: This is a breaking change for OTLP Exporter, however, the impact is minimal (most users/examples simply unwrap/expect the Result instead of matching on it.), as described in the changelog, so I propose to make the change even though OTLP Exporter is marked RC.