Skip to content

Commit

Permalink
Merge branch 'utpilla/Update-metrics-bechmarks' of https://github.com…
Browse files Browse the repository at this point in the history
…/utpilla/opentelemetry-rust into utpilla/Update-metrics-bechmarks
  • Loading branch information
utpilla committed Jul 3, 2024
2 parents 09a6bea + 99d8683 commit d80580e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion opentelemetry-appender-tracing/benches/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
| noop_layer_disabled | 12 ns |
| noop_layer_enabled | 25 ns |
| ot_layer_disabled | 19 ns |
| ot_layer_enabled | 371 ns |
| ot_layer_enabled | 305 ns |
*/

use async_trait::async_trait;
Expand Down
7 changes: 6 additions & 1 deletion opentelemetry-sdk/src/logs/log_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub struct LoggerProvider {

/// Default logger name if empty string is provided.
const DEFAULT_COMPONENT_NAME: &str = "rust.opentelemetry.io/sdk/logger";
const PREALLOCATED_ATTRIBUTE_CAPACITY: usize = 8;

impl opentelemetry::logs::LoggerProvider for LoggerProvider {
type Logger = Logger;
Expand Down Expand Up @@ -246,7 +247,11 @@ impl opentelemetry::logs::Logger for Logger {
type LogRecord = LogRecord;

fn create_log_record(&self) -> Self::LogRecord {
LogRecord::default()
// Reserve attributes memory for perf optimization. This may change in future.
LogRecord {
attributes: Some(Vec::with_capacity(PREALLOCATED_ATTRIBUTE_CAPACITY)),
..Default::default()
}
}

/// Emit a `LogRecord`.
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry/benches/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn counter_add(c: &mut Criterion) {
c.bench_function("AddWithDynamicAttributes", |b| {
b.iter_batched(
|| {
let value1 = "value1".to_string(); // Repeat character six times to match the length of value strings used in other benchmarks
let value1 = "value1".to_string();
let value2 = "value2".to_string();
let value3 = "value3".to_string();
let value4 = "value4".to_string();
Expand Down
2 changes: 1 addition & 1 deletion stress/src/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
OS: Ubuntu 22.04.3 LTS (5.15.146.1-microsoft-standard-WSL2)
Hardware: AMD EPYC 7763 64-Core Processor - 2.44 GHz, 16vCPUs,
RAM: 64.0 GB
53 M/sec
69 M/sec
*/

use opentelemetry_appender_tracing::layer;
Expand Down

0 comments on commit d80580e

Please sign in to comment.