nickstenning commented on code in PR #62436:
URL: https://github.com/apache/airflow/pull/62436#discussion_r2852899497


##########
airflow-core/src/airflow/models/dagrun.py:
##########
@@ -366,7 +405,11 @@ def __init__(
         self.triggered_by = triggered_by
         self.triggering_user_name = triggering_user_name
         self.scheduled_by_job_id = None
-        self.context_carrier = {}
+
+        context_carrier = {}
+        with start_root_span():
+            TraceContextTextMapPropagator().inject(context_carrier)
+        self.context_carrier = context_carrier

Review Comment:
   ```suggestion
   
           self.context_carrier = {}
           
           # We never call .end() on this span. It's solely used to generate a 
trace context for the rest of the run.
           span = tracer.start_span("notused")  
           ctx = trace.set_span_in_context(span)
           TraceContextTextMapPropagator().inject(self.context_carrier, 
context=ctx)
   ```
   
   or, if you want to be absolutely certain that the dag processor root span 
doesn't have a parent (I'm not sure I'd do this if it's not needed):
   
   ```suggestion
   
           self.context_carrier = {}
           
           # We never call .end() on this span. It's solely used to generate a 
trace context for the rest of the run.
           empty_context = Context()
           span = tracer.start_span("notused", context=empty_context)  
           ctx = trace.set_span_in_context(span)
           TraceContextTextMapPropagator().inject(self.context_carrier, 
context=ctx)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to