@@ -58,11 +58,17 @@ def _get_xray_trace_context():
58
58
return None
59
59
60
60
xray_trace_entity = xray_recorder .get_trace_entity () # xray (sub)segment
61
- return {
61
+ trace_context = {
62
62
"trace-id" : _convert_xray_trace_id (xray_trace_entity .trace_id ),
63
63
"parent-id" : _convert_xray_entity_id (xray_trace_entity .id ),
64
64
"sampling-priority" : _convert_xray_sampling (xray_trace_entity .sampled ),
65
65
}
66
+ logger .debug (
67
+ "Converted trace context %s from X-Ray segment %s" ,
68
+ trace_context ,
69
+ (xray_trace_entity .trace_id , xray_trace_entity .id , xray_trace_entity .sampled ),
70
+ )
71
+ return trace_context
66
72
67
73
68
74
def _get_dd_trace_py_context ():
@@ -73,6 +79,9 @@ def _get_dd_trace_py_context():
73
79
parent_id = span .context .span_id
74
80
trace_id = span .context .trace_id
75
81
sampling_priority = span .context .sampling_priority
82
+ logger .debug (
83
+ "found dd trace context: %s" , (span .context .trace_id , span .context .span_id )
84
+ )
76
85
return {
77
86
"parent-id" : str (parent_id ),
78
87
"trace-id" : str (trace_id ),
@@ -258,11 +267,11 @@ def get_dd_trace_context():
258
267
elif xray_context and dd_trace_context :
259
268
context = dd_trace_context .copy ()
260
269
context ["parent-id" ] = xray_context ["parent-id" ]
270
+ logger .debug ("Set parent id from xray trace context: %s" , context ["parent-id" ])
261
271
262
272
if dd_tracing_enabled :
263
273
dd_trace_py_context = _get_dd_trace_py_context ()
264
274
if dd_trace_py_context is not None :
265
- logger .debug ("get_dd_trace_context using dd-trace context" )
266
275
context = dd_trace_py_context
267
276
268
277
return _context_obj_to_headers (context ) if context is not None else {}
@@ -328,9 +337,13 @@ def is_lambda_context():
328
337
329
338
def set_dd_trace_py_root (trace_context_source , merge_xray_traces ):
330
339
if trace_context_source == TraceContextSource .EVENT or merge_xray_traces :
331
- headers = get_dd_trace_context ( )
340
+ headers = _context_obj_to_headers ( dd_trace_context )
332
341
span_context = propagator .extract (headers )
333
342
tracer .context_provider .activate (span_context )
343
+ logger .debug (
344
+ "Set dd trace root context to: %s" ,
345
+ (span_context .trace_id , span_context .span_id ),
346
+ )
334
347
335
348
336
349
def create_function_execution_span (
0 commit comments