diff --git a/examples/logs-basic/src/main.rs b/examples/logs-basic/src/main.rs index 1bcf75a99d..86eb3873c3 100644 --- a/examples/logs-basic/src/main.rs +++ b/examples/logs-basic/src/main.rs @@ -13,7 +13,7 @@ fn main() { // Ok(serde_json::to_writer_pretty(writer, &data).unwrap())) .build(); let logger_provider = LoggerProvider::builder() - .with_resource(Resource::new(vec![KeyValue::new( + .with_resource(Resource::new([KeyValue::new( SERVICE_NAME, "logs-basic-example", )])) diff --git a/examples/metrics-advanced/src/main.rs b/examples/metrics-advanced/src/main.rs index b99fc8d4e4..aa5dbb6cac 100644 --- a/examples/metrics-advanced/src/main.rs +++ b/examples/metrics-advanced/src/main.rs @@ -52,7 +52,7 @@ fn init_meter_provider() -> opentelemetry_sdk::metrics::SdkMeterProvider { let reader = PeriodicReader::builder(exporter, runtime::Tokio).build(); let provider = SdkMeterProvider::builder() .with_reader(reader) - .with_resource(Resource::new(vec![KeyValue::new( + .with_resource(Resource::new([KeyValue::new( "service.name", "metrics-advanced-example", )])) diff --git a/examples/metrics-basic/src/main.rs b/examples/metrics-basic/src/main.rs index 996b16a008..ecd5083d7c 100644 --- a/examples/metrics-basic/src/main.rs +++ b/examples/metrics-basic/src/main.rs @@ -13,7 +13,7 @@ fn init_meter_provider() -> opentelemetry_sdk::metrics::SdkMeterProvider { let reader = PeriodicReader::builder(exporter, runtime::Tokio).build(); let provider = SdkMeterProvider::builder() .with_reader(reader) - .with_resource(Resource::new(vec![KeyValue::new( + .with_resource(Resource::new([KeyValue::new( "service.name", "metrics-basic-example", )])) diff --git a/opentelemetry-appender-tracing/Cargo.toml b/opentelemetry-appender-tracing/Cargo.toml index 7ce1834746..d104014662 100644 --- a/opentelemetry-appender-tracing/Cargo.toml +++ b/opentelemetry-appender-tracing/Cargo.toml @@ -27,6 +27,9 @@ tracing-log = "0.2" async-trait = { workspace = true } criterion = { workspace = true } +[target.'cfg(not(target_os = "windows"))'.dev-dependencies] +pprof = { version = "0.13", features = ["flamegraph", "criterion"] } + [features] experimental_metadata_attributes = ["dep:tracing-log"] logs_level_enabled = ["opentelemetry/logs_level_enabled"] diff --git a/opentelemetry-appender-tracing/benches/logs.rs b/opentelemetry-appender-tracing/benches/logs.rs index f7ef4d94ad..8fabcc7876 100644 --- a/opentelemetry-appender-tracing/benches/logs.rs +++ b/opentelemetry-appender-tracing/benches/logs.rs @@ -21,6 +21,7 @@ use opentelemetry_appender_tracing::layer as tracing_layer; use opentelemetry_sdk::export::logs::{LogData, LogExporter}; use opentelemetry_sdk::logs::{LogProcessor, LoggerProvider}; use opentelemetry_sdk::Resource; +use pprof::criterion::{Output, PProfProfiler}; use tracing::error; use tracing_subscriber::prelude::*; use tracing_subscriber::Layer; @@ -173,5 +174,16 @@ fn criterion_benchmark(c: &mut Criterion) { benchmark_with_noop_layer(c, false, "noop_layer_disabled"); } -criterion_group!(benches, criterion_benchmark); +#[cfg(not(target_os = "windows"))] +criterion_group! { + name = benches; + config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); + targets = criterion_benchmark +} +#[cfg(target_os = "windows")] +criterion_group! { + name = benches; + config = Criterion::default(); + targets = criterion_benchmark +} criterion_main!(benches); diff --git a/opentelemetry-sdk/benches/metric_counter.rs b/opentelemetry-sdk/benches/metric_counter.rs index b75a6eb351..a3dda396ca 100644 --- a/opentelemetry-sdk/benches/metric_counter.rs +++ b/opentelemetry-sdk/benches/metric_counter.rs @@ -18,6 +18,7 @@ use opentelemetry::{ KeyValue, }; use opentelemetry_sdk::metrics::{ManualReader, SdkMeterProvider}; +use pprof::criterion::{Output, PProfProfiler}; use rand::{ rngs::{self}, Rng, SeedableRng, @@ -155,6 +156,16 @@ fn counter_add(c: &mut Criterion) { }); } -criterion_group!(benches, criterion_benchmark); - +#[cfg(not(target_os = "windows"))] +criterion_group! { + name = benches; + config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); + targets = criterion_benchmark +} +#[cfg(target_os = "windows")] +criterion_group! { + name = benches; + config = Criterion::default(); + targets = criterion_benchmark +} criterion_main!(benches);