nickstenning commented on code in PR #62436:
URL: https://github.com/apache/airflow/pull/62436#discussion_r2852878732
##########
airflow-core/src/airflow/models/dagrun.py:
##########
@@ -145,6 +151,42 @@ def _creator_note(val):
return DagRunNote(*val)
+@contextmanager
+def use_root_context():
+ dummy_span_context = SpanContext(
+ trace_id=0x00000000000000000000000000000000,
+ span_id=0x0000000000000000,
+ is_remote=False,
+ trace_flags=TraceFlags(TraceFlags.SAMPLED),
+ )
+ ctx = trace.set_span_in_context(trace.NonRecordingSpan(dummy_span_context))
+ token = context.attach(ctx)
+ try:
+ yield
+ finally:
+ context.detach(token)
+
+
+@contextmanager
+def start_root_span():
+ generator = RandomIdGenerator()
+ trace_id = generator.generate_trace_id()
+ span_id = generator.generate_span_id()
+ with use_root_context():
+ span_context = SpanContext(
+ trace_id=trace_id,
+ span_id=span_id,
+ is_remote=True,
+ trace_flags=TraceFlags(TraceFlags.SAMPLED),
+ )
+ ctx = trace.set_span_in_context(trace.NonRecordingSpan(span_context))
+ token = context.attach(ctx)
+ try:
+ yield
+ finally:
+ context.detach(token)
+
+
Review Comment:
I don't think we need any of this. See below.
```suggestion
```
--
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]