Skip to content
Open
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: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ resolver = "2"
exclude = ["opentelemetry-prometheus"]

[profile.bench]
# https://doc.rust-lang.org/cargo/reference/profiles.html#bench
# https://nnethercote.github.io/perf-book/profiling.html
# See function names in profiling reports.
# 2/true is too much, 0 is not enough, 1 is just right for back traces
debug = 1
# 2/true is too much, 0 is not enough, line-tables-only is just right for back traces
debug = "line-tables-only"

[workspace.dependencies]
async-trait = "0.1"
Expand Down Expand Up @@ -84,6 +84,7 @@ tracing-log = "0.2"
tracing-opentelemetry = "0.31"
typed-builder = "0.20"
uuid = "1.3"
pprof = { version = "0.14", features = ["flamegraph", "criterion"] }

# Aviod use of crates.io version of these crates through the tracing-opentelemetry dependencies
[patch.crates-io]
Expand Down
3 changes: 2 additions & 1 deletion opentelemetry-appender-tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ criterion = { workspace = true }
tokio = { workspace = true, features = ["full"]}

[target.'cfg(not(target_os = "windows"))'.dev-dependencies]
pprof = { version = "0.14", features = ["flamegraph", "criterion"] }
pprof = { workspace = true }

[features]
default = []
experimental_metadata_attributes = ["dep:tracing-log"]
spec_unstable_logs_enabled = ["opentelemetry/spec_unstable_logs_enabled"]
experimental_use_tracing_span_context = ["tracing-opentelemetry"]
bench_profiling = []


[[bench]]
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-appender-tracing/benches/log-attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use opentelemetry_appender_tracing::layer as tracing_layer;
use opentelemetry_sdk::error::OTelSdkResult;
use opentelemetry_sdk::logs::{LogProcessor, SdkLogRecord, SdkLoggerProvider};
use opentelemetry_sdk::Resource;
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
use pprof::criterion::{Output, PProfProfiler};
use tracing::error;
use tracing_subscriber::prelude::*;
Expand Down Expand Up @@ -251,7 +251,7 @@ fn criterion_benchmark(c: &mut Criterion) {
// }
}

#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand All @@ -261,7 +261,7 @@ criterion_group! {
targets = criterion_benchmark
}

#[cfg(target_os = "windows")]
#[cfg(any(target_os = "windows", not(feature = "bench_profiling")))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand Down
7 changes: 4 additions & 3 deletions opentelemetry-appender-tracing/benches/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use opentelemetry_appender_tracing::layer as tracing_layer;
use opentelemetry_sdk::error::OTelSdkResult;
use opentelemetry_sdk::logs::{LogProcessor, SdkLogRecord, SdkLoggerProvider};
use opentelemetry_sdk::Resource;
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
use pprof::criterion::{Output, PProfProfiler};
use tracing::error;
use tracing_subscriber::prelude::*;
Expand Down Expand Up @@ -161,7 +161,7 @@ fn criterion_benchmark(c: &mut Criterion) {
benchmark_with_noop_layer(c, false, "noop_layer_disabled");
}

#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand All @@ -170,7 +170,8 @@ criterion_group! {
.with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets = criterion_benchmark
}
#[cfg(target_os = "windows")]

#[cfg(any(target_os = "windows", not(feature = "bench_profiling")))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand Down
3 changes: 2 additions & 1 deletion opentelemetry-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ rstest = { workspace = true }
temp-env = { workspace = true }

[target.'cfg(not(target_os = "windows"))'.dev-dependencies]
pprof = { version = "0.14", features = ["flamegraph", "criterion"] }
pprof = { workspace = true }

[features]
default = ["trace", "metrics", "logs", "internal-logs"]
Expand All @@ -57,6 +57,7 @@ experimental_logs_batch_log_processor_with_async_runtime = ["logs", "experimenta
experimental_logs_concurrent_log_processor = ["logs"]
experimental_trace_batch_span_processor_with_async_runtime = ["tokio/sync", "trace", "experimental_async_runtime"]
experimental_metrics_disable_name_validation = ["metrics"]
bench_profiling = []

[[bench]]
name = "context"
Expand Down
11 changes: 7 additions & 4 deletions opentelemetry-sdk/benches/context.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use opentelemetry::{
global::BoxedTracer,
trace::{
Expand All @@ -11,9 +11,10 @@ use opentelemetry_sdk::{
error::OTelSdkResult,
trace::{Sampler, SdkTracerProvider, SpanData, SpanExporter},
};
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
use pprof::criterion::{Output, PProfProfiler};
use std::fmt::Display;
use std::hint::black_box;

fn criterion_benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("context");
Expand Down Expand Up @@ -170,7 +171,7 @@ impl SpanExporter for NoopExporter {
}
}

#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand All @@ -179,12 +180,14 @@ criterion_group! {
.with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets = criterion_benchmark
}
#[cfg(target_os = "windows")]

#[cfg(any(target_os = "windows", not(feature = "bench_profiling")))]
criterion_group! {
name = benches;
config = Criterion::default()
.warm_up_time(std::time::Duration::from_secs(1))
.measurement_time(std::time::Duration::from_secs(2));
targets = criterion_benchmark
}

criterion_main!(benches);
2 changes: 1 addition & 1 deletion opentelemetry-sdk/benches/log_enabled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ where

c.bench_function(name, |b| {
b.iter(|| {
criterion::black_box(logger.event_enabled(
std::hint::black_box(logger.event_enabled(
opentelemetry::logs::Severity::Debug,
"target",
Some("name"),
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-sdk/benches/log_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use opentelemetry_sdk::logs::LogBatch;
use opentelemetry_sdk::logs::LogProcessor;
use opentelemetry_sdk::logs::SdkLogRecord;
use opentelemetry_sdk::logs::SdkLoggerProvider;
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
use pprof::criterion::{Output, PProfProfiler};
use std::fmt::Debug;

Expand Down Expand Up @@ -164,7 +164,7 @@ fn exporter_without_future(c: &mut Criterion) {
});
}

#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand All @@ -173,7 +173,7 @@ criterion_group! {
.with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets = criterion_benchmark
}
#[cfg(target_os = "windows")]
#[cfg(any(target_os = "windows", not(feature = "bench_profiling")))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-sdk/benches/metrics_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use opentelemetry::{
KeyValue,
};
use opentelemetry_sdk::metrics::{ManualReader, SdkMeterProvider};
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
use pprof::criterion::{Output, PProfProfiler};
use rand::{
rngs::{self},
Expand Down Expand Up @@ -239,7 +239,7 @@ fn random_generator(c: &mut Criterion) {
});
}

#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand All @@ -248,7 +248,7 @@ criterion_group! {
.with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets = criterion_benchmark
}
#[cfg(target_os = "windows")]
#[cfg(any(target_os = "windows", not(feature = "bench_profiling")))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-sdk/benches/metrics_histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use opentelemetry::{
KeyValue,
};
use opentelemetry_sdk::metrics::{ManualReader, SdkMeterProvider};
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
use pprof::criterion::{Output, PProfProfiler};
use rand::{
rngs::{self},
Expand Down Expand Up @@ -143,7 +143,7 @@ fn histogram_record_with_non_static_values(c: &mut Criterion, attribute_values:
});
}

#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand All @@ -152,7 +152,7 @@ criterion_group! {
.with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets = criterion_benchmark
}
#[cfg(target_os = "windows")]
#[cfg(any(target_os = "windows", not(feature = "bench_profiling")))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand Down
7 changes: 4 additions & 3 deletions opentelemetry-sdk/benches/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use opentelemetry_sdk::{
error::OTelSdkResult,
trace::{self as sdktrace, SpanData, SpanExporter},
};
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
use pprof::criterion::{Output, PProfProfiler};

