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