Skip to content

Commit 0bb71d1

Browse files
committed
chore!: remove metrics feature gate
1 parent e43bb49 commit 0bb71d1

File tree

4 files changed

+5
-25
lines changed

4 files changed

+5
-25
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Unreleased
22

3+
### Removed
4+
5+
- Feature `metrics_gauge_unstable` since metrics gauge are stable in upstream now.
6+
37
# 0.31.0 (June 2, 2025)
48

59
### Breaking Changes

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ rust-version = "1.75.0"
1919
default = ["tracing-log", "metrics"]
2020
# Enables support for exporting OpenTelemetry metrics
2121
metrics = ["opentelemetry/metrics","opentelemetry_sdk/metrics", "smallvec"]
22-
# Enables experimental support for OpenTelemetry gauge metrics
23-
metrics_gauge_unstable = []
2422

2523
[dependencies]
2624
opentelemetry = { version = "0.30.0", default-features = false, features = ["trace"] }

src/metrics.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ use std::{collections::HashMap, fmt, sync::RwLock};
22
use tracing::{field::Visit, Subscriber};
33
use tracing_core::{Field, Interest, Metadata};
44

5-
#[cfg(feature = "metrics_gauge_unstable")]
6-
use opentelemetry::metrics::Gauge;
75
use opentelemetry::{
8-
metrics::{Counter, Histogram, Meter, MeterProvider, UpDownCounter},
6+
metrics::{Counter, Gauge, Histogram, Meter, MeterProvider, UpDownCounter},
97
InstrumentationScope, KeyValue, Value,
108
};
119
use tracing_subscriber::{
@@ -23,7 +21,6 @@ const INSTRUMENTATION_LIBRARY_NAME: &str = "tracing/tracing-opentelemetry";
2321
const METRIC_PREFIX_MONOTONIC_COUNTER: &str = "monotonic_counter.";
2422
const METRIC_PREFIX_COUNTER: &str = "counter.";
2523
const METRIC_PREFIX_HISTOGRAM: &str = "histogram.";
26-
#[cfg(feature = "metrics_gauge_unstable")]
2724
const METRIC_PREFIX_GAUGE: &str = "gauge.";
2825

2926
const I64_MAX: u64 = i64::MAX as u64;
@@ -36,11 +33,8 @@ pub(crate) struct Instruments {
3633
f64_up_down_counter: MetricsMap<UpDownCounter<f64>>,
3734
u64_histogram: MetricsMap<Histogram<u64>>,
3835
f64_histogram: MetricsMap<Histogram<f64>>,
39-
#[cfg(feature = "metrics_gauge_unstable")]
4036
u64_gauge: MetricsMap<Gauge<u64>>,
41-
#[cfg(feature = "metrics_gauge_unstable")]
4237
i64_gauge: MetricsMap<Gauge<i64>>,
43-
#[cfg(feature = "metrics_gauge_unstable")]
4438
f64_gauge: MetricsMap<Gauge<f64>>,
4539
}
4640

@@ -54,11 +48,8 @@ pub(crate) enum InstrumentType {
5448
UpDownCounterF64(f64),
5549
HistogramU64(u64),
5650
HistogramF64(f64),
57-
#[cfg(feature = "metrics_gauge_unstable")]
5851
GaugeU64(u64),
59-
#[cfg(feature = "metrics_gauge_unstable")]
6052
GaugeI64(i64),
61-
#[cfg(feature = "metrics_gauge_unstable")]
6253
GaugeF64(f64),
6354
}
6455

@@ -142,7 +133,6 @@ impl Instruments {
142133
|rec| rec.record(value, attributes),
143134
);
144135
}
145-
#[cfg(feature = "metrics_gauge_unstable")]
146136
InstrumentType::GaugeU64(value) => {
147137
update_or_insert(
148138
&self.u64_gauge,
@@ -151,7 +141,6 @@ impl Instruments {
151141
|rec| rec.record(value, attributes),
152142
);
153143
}
154-
#[cfg(feature = "metrics_gauge_unstable")]
155144
InstrumentType::GaugeI64(value) => {
156145
update_or_insert(
157146
&self.i64_gauge,
@@ -160,7 +149,6 @@ impl Instruments {
160149
|rec| rec.record(value, attributes),
161150
);
162151
}
163-
#[cfg(feature = "metrics_gauge_unstable")]
164152
InstrumentType::GaugeF64(value) => {
165153
update_or_insert(
166154
&self.f64_gauge,
@@ -185,7 +173,6 @@ impl Visit for MetricVisitor<'_> {
185173
}
186174

187175
fn record_u64(&mut self, field: &Field, value: u64) {
188-
#[cfg(feature = "metrics_gauge_unstable")]
189176
if let Some(metric_name) = field.name().strip_prefix(METRIC_PREFIX_GAUGE) {
190177
self.visited_metrics
191178
.push((metric_name, InstrumentType::GaugeU64(value)));
@@ -216,7 +203,6 @@ impl Visit for MetricVisitor<'_> {
216203
}
217204

218205
fn record_f64(&mut self, field: &Field, value: f64) {
219-
#[cfg(feature = "metrics_gauge_unstable")]
220206
if let Some(metric_name) = field.name().strip_prefix(METRIC_PREFIX_GAUGE) {
221207
self.visited_metrics
222208
.push((metric_name, InstrumentType::GaugeF64(value)));
@@ -238,7 +224,6 @@ impl Visit for MetricVisitor<'_> {
238224
}
239225

240226
fn record_i64(&mut self, field: &Field, value: i64) {
241-
#[cfg(feature = "metrics_gauge_unstable")]
242227
if let Some(metric_name) = field.name().strip_prefix(METRIC_PREFIX_GAUGE) {
243228
self.visited_metrics
244229
.push((metric_name, InstrumentType::GaugeI64(value)));
@@ -427,7 +412,6 @@ impl MetricsFilter {
427412
return true;
428413
}
429414

430-
#[cfg(feature = "metrics_gauge_unstable")]
431415
if name.starts_with(METRIC_PREFIX_GAUGE) {
432416
return true;
433417
}

tests/metrics_publishing.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ async fn f64_up_down_counter_is_exported() {
112112
exporter.export().unwrap();
113113
}
114114

115-
#[cfg(feature = "metrics_gauge_unstable")]
116115
#[tokio::test]
117116
async fn u64_gauge_is_exported() {
118117
let (subscriber, exporter) =
@@ -126,7 +125,6 @@ async fn u64_gauge_is_exported() {
126125
exporter.export().unwrap();
127126
}
128127

129-
#[cfg(feature = "metrics_gauge_unstable")]
130128
#[tokio::test]
131129
async fn f64_gauge_is_exported() {
132130
let (subscriber, exporter) =
@@ -140,7 +138,6 @@ async fn f64_gauge_is_exported() {
140138
exporter.export().unwrap();
141139
}
142140

143-
#[cfg(feature = "metrics_gauge_unstable")]
144141
#[tokio::test]
145142
async fn i64_gauge_is_exported() {
146143
let (subscriber, exporter) =
@@ -302,7 +299,6 @@ async fn f64_up_down_counter_with_attributes_is_exported() {
302299
exporter.export().unwrap();
303300
}
304301

305-
#[cfg(feature = "metrics_gauge_unstable")]
306302
#[tokio::test]
307303
async fn f64_gauge_with_attributes_is_exported() {
308304
let (subscriber, exporter) = init_subscriber(
@@ -332,7 +328,6 @@ async fn f64_gauge_with_attributes_is_exported() {
332328
exporter.export().unwrap();
333329
}
334330

335-
#[cfg(feature = "metrics_gauge_unstable")]
336331
#[tokio::test]
337332
async fn u64_gauge_with_attributes_is_exported() {
338333
let (subscriber, exporter) = init_subscriber(
@@ -362,7 +357,6 @@ async fn u64_gauge_with_attributes_is_exported() {
362357
exporter.export().unwrap();
363358
}
364359

365-
#[cfg(feature = "metrics_gauge_unstable")]
366360
#[tokio::test]
367361
async fn i64_gauge_with_attributes_is_exported() {
368362
let (subscriber, exporter) = init_subscriber(

0 commit comments

Comments
 (0)