fn criterion_benchmark(c: &mut Criterion) {
Expand Down Expand Up @@ -159,7 +159,7 @@ fn trace_benchmark_group<F: Fn(&sdktrace::SdkTracer)>(c: &mut Criterion, name: &
group.finish();
}

#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand All @@ -168,7 +168,8 @@ criterion_group! {
.with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets = criterion_benchmark
}
#[cfg(target_os = "windows")]

#[cfg(any(target_os = "windows", not(feature = "bench_profiling")))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-sdk/benches/span_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use opentelemetry_sdk::{
trace as sdktrace,
trace::{SpanData, SpanExporter},
};
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
use pprof::criterion::{Output, PProfProfiler};

fn criterion_benchmark(c: &mut Criterion) {
Expand Down Expand Up @@ -80,7 +80,7 @@ const MAP_KEYS: [&str; 64] = [
"key.56", "key.57", "key.58", "key.59", "key.60", "key.61", "key.62", "key.63", "key.64",
];

#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand All @@ -89,7 +89,7 @@ criterion_group! {
.with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets = criterion_benchmark
}
#[cfg(target_os = "windows")]
#[cfg(any(target_os = "windows", not(feature = "bench_profiling")))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-sdk/benches/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use opentelemetry_sdk::{
error::OTelSdkResult,
trace::{self as sdktrace, SpanData, SpanExporter},
};
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
use pprof::criterion::{Output, PProfProfiler};

fn criterion_benchmark(c: &mut Criterion) {
Expand Down Expand Up @@ -89,7 +89,7 @@ fn trace_benchmark_group<F: Fn(&sdktrace::SdkTracer)>(c: &mut Criterion, name: &
group.finish();
}

#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand All @@ -98,7 +98,7 @@ criterion_group! {
.with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets = criterion_benchmark
}
#[cfg(target_os = "windows")]
#[cfg(any(target_os = "windows", not(feature = "bench_profiling")))]
criterion_group! {
name = benches;
config = Criterion::default()
Expand Down
9 changes: 5 additions & 4 deletions opentelemetry-sdk/benches/tracer_creation.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use criterion::{criterion_group, criterion_main, Criterion};
use opentelemetry::{
global::{self, BoxedTracer},
InstrumentationScope, KeyValue,
};
use opentelemetry_sdk::trace as sdktrace;
use std::hint::black_box;
use std::sync::OnceLock;

#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
use pprof::criterion::{Output, PProfProfiler};

/*
Expand Down Expand Up @@ -83,7 +84,7 @@ fn criterion_benchmark(c: &mut Criterion) {
group.finish();
}

#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), feature = "bench_profiling"))]
criterion_group! {
name = benches;
config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)))
Expand All @@ -92,7 +93,7 @@ criterion_group! {
targets = criterion_benchmark
}

#[cfg(target_os = "windows")]
#[cfg(any(target_os = "windows", not(feature = "bench_profiling")))]
criterion_group! {
name = benches;
config = Criterion::default().warm_up_time(std::time::Duration::from_secs(1))
Expand Down
3 changes: 2 additions & 1 deletion opentelemetry/benches/anyvalue.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use criterion::{criterion_group, criterion_main, Criterion};
use opentelemetry::{logs::AnyValue, Value};
use std::hint::black_box;

// Run this benchmark with:
// cargo bench --bench anyvalue
Expand Down
3 changes: 2 additions & 1 deletion opentelemetry/benches/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ RAM: 64.0 GB
| CreateTupleKeyValueArray | 2.73 ns |
*/

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use criterion::{criterion_group, criterion_main, Criterion};
use opentelemetry::{Key, KeyValue};
use std::hint::black_box;
use std::sync::Arc;

// Run this benchmark with:
Expand Down
Loading
Loading