Skip to content

Commit a1c56e6

Browse files
committed
Address PR comments
1 parent 685d254 commit a1c56e6

File tree

5 files changed

+43
-14
lines changed

5 files changed

+43
-14
lines changed

opentelemetry/src/metrics/instruments/counter.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use super::SyncInstrument;
66

77
/// An instrument that records increasing values.
88
///
9-
/// [`Counter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Counter`]s for the same instrument.
9+
/// [`Counter`] can be cloned to create multiple handles to the same instrument. If a [`Counter`] needs to be shared,
10+
/// users are recommended to clone the [`Counter`] instead of creating duplicate [`Counter`]s for the same metric. Creating
11+
/// duplicate [`Counter`]s for the same metric could lower SDK performance.
1012
#[derive(Clone)]
1113
#[non_exhaustive]
1214
pub struct Counter<T>(Arc<dyn SyncInstrument<T> + Send + Sync>);

opentelemetry/src/metrics/instruments/gauge.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use super::SyncInstrument;
66

77
/// An instrument that records independent values
88
///
9-
/// [`Gauge`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Gauge`]s for the same instrument.
9+
/// [`Gauge`] can be cloned to create multiple handles to the same instrument. If a [`Gauge`] needs to be shared,
10+
/// users are recommended to clone the [`Gauge`] instead of creating duplicate [`Gauge`]s for the same metric. Creating
11+
/// duplicate [`Gauge`]s for the same metric could lower SDK performance.
1012
#[derive(Clone)]
1113
#[non_exhaustive]
1214
pub struct Gauge<T>(Arc<dyn SyncInstrument<T> + Send + Sync>);

opentelemetry/src/metrics/instruments/histogram.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use super::SyncInstrument;
66

77
/// An instrument that records a distribution of values.
88
///
9-
/// [`Histogram`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Histogram`]s for the same instrument.
9+
/// [`Histogram`] can be cloned to create multiple handles to the same instrument. If a [`Histogram`] needs to be shared,
10+
/// users are recommended to clone the [`Histogram`] instead of creating duplicate [`Histogram`]s for the same metric. Creating
11+
/// duplicate [`Histogram`]s for the same metric could lower SDK performance.
1012
#[derive(Clone)]
1113
#[non_exhaustive]
1214
pub struct Histogram<T>(Arc<dyn SyncInstrument<T> + Send + Sync>);

opentelemetry/src/metrics/instruments/up_down_counter.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use super::SyncInstrument;
66

77
/// An instrument that records increasing or decreasing values.
88
///
9-
/// [`UpDownCounter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`UpDownCounter`]s for the same instrument.
9+
/// [`UpDownCounter`] can be cloned to create multiple handles to the same instrument. If a [`UpDownCounter`] needs to be shared,
10+
/// users are recommended to clone the [`UpDownCounter`] instead of creating duplicate [`UpDownCounter`]s for the same metric. Creating
11+
/// duplicate [`UpDownCounter`]s for the same metric could lower SDK performance.
1012
#[derive(Clone)]
1113
#[non_exhaustive]
1214
pub struct UpDownCounter<T>(Arc<dyn SyncInstrument<T> + Send + Sync>);

