Skip to content

Commit

Permalink
Add stress test for user-events logs exporter (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored Dec 17, 2024
1 parent c27ebcc commit 30a3f4e
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
13 changes: 12 additions & 1 deletion stress/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ version = "0.1.0"
edition = "2021"
publish = false

[[bin]] # Bin to run the metrics stress tests for Logs UserEvent Exporter
[[bin]]
name = "eventheader"
path = "src/eventheader.rs"
doc = false

[[bin]]
name = "user_events"
path = "src/user_events.rs"
doc = false

[dependencies]
ctrlc = "3.2.5"
lazy_static = "1.4.0"
Expand All @@ -17,6 +22,12 @@ num-format = "0.4.4"
sysinfo = { version = "0.32", optional = true }
eventheader_dynamic = "0.4.0"

opentelemetry-appender-tracing = { workspace = true, features= ["spec_unstable_logs_enabled"] }
opentelemetry_sdk = { workspace = true, features = ["logs", "spec_unstable_logs_enabled"] }
opentelemetry-user-events-logs = { path = "../opentelemetry-user-events-logs", features = ["spec_unstable_logs_enabled"]}
tracing = { version = "0.1", default-features = false, features = ["std"] }
tracing-subscriber = { version = "0.3.0", default-features = false, features = ["registry", "std"] }

[features]
stats = ["sysinfo"]

Expand Down
68 changes: 68 additions & 0 deletions stress/src/user_events.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//! Run this stress test using `$ sudo -E ~/.cargo/bin/cargo run --bin user_events --release -- <num-of-threads>`.
//!
//! IMPORTANT:
//! To test with `user_events` enabled, perform the following step before running the test:
//! - Add `1` to `/sys/kernel/debug/tracing/events/user_events/testprovider_L4K1Gtestprovider/enable`:
//! `echo 1 > /sys/kernel/debug/tracing/events/user_events/testprovider_L4K1Gtestprovider/enable`
//! To test with `user_events` disabled, perform the following step:
//! - Add `0` to `/sys/kernel/debug/tracing/events/user_events/testprovider_L4K1Gtestprovider/enable`:
//! `echo 0 > /sys/kernel/debug/tracing/events/user_events/testprovider_L4K1Gtestprovider/enable`
//!
//!
// Conf - AMD EPYC 7763 64-Core Processor 2.44 GHz, 64GB RAM, Cores:8 , Logical processors: 16
// Stress Test Results (user_events disabled)
// Threads: 1 - Average Throughput: 30,866,752 iterations/sec
// Threads: 5 - Average Throughput: 32,662,641 iterations/sec
// Threads: 10 - Average Throughput: 25,776,394 iterations/sec
// Threads: 16 - Average Throughput: 16,915,860 iterations/sec

// Stress Test Results (user_events enabled)
// Threads: 1 - Average Throughput: 212,594 iterations/sec
// Threads: 5 - Average Throughput: 372,695 iterations/sec
// Threads: 10 - Average Throughput: 277,675 iterations/sec
// Threads: 16 - Average Throughput: 268,940 iterations/sec

use opentelemetry_appender_tracing::layer;
use opentelemetry_sdk::logs::LoggerProvider;
use opentelemetry_user_events_logs::{ExporterConfig, ReentrantLogProcessor, UserEventsExporter};
use std::collections::HashMap;
use tracing::info;
use tracing_subscriber::prelude::*;
mod throughput;

// Function to initialize the logger
fn init_logger() -> LoggerProvider {
let exporter_config = ExporterConfig {
default_keyword: 1,
keywords_map: HashMap::new(),
};
let exporter = UserEventsExporter::new("testprovider", None, exporter_config);
let reentrant_processor = ReentrantLogProcessor::new(exporter);
LoggerProvider::builder()
.with_log_processor(reentrant_processor)
.build()
}

// Function that performs the logging task
fn log_event_task() {
info!(
name = "my-event-name",
event_id = 20,
user_name = "otel user",
user_email = "[email protected]"
);
}

fn main() {
// Initialize the logger
let logger_provider = init_logger();
let layer = layer::OpenTelemetryTracingBridge::new(&logger_provider);
tracing_subscriber::registry().with(layer).init();

// Use the provided stress test framework
println!("Starting stress test for UserEventsExporter...");
throughput::test_throughput(|| {
log_event_task();
});
println!("Stress test completed.");
}

0 comments on commit 30a3f4e

Please sign in to comment.