Skip to content

Commit 1742e99

Browse files
[query-engine] OTLP RecordSet bridge benchmarks (open-telemetry#2484)
# Changes * Adds some benchmarks to OTLP RecordSet bridge # Details I was measuring `toint(unknown)` vs `coalesce(toint(unknown), null)` for @drewrelmas and @utpilla just checking in the work so we can build up more benchmarks in the future (if needed). Modeled after what @albertlockett is doing in [query-engine](https://github.com/open-telemetry/otel-arrow/blob/main/rust/otap-dataflow/crates/query-engine/benches/filter.rs). --------- Co-authored-by: Drew Relmas <drewrelmas@gmail.com>
1 parent 79f1c89 commit 1742e99

3 files changed

Lines changed: 79 additions & 1 deletion

File tree

rust/experimental/query_engine/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ rust-version = "1.86.0"
2222
bytes = "1.10.1"
2323
caseless = "0.2.2"
2424
chrono = "0.4.41"
25+
criterion = "0.8.0"
2526
hex = "0.4.3"
2627
opentelemetry-proto = "0.31.0"
2728
pest = "2.8"

rust/experimental/query_engine/engine-recordset-otlp-bridge/Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,12 @@ data_engine_kql_parser = { path = "../kql-parser" }
2020
data_engine_recordset = { path = "../engine-recordset" }
2121

2222
[dev-dependencies]
23+
criterion = { workspace = true }
2324
opentelemetry-proto = { workspace = true }
24-
prost = { workspace = true }
25+
prost = { workspace = true }
26+
27+
otap-df-pdata = { path = "../../../otap-dataflow/crates/pdata", features = ["testing"] }
28+
29+
[[bench]]
30+
name = "extend"
31+
harness = false
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
5+
use data_engine_recordset_otlp_bridge::*;
6+
use otap_df_pdata::testing::fixtures::logs_with_varying_attributes_and_properties;
7+
use prost::Message;
8+
9+
fn generate_logs_batch(batch_size: usize) -> Vec<u8> {
10+
let logs_data = logs_with_varying_attributes_and_properties(batch_size);
11+
logs_data.encode_to_vec()
12+
}
13+
14+
fn bench_log_pipeline(
15+
c: &mut Criterion,
16+
batch_sizes: &[usize],
17+
bench_group_name: &str,
18+
bench_pipeline_kql: &str,
19+
) {
20+
let mut group = c.benchmark_group(bench_group_name);
21+
for batch_size in batch_sizes {
22+
let benchmark_id = BenchmarkId::new("batch_size", batch_size);
23+
let _ = group.bench_with_input(benchmark_id, batch_size, |b, batch_size| {
24+
let batch = generate_logs_batch(*batch_size);
25+
let pipeline = parse_kql_query_into_pipeline(bench_pipeline_kql, None)
26+
.expect("can parse pipeline");
27+
b.iter(|| {
28+
process_protobuf_otlp_export_logs_service_request_using_pipeline(
29+
&pipeline,
30+
RecordSetEngineDiagnosticLevel::Warn,
31+
&batch,
32+
)
33+
.expect("doesn't fail")
34+
});
35+
});
36+
}
37+
group.finish();
38+
}
39+
40+
fn bench_extend_pipelines(c: &mut Criterion) {
41+
let batch_sizes = [32, 1024, 8192];
42+
43+
// Note: toint() for an unknown field generates a warning
44+
bench_log_pipeline(
45+
c,
46+
&batch_sizes,
47+
"toint_unknown_field",
48+
"source | extend a = toint(unknown)",
49+
);
50+
51+
// Note: coalesce with inner toint() for an unknown field generates an info
52+
bench_log_pipeline(
53+
c,
54+
&batch_sizes,
55+
"coalesce_toint_unknown_field",
56+
"source | extend a = coalesce(toint(unknown), null)",
57+
);
58+
}
59+
60+
mod benches {
61+
use super::*;
62+
63+
criterion_group!(
64+
name = benches;
65+
config = Criterion::default();
66+
targets = bench_extend_pipelines
67+
);
68+
}
69+
70+
criterion_main!(benches::benches);

0 commit comments

Comments
 (0)