Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"datapoint",
"deque",
"Dirkjan",
"downcasting",
"EPYC",
"hasher",
"Isobel",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
//! Types for delivery of pre-aggregated metric time series data.
//! Interfaces for exporting metrics
use async_trait::async_trait;

use crate::metrics::{MetricResult, Temporality};
use crate::Resource;
use opentelemetry::{InstrumentationScope, KeyValue};
use std::{any, borrow::Cow, fmt, time::SystemTime};

use opentelemetry::{InstrumentationScope, KeyValue};
/// Exporter handles the delivery of metric data to external receivers.
///
/// This is the final component in the metric push pipeline.
#[async_trait]
pub trait PushMetricExporter: Send + Sync + 'static {
/// Export serializes and transmits metric data to a receiver.
///
/// All retry logic must be contained in this function. The SDK does not
/// implement any retry logic. All errors returned by this function are
/// considered unrecoverable and will be reported to a configured error
/// Handler.
async fn export(&self, metrics: &mut ResourceMetrics) -> MetricResult<()>;

use crate::Resource;
/// Flushes any metric data held by an exporter.
async fn force_flush(&self) -> MetricResult<()>;

/// Releases any held computational resources.
///
/// After Shutdown is called, calls to Export will perform no operation and
/// instead will return an error indicating the shutdown state.
fn shutdown(&self) -> MetricResult<()>;

use super::Temporality;
/// Access the [Temporality] of the MetricExporter.
fn temporality(&self) -> Temporality;
}

/// A collection of [ScopeMetrics] and the associated [Resource] that created them.
#[derive(Debug)]
Expand Down
4 changes: 4 additions & 0 deletions opentelemetry-sdk/src/export/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#[cfg_attr(docsrs, doc(cfg(feature = "logs")))]
pub mod logs;

#[cfg(feature = "metrics")]
#[cfg_attr(docsrs, doc(cfg(feature = "metrics")))]
pub mod metrics;

#[cfg(feature = "trace")]
#[cfg_attr(docsrs, doc(cfg(feature = "trace")))]
pub mod trace;
Expand Down
3 changes: 2 additions & 1 deletion opentelemetry-sdk/src/metrics/aggregation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,10 @@ impl Aggregation {
#[cfg(test)]
mod tests {
use crate::metrics::{
aggregation::Aggregation,
internal::{EXPO_MAX_SCALE, EXPO_MIN_SCALE},
Aggregation,
};

use crate::metrics::{MetricError, MetricResult};

#[test]
Expand Down
33 changes: 0 additions & 33 deletions opentelemetry-sdk/src/metrics/exporter.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1 @@
//! Interfaces for exporting metrics
use async_trait::async_trait;

use crate::metrics::MetricResult;

use crate::metrics::data::ResourceMetrics;

use super::Temporality;

/// Exporter handles the delivery of metric data to external receivers.
///
/// This is the final component in the metric push pipeline.
#[async_trait]
pub trait PushMetricExporter: Send + Sync + 'static {
/// Export serializes and transmits metric data to a receiver.
///
/// All retry logic must be contained in this function. The SDK does not
/// implement any retry logic. All errors returned by this function are
/// considered unrecoverable and will be reported to a configured error
/// Handler.
async fn export(&self, metrics: &mut ResourceMetrics) -> MetricResult<()>;

/// Flushes any metric data held by an exporter.
async fn force_flush(&self) -> MetricResult<()>;

/// Releases any held computational resources.
///
/// After Shutdown is called, calls to Export will perform no operation and
/// instead will return an error indicating the shutdown state.
fn shutdown(&self) -> MetricResult<()>;

/// Access the [Temporality] of the MetricExporter.
fn temporality(&self) -> Temporality;
}
5 changes: 3 additions & 2 deletions opentelemetry-sdk/src/metrics/internal/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use std::{

use opentelemetry::KeyValue;

use crate::metrics::{data::Aggregation, Temporality};
use crate::export::metrics::Aggregation;
use crate::metrics::Temporality;

use super::{
exponential_histogram::ExpoHistogram, histogram::Histogram, last_value::LastValue,
Expand Down Expand Up @@ -199,7 +200,7 @@ impl<T: Number> AggregateBuilder<T> {

#[cfg(test)]
mod tests {
use crate::metrics::data::{
use crate::export::metrics::{
ExponentialBucket, ExponentialHistogram, ExponentialHistogramDataPoint, Gauge,
GaugeDataPoint, Histogram, HistogramDataPoint, Sum, SumDataPoint,
};
Expand Down
Loading
Loading