Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions opentelemetry-appender-tracing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ when conversion is feasible. Otherwise stored as
`opentelemetry::logs::AnyValue::String`. This avoids unnecessary string
allocation when values can be represented in their original types.

- perf - small perf improvement by avoiding string allocation of `target`

## 0.28.1

Released 2025-Feb-12
Expand Down
4 changes: 2 additions & 2 deletions 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 | 167 ns |
| ot_layer_enabled | 155 ns |

Hardware: Apple M4 Pro
Total Number of Cores: 14 (10 performance and 4 efficiency)
Expand All @@ -20,7 +20,7 @@
| noop_layer_disabled | 8 ns |
| noop_layer_enabled | 14 ns |
| ot_layer_disabled | 12 ns |
| ot_layer_enabled | 186 ns |
| ot_layer_enabled | 130 ns |
*/

use criterion::{criterion_group, criterion_main, Criterion};
Expand Down
3 changes: 1 addition & 2 deletions opentelemetry-appender-tracing/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ where

let mut log_record = self.logger.create_log_record();

// TODO: Fix heap allocation
log_record.set_target(target.to_string());
log_record.set_target(target);
log_record.set_event_name(name);
log_record.set_severity_number(severity);
log_record.set_severity_text(metadata.level().as_str());
Expand Down
11 changes: 4 additions & 7 deletions opentelemetry-sdk/src/logs/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,11 @@ impl opentelemetry::logs::Logger for SdkLogger {

//let mut log_record = record;
if record.trace_context.is_none() {
let trace_context = Context::map_current(|cx| {
cx.has_active_span()
.then(|| TraceContext::from(cx.span().span_context()))
Context::map_current(|cx| {
cx.has_active_span().then(|| {
record.trace_context = Some(TraceContext::from(cx.span().span_context()))
})
});

if let Some(ref trace_context) = trace_context {
record.trace_context = Some(trace_context.clone());
}
}
if record.observed_timestamp.is_none() {
record.observed_timestamp = Some(now());
Expand Down
Loading