File tree Expand file tree Collapse file tree 1 file changed +14
-16
lines changed
opentelemetry-appender-tracing/src Expand file tree Collapse file tree 1 file changed +14
-16
lines changed Original file line number Diff line number Diff line change @@ -247,28 +247,26 @@ where
247
247
#[ cfg( feature = "experimental_use_tracing_span_context" ) ]
248
248
if let Some ( span) = _ctx. event_span ( event) {
249
249
use tracing_opentelemetry:: OtelData ;
250
- let opt_span_id = span
251
- . extensions ( )
252
- . get :: < OtelData > ( )
253
- . and_then ( |otd| otd. builder . span_id ) ;
254
-
255
- let opt_trace_id = span. scope ( ) . last ( ) . and_then ( |root_span| {
256
- root_span
257
- . extensions ( )
258
- . get :: < OtelData > ( )
259
- . and_then ( |otd| otd. builder . trace_id )
260
- } ) ;
261
-
262
- if let Some ( ( trace_id, span_id) ) = opt_trace_id. zip ( opt_span_id) {
263
- log_record. set_trace_context ( trace_id, span_id, None ) ;
264
- }
265
-
266
250
if let Some ( otd) = span. extensions ( ) . get :: < OtelData > ( ) {
267
251
if let Some ( attributes) = & otd. builder . attributes {
268
252
for attribute in attributes {
269
253
log_record. add_attribute ( attribute. key . clone ( ) , & attribute. value ) ;
270
254
}
271
255
}
256
+
257
+ if let Some ( span_id) = otd. builder . span_id {
258
+ let opt_trace_id = otd. builder . trace_id . or_else ( || {
259
+ span. scope ( ) . last ( ) . and_then ( |root_span| {
260
+ root_span
261
+ . extensions ( )
262
+ . get :: < OtelData > ( )
263
+ . and_then ( |otd| otd. builder . trace_id )
264
+ } )
265
+ } ) ;
266
+ if let Some ( trace_id) = opt_trace_id {
267
+ log_record. set_trace_context ( trace_id, span_id, None ) ;
268
+ }
269
+ }
272
270
}
273
271
}
274
272
You can’t perform that action at this time.
0 commit comments