Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Move exemplars to separate module
  • Loading branch information
emschwartz committed May 25, 2023
commit 68cbe87bc2083f76877c94e85bb09bbf8c739179
12 changes: 12 additions & 0 deletions autometrics/src/exemplars/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//! Attach exemplars to the generated metrics (used for connecting metrics to traces)
//!
//! Autometrics integrates with tracing libraries to extract details from the
//! current span context and attach them as exemplars to the metrics it generates.
//!
//! See each of the submodules for details on how to integrate with each tracing library.
//!
//! **Note:** This is currently only supported with the `prometheus-client` metrics library,
//! because that is the only one that currently supports producing metrics with exemplars.

#[cfg(feature = "exemplars-tracing")]
pub mod tracing;
3 changes: 0 additions & 3 deletions autometrics/src/integrations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@
pub mod prometheus_client {
pub use crate::tracker::prometheus_client::REGISTRY;
}

#[cfg(feature = "exemplars-tracing")]
pub mod tracing;
2 changes: 2 additions & 0 deletions autometrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#![doc = include_str!("../README.md")]

mod constants;
#[cfg(feature = "exemplars-tracing")]
pub mod exemplars;
pub mod integrations;
mod labels;
pub mod objectives;
Expand Down
2 changes: 1 addition & 1 deletion autometrics/src/tracker/prometheus_client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::TrackMetrics;
#[cfg(feature = "exemplars-tracing")]
use crate::integrations::tracing::get_exemplar;
use crate::exemplars::tracing::get_exemplar;
use crate::labels::{BuildInfoLabels, CounterLabels, GaugeLabels, HistogramLabels};
use crate::{constants::*, HISTOGRAM_BUCKETS};
use once_cell::sync::Lazy;
Expand Down
2 changes: 1 addition & 1 deletion examples/tracing/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use autometrics::{
autometrics, encode_global_metrics, integrations::tracing::AutometricsExemplarExtractor,
autometrics, encode_global_metrics, exemplars::tracing::AutometricsExemplarExtractor,
};
use tracing::{instrument, trace};
use tracing_subscriber::{prelude::*, EnvFilter};
Expand Down