opentelemetry_sdk/metrics/exporter.rs
1//! Interfaces for exporting metrics
2use async_trait::async_trait;
3
4use opentelemetry::metrics::Result;
5
6use crate::metrics::{
7 data::ResourceMetrics,
8 reader::{AggregationSelector, TemporalitySelector},
9};
10
11/// Exporter handles the delivery of metric data to external receivers.
12///
13/// This is the final component in the metric push pipeline.
14#[async_trait]
15pub trait PushMetricsExporter:
16 AggregationSelector + TemporalitySelector + Send + Sync + 'static
17{
18 /// Export serializes and transmits metric data to a receiver.
19 ///
20 /// All retry logic must be contained in this function. The SDK does not
21 /// implement any retry logic. All errors returned by this function are
22 /// considered unrecoverable and will be reported to a configured error
23 /// Handler.
24 async fn export(&self, metrics: &mut ResourceMetrics) -> Result<()>;
25
26 /// Flushes any metric data held by an exporter.
27 async fn force_flush(&self) -> Result<()>;
28
29 /// Releases any held computational resources.
30 ///
31 /// After Shutdown is called, calls to Export will perform no operation and
32 /// instead will return an error indicating the shutdown state.
33 fn shutdown(&self) -> Result<()>;
34}