opentelemetry/src/metrics/meter.rs

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ impl Meter {
310310

311311
/// creates an instrument builder for recording increasing values.
312312
///
313-
/// [`Counter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Counter`]s for the same instrument.
313+
/// [`Counter`] can be cloned to create multiple handles to the same instrument. If a [`Counter`] needs to be shared,
314+
/// users are recommended to clone the [`Counter`] instead of creating duplicate [`Counter`]s for the same metric. Creating
315+
/// duplicate [`Counter`]s for the same metric could lower SDK performance.
314316
pub fn u64_counter(
315317
&self,
316318
name: impl Into<Cow<'static, str>>,
@@ -320,7 +322,9 @@ impl Meter {
320322

321323
/// creates an instrument builder for recording increasing values.
322324
///
323-
/// [`Counter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Counter`]s for the same instrument.
325+
/// [`Counter`] can be cloned to create multiple handles to the same instrument. If a [`Counter`] needs to be shared,
326+
/// users are recommended to clone the [`Counter`] instead of creating duplicate [`Counter`]s for the same metric. Creating
327+
/// duplicate [`Counter`]s for the same metric could lower SDK performance.
324328
pub fn f64_counter(
325329
&self,
326330
name: impl Into<Cow<'static, str>>,
@@ -346,7 +350,9 @@ impl Meter {
346350

347351
/// creates an instrument builder for recording changes of a value.
348352
///
349-
/// [`UpDownCounter`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`UpDownCounter`]s for the same instrument.
353+
/// [`UpDownCounter`] can be cloned to create multiple handles to the same instrument. If a [`UpDownCounter`] needs to be shared,
354+
/// users are recommended to clone the [`UpDownCounter`] instead of creating duplicate [`UpDownCounter`]s for the same metric. Creating
355+
/// duplicate [`UpDownCounter`]s for the same metric could lower SDK performance.
350356
pub fn i64_up_down_counter(
351357
&self,
352358
name: impl Into<Cow<'static, str>>,
@@ -356,7 +362,9 @@ impl Meter {
356362

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

367375
/// creates an instrument builder for recording changes of a value via callback.
376+
///
377+
/// [`UpDownCounter`] can be cloned to create multiple handles to the same instrument. If a [`UpDownCounter`] needs to be shared,
378+
/// users are recommended to clone the [`UpDownCounter`] instead of creating duplicate [`UpDownCounter`]s for the same metric. Creating
379+
/// duplicate [`UpDownCounter`]s for the same metric could lower SDK performance.
368380
pub fn i64_observable_up_down_counter(
369381
&self,
370382
name: impl Into<Cow<'static, str>>,
@@ -382,7 +394,9 @@ impl Meter {
382394

383395
/// creates an instrument builder for recording independent values.
384396
///
385-
/// [`Gauge`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Gauge`]s for the same instrument.
397+
/// [`Gauge`] can be cloned to create multiple handles to the same instrument. If a [`Gauge`] needs to be shared,
398+
/// users are recommended to clone the [`Gauge`] instead of creating duplicate [`Gauge`]s for the same metric. Creating
399+
/// duplicate [`Gauge`]s for the same metric could lower SDK performance.
386400
pub fn u64_gauge(
387401
&self,
388402
name: impl Into<Cow<'static, str>>,
@@ -392,7 +406,9 @@ impl Meter {
392406

393407
/// creates an instrument builder for recording independent values.
394408
///
395-
/// [`Gauge`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Gauge`]s for the same instrument.
409+
/// [`Gauge`] can be cloned to create multiple handles to the same instrument. If a [`Gauge`] needs to be shared,
410+
/// users are recommended to clone the [`Gauge`] instead of creating duplicate [`Gauge`]s for the same metric. Creating
411+
/// duplicate [`Gauge`]s for the same metric could lower SDK performance.
396412
pub fn f64_gauge(
397413
&self,
398414
name: impl Into<Cow<'static, str>>,
@@ -401,8 +417,9 @@ impl Meter {
401417
}
402418

403419
/// creates an instrument builder for recording independent values.
404-
///
405-
/// /// [`Gauge`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Gauge`]s for the same instrument.
420+
/// [`Gauge`] can be cloned to create multiple handles to the same instrument. If a [`Gauge`] needs to be shared,
421+
/// users are recommended to clone the [`Gauge`] instead of creating duplicate [`Gauge`]s for the same metric. Creating
422+
/// duplicate [`Gauge`]s for the same metric could lower SDK performance.
406423
pub fn i64_gauge(
407424
&self,
408425
name: impl Into<Cow<'static, str>>,
@@ -436,7 +453,9 @@ impl Meter {
436453

437454
/// creates an instrument builder for recording a distribution of values.
438455
///
439-
/// [`Histogram`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Histogram`]s for the same instrument.
456+
/// [`Histogram`] can be cloned to create multiple handles to the same instrument. If a [`Histogram`] needs to be shared,
457+
/// users are recommended to clone the [`Histogram`] instead of creating duplicate [`Histogram`]s for the same metric. Creating
458+
/// duplicate [`Histogram`]s for the same metric could lower SDK performance.
440459
pub fn f64_histogram(
441460
&self,
442461
name: impl Into<Cow<'static, str>>,
@@ -446,7 +465,9 @@ impl Meter {
446465

447466
/// creates an instrument builder for recording a distribution of values.
448467
///
449-
/// [`Histogram`] can be cloned to create multiple handles to the same instrument. Avoid creating duplicate [`Histogram`]s for the same instrument.
468+
/// [`Histogram`] can be cloned to create multiple handles to the same instrument. If a [`Histogram`] needs to be shared,
469+
/// users are recommended to clone the [`Histogram`] instead of creating duplicate [`Histogram`]s for the same metric. Creating
470+
/// duplicate [`Histogram`]s for the same metric could lower SDK performance.
450471
pub fn u64_histogram(
451472
&self,
452473
name: impl Into<Cow<'static, str>>,

0 commit comments

Comments
 (0)