nickstenning commented on code in PR #61897:
URL: https://github.com/apache/airflow/pull/61897#discussion_r2852578538
##########
airflow-core/src/airflow/executors/base_executor.py:
##########
@@ -378,28 +391,14 @@ def trigger_tasks(self, open_slots: int) -> None:
if isinstance(item, workloads.ExecuteTask) and hasattr(item, "ti"):
ti = item.ti
-
- # If it's None, then the span for the current id hasn't been
started.
- if self.active_spans is not None and
self.active_spans.get("ti:" + str(ti.id)) is None:
- if isinstance(ti, workloads.TaskInstance):
- parent_context =
Trace.extract(ti.parent_context_carrier)
- else:
- parent_context =
Trace.extract(ti.dag_run.context_carrier)
- # Start a new span using the context from the parent.
- # Attributes will be set once the task has finished so
that all
- # values will be available (end_time, duration, etc.).
-
- span = Trace.start_child_span(
- span_name=f"{ti.task_id}",
- parent_context=parent_context,
- component="task",
- start_as_current=False,
- )
- self.active_spans.set("ti:" + str(ti.id), span)
- # Inject the current context into the carrier.
- carrier = Trace.inject()
- ti.context_carrier = carrier
-
+ if isinstance(ti, workloads.TaskInstance):
Review Comment:
I might be lacking some context (ba-DUM tish) to figure out what's going on
here.
What are these two different branches?
We need to be a bit careful not to propagate context around in ways that are
confusing. I'd expect `ti.context_carrier` to represent the context _of the TI
span_, not the context of the TI's parent dag run.
That might mean that we don't need `ti.context_carrier` at all, and we can
simply always reference `ti.dag_run.context_carrier` when we need to start a
span for a TI.
But perhaps I'm misunderstanding what the two branches are for in
```python
if isinstance(ti, workloads.TaskInstance):
...
else:
...
```
--
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]