From 70b99acf71e63ded157e1291894dcece79497b55 Mon Sep 17 00:00:00 2001 From: Evan Schwartz <3262610+emschwartz@users.noreply.github.com> Date: Thu, 27 Jul 2023 13:37:37 +0200 Subject: [PATCH 1/2] Fix OpenTelemetry tests --- .github/workflows/ci.yml | 7 +++---- autometrics/src/prometheus_exporter.rs | 22 ++++++++++++---------- autometrics/src/tracker/opentelemetry.rs | 1 + autometrics/tests/integration_test.rs | 2 -- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d57f943..be355057 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,11 +30,10 @@ jobs: - run: cargo test --features=prometheus-exporter,prometheus-0_13 - run: cargo test --features=prometheus-exporter,prometheus-client-0_21,exemplars-tracing - run: cargo test --features=prometheus-exporter,prometheus-client-0_21,exemplars-tracing-opentelemetry - # The tests using opentelemetry are currently failing because of this issue: + # The tests using opentelemetry need to be run with only one thread because of # https://github.com/open-telemetry/opentelemetry-rust/issues/1070 - # We should remove the continue-on-error once that is fixed - - run: cargo test --features=prometheus-exporter,opentelemetry-0_19 - continue-on-error: true + # We should remove the test-threads setting once that is fixed + - run: cargo test --features=prometheus-exporter,opentelemetry-0_19 -- --test-threads=1 # Build the crate using the other optional features - run: cargo build --features=metrics-0_21,custom-objective-percentile,custom-objective-latency diff --git a/autometrics/src/prometheus_exporter.rs b/autometrics/src/prometheus_exporter.rs index af6e2d8c..2a2e1bf1 100644 --- a/autometrics/src/prometheus_exporter.rs +++ b/autometrics/src/prometheus_exporter.rs @@ -29,10 +29,6 @@ use once_cell::sync::OnceCell; use opentelemetry_api::metrics::MetricsError; #[cfg(opentelemetry)] use opentelemetry_prometheus::{exporter, PrometheusExporter}; -#[cfg(opentelemetry)] -use opentelemetry_sdk::export::metrics::aggregation; -#[cfg(opentelemetry)] -use opentelemetry_sdk::metrics::{controllers, processors, selectors}; #[cfg(any(opentelemetry, prometheus))] use prometheus::TextEncoder; use thiserror::Error; @@ -237,15 +233,21 @@ fn initialize_prometheus_exporter() -> Result Date: Thu, 27 Jul 2023 13:38:18 +0200 Subject: [PATCH 2/2] Remove print statement --- autometrics/src/tracker/opentelemetry.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/autometrics/src/tracker/opentelemetry.rs b/autometrics/src/tracker/opentelemetry.rs index 89a099d6..b90a32b0 100644 --- a/autometrics/src/tracker/opentelemetry.rs +++ b/autometrics/src/tracker/opentelemetry.rs @@ -59,7 +59,6 @@ impl TrackMetrics for OpenTelemetryTracker { let duration = self.start.elapsed().as_secs_f64(); // Track the function calls - println!("incrementing counter"); let counter_labels = to_key_values(counter_labels.to_vec()); COUNTER.add(&self.context, 1, &counter_labels);