Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: produce measurement with attributes #43

Merged
merged 9 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from 8 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
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ once_cell = "1.13.0"
# Fix minimal-versions
async-trait = { version = "0.1.56", optional = true }
thiserror = { version = "1.0.31", optional = true }
smallvec = "1.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can this be option and enabled with the metrics feature?


[dev-dependencies]
async-trait = "0.1.56"
Expand All @@ -56,6 +57,10 @@ bench = false
name = "trace"
harness = false

[[bench]]
name = "metrics"
harness = false

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
162 changes: 162 additions & 0 deletions benches/metrics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
use criterion::{criterion_group, criterion_main, Criterion};
use opentelemetry::metrics::noop::NoopMeterProvider;
use tracing_opentelemetry::MetricsLayer;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

fn metrics_events(c: &mut Criterion) {
let mut group = c.benchmark_group("otel_metrics_events");
{
let _subscriber = tracing_subscriber::registry().set_default();
group.bench_function("no_metrics_layer", |b| {
b.iter(|| {
tracing::info!(key_1 = "va", "msg");
})
});
}

{
let _subscriber = tracing_subscriber::registry()
.with(MetricsLayer::new(NoopMeterProvider::new()))
.set_default();
group.bench_function("metrics_events_0_attr_0", |b| {
b.iter(|| {
tracing::info!(key_1 = "va", "msg");
})
});
}

{
let _subscriber = tracing_subscriber::registry()
.with(MetricsLayer::new(NoopMeterProvider::new()))
.set_default();
group.bench_function("metrics_events_1_attr_0", |b| {
b.iter(|| {
tracing::info!(monotonic_counter.c1 = 1, "msg");
})
});
}

{
let _subscriber = tracing_subscriber::registry()
.with(MetricsLayer::new(NoopMeterProvider::new()))
.set_default();
group.bench_function("metrics_events_2_attr_0", |b| {
b.iter(|| {
tracing::info!(monotonic_counter.c1 = 1, monotonic_counter.c2 = 1, "msg");
})
});
}

{
let _subscriber = tracing_subscriber::registry()
.with(MetricsLayer::new(NoopMeterProvider::new()))
.set_default();
group.bench_function("metrics_events_4_attr_0", |b| {
b.iter(|| {
tracing::info!(
monotonic_counter.c1 = 1,
monotonic_counter.c2 = 1,
monotonic_counter.c3 = 1,
monotonic_counter.c4 = 1,
"msg"
);
})
});
}

{
let _subscriber = tracing_subscriber::registry()
.with(MetricsLayer::new(NoopMeterProvider::new()))
.set_default();
group.bench_function("metrics_events_8_attr_0", |b| {
b.iter(|| {
tracing::info!(
monotonic_counter.c1 = 1,
monotonic_counter.c2 = 1,
monotonic_counter.c3 = 1,
monotonic_counter.c4 = 1,
monotonic_counter.c5 = 1,
monotonic_counter.c6 = 1,
monotonic_counter.c7 = 1,
monotonic_counter.c8 = 1,
"msg"
);
})
});
}

{
let _subscriber = tracing_subscriber::registry()
.with(MetricsLayer::new(NoopMeterProvider::new()))
.set_default();
group.bench_function("metrics_events_1_attr_1", |b| {
b.iter(|| {
tracing::info!(monotonic_counter.c1 = 1, key_1 = 1_i64, "msg");
})
});
}

{
let _subscriber = tracing_subscriber::registry()
.with(MetricsLayer::new(NoopMeterProvider::new()))
.set_default();
group.bench_function("metrics_events_1_attr_2", |b| {
b.iter(|| {
tracing::info!(
monotonic_counter.c1 = 1,
key_1 = 1_i64,
key_2 = 1_i64,
"msg"
);
})
});
}

{
let _subscriber = tracing_subscriber::registry()
.with(MetricsLayer::new(NoopMeterProvider::new()))
.set_default();
group.bench_function("metrics_events_1_attr_4", |b| {
b.iter(|| {
tracing::info!(
monotonic_counter.c1 = 1,
key_1 = 1_i64,
key_2 = 1_i64,
key_3 = 1_i64,
key_4 = 1_i64,
"msg"
);
})
});
}

{
let _subscriber = tracing_subscriber::registry()
.with(MetricsLayer::new(NoopMeterProvider::new()))
.set_default();
group.bench_function("metrics_events_1_attr_8", |b| {
b.iter(|| {
tracing::info!(
monotonic_counter.c1 = 1,
key_1 = 1_i64,
key_2 = 1_i64,
key_3 = 1_i64,
key_4 = 1_i64,
key_5 = 1_i64,
key_6 = 1_i64,
key_7 = 1_i64,
key_8 = 1_i64,
"msg"
);
})
});
}
group.finish();
}

criterion_group! {
name = benches;
config = Criterion::default();
targets = metrics_events
}
criterion_main!(benches);
Loading