Skip to content
Merged
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
4 changes: 4 additions & 0 deletions opentelemetry/src/metrics/instruments/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ use std::sync::Arc;
use super::SyncInstrument;

/// An instrument that records increasing values.
///
/// [`Counter`] can be cloned to create multiple handles to the same instrument. If a [`Counter`] needs to be shared,
/// users are recommended to clone the [`Counter`] instead of creating duplicate [`Counter`]s for the same metric. Creating
/// duplicate [`Counter`]s for the same metric could lower SDK performance.
#[derive(Clone)]
#[non_exhaustive]
pub struct Counter<T>(Arc<dyn SyncInstrument<T> + Send + Sync>);
Expand Down
4 changes: 4 additions & 0 deletions opentelemetry/src/metrics/instruments/gauge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ use std::sync::Arc;
use super::SyncInstrument;

/// An instrument that records independent values
///
/// [`Gauge`] can be cloned to create multiple handles to the same instrument. If a [`Gauge`] needs to be shared,
/// users are recommended to clone the [`Gauge`] instead of creating duplicate [`Gauge`]s for the same metric. Creating
/// duplicate [`Gauge`]s for the same metric could lower SDK performance.
#[derive(Clone)]
#[non_exhaustive]
pub struct Gauge<T>(Arc<dyn SyncInstrument<T> + Send + Sync>);
Expand Down
4 changes: 4 additions & 0 deletions opentelemetry/src/metrics/instruments/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ use std::sync::Arc;
use super::SyncInstrument;

/// An instrument that records a distribution of values.
///
/// [`Histogram`] can be cloned to create multiple handles to the same instrument. If a [`Histogram`] needs to be shared,
/// users are recommended to clone the [`Histogram`] instead of creating duplicate [`Histogram`]s for the same metric. Creating
/// duplicate [`Histogram`]s for the same metric could lower SDK performance.
#[derive(Clone)]
#[non_exhaustive]
pub struct Histogram<T>(Arc<dyn SyncInstrument<T> + Send + Sync>);
Expand Down
4 changes: 4 additions & 0 deletions opentelemetry/src/metrics/instruments/up_down_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ use std::sync::Arc;
use super::SyncInstrument;

/// An instrument that records increasing or decreasing values.
///
/// [`UpDownCounter`] can be cloned to create multiple handles to the same instrument. If a [`UpDownCounter`] needs to be shared,
/// users are recommended to clone the [`UpDownCounter`] instead of creating duplicate [`UpDownCounter`]s for the same metric. Creating
/// duplicate [`UpDownCounter`]s for the same metric could lower SDK performance.
#[derive(Clone)]
#[non_exhaustive]
pub struct UpDownCounter<T>(Arc<dyn SyncInstrument<T> + Send + Sync>);
Expand Down
39 changes: 39 additions & 0 deletions opentelemetry/src/metrics/meter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ impl Meter {
}

/// creates an instrument builder for recording increasing values.
///
/// [`Counter`] can be cloned to create multiple handles to the same instrument. If a [`Counter`] needs to be shared,
/// users are recommended to clone the [`Counter`] instead of creating duplicate [`Counter`]s for the same metric. Creating
/// duplicate [`Counter`]s for the same metric could lower SDK performance.
pub fn u64_counter(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -317,6 +321,10 @@ impl Meter {
}

/// creates an instrument builder for recording increasing values.
///
/// [`Counter`] can be cloned to create multiple handles to the same instrument. If a [`Counter`] needs to be shared,
/// users are recommended to clone the [`Counter`] instead of creating duplicate [`Counter`]s for the same metric. Creating
/// duplicate [`Counter`]s for the same metric could lower SDK performance.
pub fn f64_counter(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -341,6 +349,10 @@ impl Meter {
}

/// creates an instrument builder for recording changes of a value.
///
/// [`UpDownCounter`] can be cloned to create multiple handles to the same instrument. If a [`UpDownCounter`] needs to be shared,
/// users are recommended to clone the [`UpDownCounter`] instead of creating duplicate [`UpDownCounter`]s for the same metric. Creating
/// duplicate [`UpDownCounter`]s for the same metric could lower SDK performance.
pub fn i64_up_down_counter(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -349,6 +361,10 @@ impl Meter {
}

/// creates an instrument builder for recording changes of a value.
///
/// [`UpDownCounter`] can be cloned to create multiple handles to the same instrument. If a [`UpDownCounter`] needs to be shared,
/// users are recommended to clone the [`UpDownCounter`] instead of creating duplicate [`UpDownCounter`]s for the same metric. Creating
/// duplicate [`UpDownCounter`]s for the same metric could lower SDK performance.
pub fn f64_up_down_counter(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -357,6 +373,10 @@ impl Meter {
}

/// creates an instrument builder for recording changes of a value via callback.
///
/// [`UpDownCounter`] can be cloned to create multiple handles to the same instrument. If a [`UpDownCounter`] needs to be shared,
/// users are recommended to clone the [`UpDownCounter`] instead of creating duplicate [`UpDownCounter`]s for the same metric. Creating
/// duplicate [`UpDownCounter`]s for the same metric could lower SDK performance.
pub fn i64_observable_up_down_counter(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -373,6 +393,10 @@ impl Meter {
}

/// creates an instrument builder for recording independent values.
///
/// [`Gauge`] can be cloned to create multiple handles to the same instrument. If a [`Gauge`] needs to be shared,
/// users are recommended to clone the [`Gauge`] instead of creating duplicate [`Gauge`]s for the same metric. Creating
/// duplicate [`Gauge`]s for the same metric could lower SDK performance.
pub fn u64_gauge(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -381,6 +405,10 @@ impl Meter {
}

/// creates an instrument builder for recording independent values.
///
/// [`Gauge`] can be cloned to create multiple handles to the same instrument. If a [`Gauge`] needs to be shared,
/// users are recommended to clone the [`Gauge`] instead of creating duplicate [`Gauge`]s for the same metric. Creating
/// duplicate [`Gauge`]s for the same metric could lower SDK performance.
pub fn f64_gauge(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -389,6 +417,9 @@ impl Meter {
}

/// creates an instrument builder for recording independent values.
/// [`Gauge`] can be cloned to create multiple handles to the same instrument. If a [`Gauge`] needs to be shared,
/// users are recommended to clone the [`Gauge`] instead of creating duplicate [`Gauge`]s for the same metric. Creating
/// duplicate [`Gauge`]s for the same metric could lower SDK performance.
pub fn i64_gauge(
&self,
name: impl Into<Cow<'static, str>>,
Expand Down Expand Up @@ -421,6 +452,10 @@ impl Meter {
}

/// creates an instrument builder for recording a distribution of values.
///
/// [`Histogram`] can be cloned to create multiple handles to the same instrument. If a [`Histogram`] needs to be shared,
/// users are recommended to clone the [`Histogram`] instead of creating duplicate [`Histogram`]s for the same metric. Creating
/// duplicate [`Histogram`]s for the same metric could lower SDK performance.
pub fn f64_histogram(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -429,6 +464,10 @@ impl Meter {
}

/// creates an instrument builder for recording a distribution of values.
///
/// [`Histogram`] can be cloned to create multiple handles to the same instrument. If a [`Histogram`] needs to be shared,
/// users are recommended to clone the [`Histogram`] instead of creating duplicate [`Histogram`]s for the same metric. Creating
/// duplicate [`Histogram`]s for the same metric could lower SDK performance.
pub fn u64_histogram(
&self,
name: impl Into<Cow<'static, str>>,
Expand Down
Loading