-
Notifications
You must be signed in to change notification settings - Fork 86
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
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c0357cb
feat: produce measurement with attributes
ymgyt 194d783
test: add attributes test case to metrics
ymgyt c365058
feat: use Filter trait
ymgyt 802809c
chore: add metrics bench
ymgyt 3cfc96f
fix: wrap with filter layer
ymgyt 3198cbf
Merge branch 'v0.1.x' into metrics-attributes
ymgyt 2c0dc3a
fix: remove methods that are incompatible with the minimal version
ymgyt c6b6a56
test: rename metrics benchmarks
ymgyt 9b49e54
chore: make smallvec optional
ymgyt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?