FallbackHandler

Trait FallbackHandler 

Source
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(())
    }
}

Required Methods§

Source

fn handle_failure( &self, failure: ExportFailure, ) -> Result<(), Box<dyn Error + Sync + Send>>

Handle a failed export.

§Arguments
  • failure - Details of the failed export including the original OTLP request
§Returns

Returns Ok(()) if the fallback successfully handled the failure, or an error if the fallback itself failed. Errors are logged but otherwise ignored.

Implementors§