-
Notifications
You must be signed in to change notification settings - Fork 554
chore: modify LogExporter and TraceExporter interfaces to support returning failure #2381
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
Changes from all commits
2c24988
5b243a6
77d9a01
dc5d9b1
1b49188
a670a4e
6440a73
3c68efa
c2586ce
a460184
b1fff95
0ad193f
4df322f
26bbdc4
de49068
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
//! Wrapper for error from trace, logs and metrics part of open telemetry. | ||
use std::sync::PoisonError; | ||
|
||
#[cfg(feature = "logs")] | ||
use crate::logs::LogError; | ||
#[cfg(feature = "metrics")] | ||
use crate::metrics::MetricError; | ||
use opentelemetry::propagation::PropagationError; | ||
#[cfg(feature = "trace")] | ||
use opentelemetry::trace::TraceError; | ||
use std::sync::PoisonError; | ||
use std::time::Duration; | ||
use thiserror::Error; | ||
|
||
/// Wrapper for error from both tracing and metrics part of open telemetry. | ||
/// Wrapper for error from both tracing and metrics part of open telemetry. This | ||
/// gives us a common error type where we _need_ to return errors that may come | ||
/// from various components. | ||
#[derive(thiserror::Error, Debug)] | ||
#[non_exhaustive] | ||
pub enum Error { | ||
|
@@ -34,6 +37,10 @@ | |
/// Error happens when injecting and extracting information using propagators. | ||
Propagation(#[from] PropagationError), | ||
|
||
/// Failed to shutdown an exporter | ||
#[error(transparent)] | ||
Shutdown(#[from] ShutdownError), | ||
|
||
#[error("{0}")] | ||
/// Other types of failures not covered by the variants above. | ||
Other(String), | ||
|
@@ -44,3 +51,28 @@ | |
Error::Other(err.to_string()) | ||
} | ||
} | ||
|
||
/// Errors returned by shutdown operations in the Export API. | ||
#[derive(Error, Debug)] | ||
#[non_exhaustive] | ||
pub enum ShutdownError { | ||
/// Shutdown timed out before completing. | ||
#[error("Shutdown timed out after {0:?}")] | ||
Timeout(Duration), | ||
|
||
/// The export client failed while holding the client lock. It is not | ||
/// possible to complete the shutdown and a retry will not help. | ||
/// This is something that should not happen and should likely emit some diagnostic. | ||
#[error("export client failed while holding lock; cannot retry.")] | ||
ClientFailed(String), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is exposing internal details. "Client" may or may not be a thing, depending on the exporter. Can we live with the following for Provider.ShutDown()
Provider.ShutDown() is expected to pass shutdown() calls to registered Processors/Readers, and clean up its own internal state, if any. There is no "export" notion in provider, as provider don't even have access to Exporters. Also wondering if we should even have Result with custom Error types for processor.shutdown(), exporter.shutdown() reader.shutdown() ? Or can be return just Result with just String, and do internal logging? These are anyway not invoked by user (user only invoke provider.shutdown()), so is there value in returning Result with custom Errors? |
||
|
||
/// An unexpected error occurred during shutdown. | ||
#[error(transparent)] | ||
Other(#[from] Box<dyn std::error::Error + Send + Sync + 'static>), | ||
} | ||
|
||
impl<T> From<PoisonError<T>> for ShutdownError { | ||
fn from(err: PoisonError<T>) -> Self { | ||
ShutdownError::ClientFailed(format!("Mutex poisoned during shutdown: {}", err)) | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.