pub trait FallbackHandler: Send + Sync {
// Required method
fn handle_failure(
&self,
failure: ExportFailure,
) -> Result<(), Box<dyn Error + Sync + Send>>;
}Expand description
Handler for export failures after all retry attempts have been exhausted.
Implementations should focus on preserving data (write to disk, queue, alternative endpoint) rather than attempting additional retries.
§Example
ⓘ
use opentelemetry_configuration::{FallbackHandler, ExportFailure};
struct S3FallbackHandler {
bucket: String,
client: aws_sdk_s3::Client,
}
impl FallbackHandler for S3FallbackHandler {
fn handle_failure(&self, failure: ExportFailure)
-> Result<(), Box<dyn std::error::Error + Send + Sync>>
{
let key = format!(
"failed-exports/{}/{}.pb",
failure.request.signal_type(),
failure.timestamp.duration_since(std::time::UNIX_EPOCH)?.as_millis()
);
// In a real implementation, you'd use async here
let bytes = failure.request.to_protobuf();
// self.client.put_object().bucket(&self.bucket).key(&key).body(bytes)...
Ok(())
}
}