use futures::stream::Stream;
use futures::StreamExt;
use opentelemetry::sdk::metrics::{selectors, PushController};
use opentelemetry_otlp::{ExportConfig, WithExportConfig};
use std::time::Duration;
fn delayed_interval(duration: Duration) -> impl Stream<Item = tokio::time::Instant> {
opentelemetry::util::tokio_interval_stream(duration).skip(1)
}
pub fn init_meter() -> PushController {
let export_config = ExportConfig::default();
opentelemetry_otlp::new_pipeline()
.metrics(tokio::spawn, delayed_interval)
.with_exporter(
opentelemetry_otlp::new_exporter()
.tonic()
.with_export_config(export_config),
)
.with_aggregator_selector(selectors::simple::Selector::Exact)
.build()
.unwrap()
}