Skip to content

Commit f013b3d

Browse files
authored
test: Stress test for logs modified to show throughput when enabled()… (#2760)
1 parent a317856 commit f013b3d

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

opentelemetry-appender-tracing/benches/log-attributes.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,11 @@ fn create_benchmark(c: &mut Criterion, num_attributes: usize) {
248248
}
249249

250250
fn criterion_benchmark(c: &mut Criterion) {
251+
create_benchmark(c, 2);
251252
// Run benchmarks for 0 to 12 attributes
252-
for num_attributes in 0..=12 {
253-
create_benchmark(c, num_attributes);
254-
}
253+
// for num_attributes in 0..=12 {
254+
// create_benchmark(c, 2);
255+
// }
255256
}
256257

257258
#[cfg(not(target_os = "windows"))]

stress/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ lazy_static = { workspace = true }
4545
num_cpus = { workspace = true }
4646
opentelemetry = { path = "../opentelemetry", features = ["metrics", "logs", "trace", "spec_unstable_logs_enabled"] }
4747
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = ["metrics", "logs", "trace", "spec_unstable_logs_enabled"] }
48-
opentelemetry-appender-tracing = { workspace = true }
48+
opentelemetry-appender-tracing = { workspace = true, features = ["spec_unstable_logs_enabled"] }
4949
rand = { workspace = true, features = ["small_rng", "os_rng"] }
5050
tracing = { workspace = true, features = ["std"]}
5151
tracing-subscriber = { workspace = true, features = ["registry", "std"] }

stress/src/logs.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
88
Hardware: AMD EPYC 7763 64-Core Processor - 2.44 GHz, 16vCPUs,
99
~40 M /sec
10+
11+
Hardware: Apple M4 Pro
12+
Total Number of Cores: 14 (10 performance and 4 efficiency)
13+
~40 M/sec
14+
~1.1 B/sec (when disabled)
1015
*/
1116

1217
use opentelemetry::InstrumentationScope;
@@ -32,6 +37,7 @@ impl LogExporter for MockLogExporter {
3237
#[derive(Debug)]
3338
pub struct MockLogProcessor {
3439
exporter: MockLogExporter,
40+
enabled: bool,
3541
}
3642

3743
impl LogProcessor for MockLogProcessor {
@@ -51,13 +57,26 @@ impl LogProcessor for MockLogProcessor {
5157
fn shutdown(&self) -> OTelSdkResult {
5258
Ok(())
5359
}
60+
61+
fn event_enabled(
62+
&self,
63+
_level: opentelemetry::logs::Severity,
64+
_target: &str,
65+
_name: Option<&str>,
66+
) -> bool {
67+
self.enabled
68+
}
5469
}
5570

5671
fn main() {
72+
// change this to false to test the throughput when enabled is false.
73+
let enabled = true;
74+
5775
// LoggerProvider with a no-op processor.
5876
let provider: SdkLoggerProvider = SdkLoggerProvider::builder()
5977
.with_log_processor(MockLogProcessor {
6078
exporter: MockLogExporter {},
79+
enabled,
6180
})
6281
.build();
6382

0 commit comments

Comments
 (0)