Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update code documentation for Metric instruments #2281

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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,8 @@ 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. Avoid creating duplicate [`Counter`]s for the same instrument.
utpilla marked this conversation as resolved.
Show resolved Hide resolved
#[derive(Clone)]
#[non_exhaustive]
pub struct Counter<T>(Arc<dyn SyncInstrument<T> + Send + Sync>);
Expand All @@ -31,6 +33,8 @@ impl<T> Counter<T> {
}

/// An async instrument that records increasing values.
///
/// [`ObservableCounter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`ObservableCounter`]s for the same instrument.
utpilla marked this conversation as resolved.
Show resolved Hide resolved
#[derive(Clone)]
#[non_exhaustive]
pub struct ObservableCounter<T> {
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,8 @@ 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. Avoid creating duplicate [`Gauge`]s for the same instrument.
#[derive(Clone)]
#[non_exhaustive]
pub struct Gauge<T>(Arc<dyn SyncInstrument<T> + Send + Sync>);
Expand All @@ -31,6 +33,8 @@ impl<T> Gauge<T> {
}

/// An async instrument that records independent readings.
///
/// [`ObservableGauge`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`ObservableGauge`]s for the same instrument.
#[derive(Clone)]
#[non_exhaustive]
pub struct ObservableGauge<T> {
Expand Down
2 changes: 2 additions & 0 deletions opentelemetry/src/metrics/instruments/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ 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. Avoid creating duplicate [`Histogram`]s for the same instrument.
#[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,8 @@ 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. Avoid creating duplicate [`UpDownCounter`]s for the same instrument.
#[derive(Clone)]
#[non_exhaustive]
pub struct UpDownCounter<T>(Arc<dyn SyncInstrument<T> + Send + Sync>);
Expand Down Expand Up @@ -34,6 +36,8 @@ impl<T> UpDownCounter<T> {
}

/// An async instrument that records increasing or decreasing values.
///
/// [`ObservableUpDownCounter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`ObservableUpDownCounter`]s for the same instrument.
#[derive(Clone)]
#[non_exhaustive]
pub struct ObservableUpDownCounter<T> {
Expand Down
32 changes: 32 additions & 0 deletions opentelemetry/src/metrics/meter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ impl Meter {
}

/// creates an instrument builder for recording increasing values.
///
/// [`Counter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Counter`]s for the same instrument.
pub fn u64_counter(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -317,6 +319,8 @@ impl Meter {
}

/// creates an instrument builder for recording increasing values.
///
/// [`Counter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Counter`]s for the same instrument.
pub fn f64_counter(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -325,6 +329,8 @@ impl Meter {
}

/// creates an instrument builder for recording increasing values via callback.
///
/// [`ObservableCounter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`ObservableCounter`]s for the same instrument.
pub fn u64_observable_counter(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -333,6 +339,8 @@ impl Meter {
}

/// creates an instrument builder for recording increasing values via callback.
///
/// [`ObservableCounter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`ObservableCounter`]s for the same instrument.
pub fn f64_observable_counter(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -341,6 +349,8 @@ impl Meter {
}

/// creates an instrument builder for recording changes of a value.
///
/// [`UpDownCounter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`UpDownCounter`]s for the same instrument.
pub fn i64_up_down_counter(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -349,6 +359,8 @@ impl Meter {
}

/// creates an instrument builder for recording changes of a value.
///
/// [`UpDownCounter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`UpDownCounter`]s for the same instrument.
pub fn f64_up_down_counter(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -357,6 +369,8 @@ impl Meter {
}

/// creates an instrument builder for recording changes of a value via callback.
///
/// [`ObservableUpDownCounter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`ObservableUpDownCounter`]s for the same instrument.
pub fn i64_observable_up_down_counter(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -365,6 +379,8 @@ impl Meter {
}

/// creates an instrument builder for recording changes of a value via callback.
///
/// [`ObservableUpDownCounter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`ObservableUpDownCounter`]s for the same instrument.
pub fn f64_observable_up_down_counter(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -373,6 +389,8 @@ impl Meter {
}

/// creates an instrument builder for recording independent values.
///
/// [`Gauge`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Gauge`]s for the same instrument.
pub fn u64_gauge(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -381,6 +399,8 @@ impl Meter {
}

/// creates an instrument builder for recording independent values.
///
/// [`Gauge`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Gauge`]s for the same instrument.
pub fn f64_gauge(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -389,6 +409,8 @@ impl Meter {
}

/// creates an instrument builder for recording independent values.
///
/// /// [`Gauge`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Gauge`]s for the same instrument.
pub fn i64_gauge(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -397,6 +419,8 @@ impl Meter {
}

/// creates an instrument builder for recording the current value via callback.
///
/// [`ObservableGauge`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`ObservableGauge`]s for the same instrument.
pub fn u64_observable_gauge(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -405,6 +429,8 @@ impl Meter {
}

/// creates an instrument builder for recording the current value via callback.
///
/// [`ObservableGauge`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`ObservableGauge`]s for the same instrument.
pub fn i64_observable_gauge(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -413,6 +439,8 @@ impl Meter {
}

/// creates an instrument builder for recording the current value via callback.
///
/// [`ObservableGauge`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`ObservableGauge`]s for the same instrument.
pub fn f64_observable_gauge(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -421,6 +449,8 @@ impl Meter {
}

/// creates an instrument builder for recording a distribution of values.
///
/// [`Histogram`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Histogram`]s for the same instrument.
pub fn f64_histogram(
&self,
name: impl Into<Cow<'static, str>>,
Expand All @@ -429,6 +459,8 @@ impl Meter {
}

/// creates an instrument builder for recording a distribution of values.
///
/// [`Histogram`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Histogram`]s for the same instrument.
pub fn u64_histogram(
&self,
name: impl Into<Cow<'static, str>>,
Expand Down
Loading