Skip to content

Commit

Permalink
test: guard gauge(unstable) tests by feature. fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
biryukovmaxim committed Apr 30, 2024
1 parent cfa325b commit a8bb957
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions tests/metrics_publishing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,49 +115,55 @@ async fn f64_up_down_counter_is_exported() {
exporter.export().unwrap();
}

#[cfg(feature = "otel_unstable")]
#[tokio::test]
async fn u64_gauge_is_exported() {
let (subscriber, exporter) = init_subscriber(
"gygygy".to_string(),
InstrumentKind::Gauge,
1_u64,
2_u64,
None,
);

tracing::subscriber::with_default(subscriber, || {
tracing::info!(gauge.gygygy = 1_u64);
tracing::info!(gauge.gygygy = 2_u64);
});

exporter.export().unwrap();
}

#[cfg(feature = "otel_unstable")]
#[tokio::test]
async fn f64_gauge_is_exported() {
let (subscriber, exporter) = init_subscriber(
"huitt".to_string(),
InstrumentKind::Gauge,
1_f64,
2_f64,
None,
);

tracing::subscriber::with_default(subscriber, || {
tracing::info!(gauge.huitt = 1_f64);
tracing::info!(gauge.huitt = 2_f64);
});

exporter.export().unwrap();
}

#[cfg(feature = "otel_unstable")]
#[tokio::test]
async fn i64_gauge_is_exported() {
let (subscriber, exporter) = init_subscriber(
"samsagaz".to_string(),
InstrumentKind::Gauge,
1_i64,
2_i64,
None,
);

tracing::subscriber::with_default(subscriber, || {
tracing::info!(gauge.samsagaz = 1_i64);
tracing::info!(gauge.samsagaz = 2_i64);
});

exporter.export().unwrap();
Expand Down Expand Up @@ -323,11 +329,12 @@ async fn f64_up_down_counter_with_attributes_is_exported() {
exporter.export().unwrap();
}

#[cfg(feature = "otel_unstable")]
#[tokio::test]
async fn f64_gauge_with_attributes_is_exported() {
let (subscriber, exporter) = init_subscriber(
"hello_world".to_string(),
InstrumentKind::Counter,
InstrumentKind::Gauge,
1_f64,
Some(AttributeSet::from(
[
Expand Down Expand Up @@ -355,11 +362,12 @@ async fn f64_gauge_with_attributes_is_exported() {
exporter.export().unwrap();
}

#[cfg(feature = "otel_unstable")]
#[tokio::test]
async fn u64_gauge_with_attributes_is_exported() {
let (subscriber, exporter) = init_subscriber(
"hello_world".to_string(),
InstrumentKind::Counter,
InstrumentKind::Gauge,
1_u64,
Some(AttributeSet::from(
[
Expand Down Expand Up @@ -387,11 +395,12 @@ async fn u64_gauge_with_attributes_is_exported() {
exporter.export().unwrap();
}

#[cfg(feature = "otel_unstable")]
#[tokio::test]
async fn i64_gauge_with_attributes_is_exported() {
let (subscriber, exporter) = init_subscriber(
"hello_world".to_string(),
InstrumentKind::Counter,
InstrumentKind::Gauge,
1_i64,
Some(AttributeSet::from(
[
Expand Down Expand Up @@ -668,7 +677,7 @@ where
gauge.data_points
.iter()
.map(|data_point| data_point.value)
.sum()
.last().unwrap()
);

if let Some(expected_attributes) = self.expected_attributes.as_ref() {
Expand Down

0 comments on commit a8bb957

Please sign in to comment.