From 1e8dbdbd86abf2da0afdaf235f17a9971e43eb89 Mon Sep 17 00:00:00 2001 From: Evan Schwartz <3262610+emschwartz@users.noreply.github.com> Date: Tue, 21 Mar 2023 12:31:14 +0100 Subject: [PATCH] Histogram buckets only used for specific features --- autometrics/src/lib.rs | 1 + autometrics/src/tracker/prometheus.rs | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/autometrics/src/lib.rs b/autometrics/src/lib.rs index 60b6417..fa567bb 100644 --- a/autometrics/src/lib.rs +++ b/autometrics/src/lib.rs @@ -21,6 +21,7 @@ pub use self::prometheus_exporter::*; /// We use the histogram buckets recommended by the OpenTelemetry specification /// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#explicit-bucket-histogram-aggregation +#[cfg(any(feature = "prometheus", feature = "prometheus-exporter"))] pub(crate) const HISTOGRAM_BUCKETS: [f64; 14] = [ 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1.0, 2.5, 5.0, 7.5, 10.0, ]; diff --git a/autometrics/src/tracker/prometheus.rs b/autometrics/src/tracker/prometheus.rs index dace5fc..4ecbb3f 100644 --- a/autometrics/src/tracker/prometheus.rs +++ b/autometrics/src/tracker/prometheus.rs @@ -1,6 +1,5 @@ use crate::labels::{CounterLabels, GaugeLabels, HistogramLabels}; -use crate::HISTOGRAM_BUCKETS; -use crate::{constants::*, tracker::TrackMetrics}; +use crate::{constants::*, tracker::TrackMetrics, HISTOGRAM_BUCKETS}; use const_format::{formatcp, str_replace}; use once_cell::sync::Lazy; use prometheus::histogram_opts;