Skip to content

Commit

Permalink
fix: use view instead
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 committed Apr 16, 2024
1 parent d95dc05 commit c63aaaa
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions crates/metrics/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
pub use {future::*, once_cell::sync::Lazy, opentelemetry as otel, task::*};
use {
custom_aggregation_selector::CustomAggregationSelector,
opentelemetry_sdk::metrics::SdkMeterProvider,
opentelemetry_sdk::metrics::{
new_view,
Aggregation,
Instrument,
InstrumentKind,
SdkMeterProvider,
Stream,
},
otel::metrics::{Meter, MeterProvider},
prometheus::{Error as PrometheusError, Registry, TextEncoder},
std::{
sync::{Arc, Mutex},
time::Duration,
},
};
pub use {future::*, once_cell::sync::Lazy, opentelemetry as otel, task::*};

pub mod custom_aggregation_selector;
pub mod future;
Expand All @@ -24,12 +30,27 @@ static METRICS_CORE: Lazy<Arc<ServiceMetrics>> = Lazy::new(|| {

let registry = Registry::new();
let prometheus_exporter = opentelemetry_prometheus::exporter()
.with_aggregation_selector(CustomAggregationSelector::new())
// .with_aggregation_selector(CustomAggregationSelector::new())
.with_registry(registry.clone())
.build()
.unwrap();
let provider = SdkMeterProvider::builder()
.with_reader(prometheus_exporter)
.with_view(
new_view(
{
let mut instrument = Instrument::new();
instrument.kind = Some(InstrumentKind::Histogram);
instrument
},
Stream::new().aggregation(Aggregation::Base2ExponentialHistogram {
max_size: 160,
max_scale: 20,
record_min_max: true,
}),
)
.unwrap(),
)
.build();
let meter = provider.meter(service_name);

Expand Down

0 comments on commit c63aaaa

Please sign in to comment.