|
| 1 | +//! Run this stress test using `cargo run --bin etw --release -- <num-of-threads>`. |
| 2 | +//! |
| 3 | +// Conf - AMD EPYC 7763 64-Core Processor 2.44 GHz, 64GB RAM, Cores:8 , Logical processors: 16 |
| 4 | +// Stress Test Results (no listener) |
| 5 | +// Threads: 1 - Average Throughput: 52M iterations/sec |
| 6 | +// Threads: 5 - Average Throughput: 250M iterations/sec |
| 7 | +// Threads: 10 - Average Throughput: 320M iterations/sec |
| 8 | +// Threads: 16 - Average Throughput: 400M iterations/sec |
| 9 | + |
| 10 | +// Stress Test Results (logman is listening) |
| 11 | +// Threads: 1 - Average Throughput: 600K iterations/sec |
| 12 | +// Threads: 5 - Average Throughput: 2.7M iterations/sec |
| 13 | +// Threads: 10 - Average Throughput: 4.1M iterations/sec |
| 14 | +// Threads: 16 - Average Throughput: 5M iterations/sec |
| 15 | +// $EtwSessionGuid = (new-object System.Diagnostics.Tracing.EventSource("my-provider-name")).Guid.ToString()` |
| 16 | +// logman create trace OtelETWExampleBasic -o OtelETWExampleBasic.log -p "{$EtwSessionGuid}" -f bincirc -max 1000 |
| 17 | +// logman start OtelETWExampleBasic |
| 18 | +// RUN test here... |
| 19 | +// logman stop OtelETWExampleBasic |
| 20 | + |
| 21 | +use opentelemetry_appender_tracing::layer; |
| 22 | +use opentelemetry_etw_logs::{ExporterConfig, ReentrantLogProcessor}; |
| 23 | +use opentelemetry_sdk::logs::LoggerProvider; |
| 24 | +use std::collections::HashMap; |
| 25 | +use tracing::info; |
| 26 | +use tracing_subscriber::prelude::*; |
| 27 | +mod throughput; |
| 28 | + |
| 29 | +// Function to initialize the logger |
| 30 | +fn init_logger() -> LoggerProvider { |
| 31 | + let exporter_config = ExporterConfig { |
| 32 | + default_keyword: 1, |
| 33 | + keywords_map: HashMap::new(), |
| 34 | + }; |
| 35 | + let reenterant_processor = ReentrantLogProcessor::new( |
| 36 | + "my-provider-name", |
| 37 | + "my-event-name".into(), |
| 38 | + None, |
| 39 | + exporter_config, |
| 40 | + ); |
| 41 | + LoggerProvider::builder() |
| 42 | + .with_log_processor(reenterant_processor) |
| 43 | + .build() |
| 44 | +} |
| 45 | + |
| 46 | +// Function that performs the logging task |
| 47 | +fn log_event_task() { |
| 48 | + info!( |
| 49 | + name = "my-event-name", |
| 50 | + event_id = 20, |
| 51 | + user_name = "otel user", |
| 52 | + |
| 53 | + ); |
| 54 | +} |
| 55 | + |
| 56 | +fn main() { |
| 57 | + let logger_provider = init_logger(); |
| 58 | + let layer = layer::OpenTelemetryTracingBridge::new(&logger_provider); |
| 59 | + tracing_subscriber::registry().with(layer).init(); |
| 60 | + |
| 61 | + throughput::test_throughput(|| { |
| 62 | + log_event_task(); |
| 63 | + }); |
| 64 | + |
| 65 | + println!("Stress test completed."); |
| 66 | +} |
0 commit comments