File tree Expand file tree Collapse file tree 4 files changed +9
-11
lines changed
opentelemetry-appender-tracing
opentelemetry-sdk/src/logs Expand file tree Collapse file tree 4 files changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ when conversion is feasible. Otherwise stored as
47
47
` opentelemetry::logs::AnyValue::String ` . This avoids unnecessary string
48
48
allocation when values can be represented in their original types.
49
49
50
+ - perf - small perf improvement by avoiding string allocation of ` target `
51
+
50
52
## 0.28.1
51
53
52
54
Released 2025-Feb-12
Original file line number Diff line number Diff line change 10
10
| noop_layer_disabled | 12 ns |
11
11
| noop_layer_enabled | 25 ns |
12
12
| ot_layer_disabled | 19 ns |
13
- | ot_layer_enabled | 167 ns |
13
+ | ot_layer_enabled | 155 ns |
14
14
15
15
Hardware: Apple M4 Pro
16
16
Total Number of Cores: 14 (10 performance and 4 efficiency)
20
20
| noop_layer_disabled | 8 ns |
21
21
| noop_layer_enabled | 14 ns |
22
22
| ot_layer_disabled | 12 ns |
23
- | ot_layer_enabled | 186 ns |
23
+ | ot_layer_enabled | 130 ns |
24
24
*/
25
25
26
26
use criterion:: { criterion_group, criterion_main, Criterion } ;
Original file line number Diff line number Diff line change @@ -189,8 +189,7 @@ where
189
189
190
190
let mut log_record = self . logger . create_log_record ( ) ;
191
191
192
- // TODO: Fix heap allocation
193
- log_record. set_target ( target. to_string ( ) ) ;
192
+ log_record. set_target ( target) ;
194
193
log_record. set_event_name ( name) ;
195
194
log_record. set_severity_number ( severity) ;
196
195
log_record. set_severity_text ( metadata. level ( ) . as_str ( ) ) ;
Original file line number Diff line number Diff line change @@ -34,14 +34,11 @@ impl opentelemetry::logs::Logger for SdkLogger {
34
34
35
35
//let mut log_record = record;
36
36
if record. trace_context . is_none ( ) {
37
- let trace_context = Context :: map_current ( |cx| {
38
- cx. has_active_span ( )
39
- . then ( || TraceContext :: from ( cx. span ( ) . span_context ( ) ) )
37
+ Context :: map_current ( |cx| {
38
+ cx. has_active_span ( ) . then ( || {
39
+ record. trace_context = Some ( TraceContext :: from ( cx. span ( ) . span_context ( ) ) )
40
+ } )
40
41
} ) ;
41
-
42
- if let Some ( ref trace_context) = trace_context {
43
- record. trace_context = Some ( trace_context. clone ( ) ) ;
44
- }
45
42
}
46
43
if record. observed_timestamp . is_none ( ) {
47
44
record. observed_timestamp = Some ( now ( ) ) ;
You can’t perform that action at this time.
0 commit comments