Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 12 additions & 10 deletions autometrics/src/prometheus_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -237,15 +233,21 @@ fn initialize_prometheus_exporter() -> Result<GlobalPrometheus, ExporterInitiali
.install_recorder()?,

#[cfg(opentelemetry)]
opentelemetry_exporter: exporter(
controllers::basic(processors::factory(
opentelemetry_exporter: {
use opentelemetry_sdk::export::metrics::aggregation;
use opentelemetry_sdk::metrics::{controllers, processors, selectors};

let controller = controllers::basic(processors::factory(
selectors::simple::histogram(
crate::settings::get_settings().histogram_buckets.clone(),
),
aggregation::cumulative_temporality_selector(),
))
.build(),
)
.try_init()?,
));

#[cfg(debug_assertions)]
let controller = controller.with_collect_period(std::time::Duration::ZERO);

exporter(controller.build()).try_init()?
},
})
}
2 changes: 0 additions & 2 deletions autometrics/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ fn single_function() {
hello_world();

let metrics = prometheus_exporter::encode_to_string().unwrap();
println!("{}", metrics);
assert!(metrics.lines().any(|line| {
(line.starts_with("function_calls_total{"))
&& line.contains(r#"function="hello_world""#)
Expand Down Expand Up @@ -163,7 +162,6 @@ fn caller_labels() {
module_1::function_1();

let metrics = prometheus_exporter::encode_to_string().unwrap();
println!("{}", metrics);
assert!(metrics.lines().any(|line| {
line.starts_with("function_calls_total{")
&& line.contains(r#"caller_function="function_1""#)
Expand Down