diff --git a/opentelemetry/benches/attributes.rs b/opentelemetry/benches/attributes.rs index 081af06c36..42492f70cc 100644 --- a/opentelemetry/benches/attributes.rs +++ b/opentelemetry/benches/attributes.rs @@ -40,6 +40,24 @@ fn attributes_creation(c: &mut Criterion) { }); }); + c.bench_function("ProvideKeyValueUsingGenericMethod", |b| { + b.iter(|| { + let _v1 = black_box(no_op("attribute1", "value1")); + }); + }); + + #[allow(clippy::useless_vec)] + c.bench_function("ProvideMultipleKeyValuesUsingGenericMethod", |b| { + b.iter(|| { + let _v1 = black_box(vec![ + no_op("attribute1", "value1"), + no_op("attribute2", "value2"), + no_op("attribute3", "value3"), + no_op("attribute4", "value4"), + ]); + }); + }); + #[allow(clippy::useless_vec)] c.bench_function("CreateOtelKeyValueVector", |b| { b.iter(|| { @@ -65,6 +83,17 @@ fn attributes_creation(c: &mut Criterion) { }); } + +trait OTelValueType {} + +impl OTelValueType for u32 {} + +impl OTelValueType for &str {} + +fn no_op(key: &'static str, value: T) { + black_box("test"); +} + criterion_group!(benches, criterion_benchmark); criterion_main!(benches);