Skip to content

Commit f8f57e3

Browse files
committed
Update Metrics API docs
1 parent 31bea19 commit f8f57e3

File tree

5 files changed

+46
-0
lines changed

5 files changed

+46
-0
lines changed

opentelemetry/src/metrics/instruments/counter.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use std::sync::Arc;
55
use super::SyncInstrument;
66

77
/// An instrument that records increasing values.
8+
///
9+
/// [`Counter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Counter`]s for the same instrument.
810
#[derive(Clone)]
911
#[non_exhaustive]
1012
pub struct Counter<T>(Arc<dyn SyncInstrument<T> + Send + Sync>);
@@ -31,6 +33,8 @@ impl<T> Counter<T> {
3133
}
3234

3335
/// An async instrument that records increasing values.
36+
///
37+
/// [`ObservableCounter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`ObservableCounter`]s for the same instrument.
3438
#[derive(Clone)]
3539
#[non_exhaustive]
3640
pub struct ObservableCounter<T> {

opentelemetry/src/metrics/instruments/gauge.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use std::sync::Arc;
55
use super::SyncInstrument;
66

77
/// An instrument that records independent values
8+
///
9+
/// [`Gauge`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Gauge`]s for the same instrument.
810
#[derive(Clone)]
911
#[non_exhaustive]
1012
pub struct Gauge<T>(Arc<dyn SyncInstrument<T> + Send + Sync>);
@@ -31,6 +33,8 @@ impl<T> Gauge<T> {
3133
}
3234

3335
/// An async instrument that records independent readings.
36+
///
37+
/// [`ObservableGauge`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`ObservableGauge`]s for the same instrument.
3438
#[derive(Clone)]
3539
#[non_exhaustive]
3640
pub struct ObservableGauge<T> {

opentelemetry/src/metrics/instruments/histogram.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use std::sync::Arc;
55
use super::SyncInstrument;
66

77
/// An instrument that records a distribution of values.
8+
///
9+
/// [`Histogram`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Histogram`]s for the same instrument.
810
#[derive(Clone)]
911
#[non_exhaustive]
1012
pub struct Histogram<T>(Arc<dyn SyncInstrument<T> + Send + Sync>);

opentelemetry/src/metrics/instruments/up_down_counter.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use std::sync::Arc;
55
use super::SyncInstrument;
66

77
/// An instrument that records increasing or decreasing values.
8+
///
9+
/// [`UpDownCounter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`UpDownCounter`]s for the same instrument.
810
#[derive(Clone)]
911
#[non_exhaustive]
1012
pub struct UpDownCounter<T>(Arc<dyn SyncInstrument<T> + Send + Sync>);
@@ -34,6 +36,8 @@ impl<T> UpDownCounter<T> {
3436
}
3537

3638
/// An async instrument that records increasing or decreasing values.
39+
///
40+
/// [`ObservableUpDownCounter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`ObservableUpDownCounter`]s for the same instrument.
3741
#[derive(Clone)]
3842
#[non_exhaustive]
3943
pub struct ObservableUpDownCounter<T> {

opentelemetry/src/metrics/meter.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ impl Meter {
309309
}
310310

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)