Skip to content

Commit

Permalink
opentelemetry: fix metrics docs using value. instead of histogram. (
Browse files Browse the repository at this point in the history
#2326)

## Motivation

This fixes a discrepancy in the `tracing-opentelemetry` docs for the new
MetricsLayer. The docs refer to `value.` as a way to collect discrete
data point, but this doesn't match any of the prefix constant mentioned
in the same file.

```rust
const METRIC_PREFIX_MONOTONIC_COUNTER: &str = "monotonic_counter.";
const METRIC_PREFIX_COUNTER: &str = "counter.";
const METRIC_PREFIX_HISTOGRAM: &str = "histogram.";
```

## Solution

This fixes the documentation and test by referring to `histogram.`
instead of `value.`.
  • Loading branch information
nmoutschen committed Sep 30, 2022
1 parent cf2b06f commit 1215ab2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions tracing-opentelemetry/src/metrics.rs
Expand Up @@ -263,7 +263,7 @@ impl<'a> Visit for MetricVisitor<'a> {
/// - `monotonic_counter.` (non-negative numbers): Used when the counter should
/// only ever increase
/// - `counter.`: Used when the counter can go up or down
/// - `value.`: Used for discrete data points (i.e., summing them does not make
/// - `histogram.`: Used for discrete data points (i.e., summing them does not make
/// semantic sense)
///
/// Examples:
Expand All @@ -276,9 +276,9 @@ impl<'a> Visit for MetricVisitor<'a> {
/// info!(counter.baz = -1);
/// info!(counter.xyz = 1.1);
///
/// info!(value.qux = 1);
/// info!(value.abc = -1);
/// info!(value.def = 1.1);
/// info!(histogram.qux = 1);
/// info!(histogram.abc = -1);
/// info!(histogram.def = 1.1);
/// ```
///
/// # Mixing data types
Expand Down
6 changes: 3 additions & 3 deletions tracing-opentelemetry/tests/metrics_publishing.rs
Expand Up @@ -129,7 +129,7 @@ async fn u64_histogram_is_exported() {
);

tracing::collect::with_default(subscriber, || {
tracing::info!(value.abcdefg = 9_u64);
tracing::info!(histogram.abcdefg = 9_u64);
});

exporter.export().unwrap();
Expand All @@ -145,7 +145,7 @@ async fn i64_histogram_is_exported() {
);

tracing::collect::with_default(subscriber, || {
tracing::info!(value.abcdefg_auenatsou = -19_i64);
tracing::info!(histogram.abcdefg_auenatsou = -19_i64);
});

exporter.export().unwrap();
Expand All @@ -161,7 +161,7 @@ async fn f64_histogram_is_exported() {
);

tracing::collect::with_default(subscriber, || {
tracing::info!(value.abcdefg_racecar = 777.0012_f64);
tracing::info!(histogram.abcdefg_racecar = 777.0012_f64);
});

exporter.export().unwrap();
Expand Down

0 comments on commit 1215ab2

Please sign in to comment.