xBis7 commented on code in PR #61897:
URL: https://github.com/apache/airflow/pull/61897#discussion_r2830240882


##########
airflow-core/src/airflow/executors/base_executor.py:
##########
@@ -133,15 +133,32 @@ def get_mandatory_value(self, *args, **kwargs) -> str:
         return conf.get_mandatory_value(*args, **kwargs, 
team_name=self.team_name)
 
 
+@contextmanager
+def start_ti_span(ti):
+    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.).
+
+    tracer = Trace.get_tracer("dagrun")
+    with tracer.start_as_current_span("task", context=parent_context) as span:

Review Comment:
   Similar to the `dag_id` and the `create_dagrun` name, if we included the 
`task_id` in the name instead of adding it as an attribute, it would be easier 
to identify which task is running without having to click on it and examine the 
attributes.



##########
airflow-core/src/airflow/serialization/definitions/dag.py:
##########
@@ -70,6 +71,18 @@
 log = structlog.get_logger(__name__)
 
 
+def add_dagrun_span(func):
+    @functools.wraps(func)
+    def wrapper(self, *args, **kwargs):
+        tracer = Trace.get_tracer("dagrun")
+        with tracer.start_as_current_span("create_dagrun") as span:

Review Comment:
   If we included the `dag_id` in the name instead of adding it as an 
attribute, it would be easier to identify to which dag the trace belongs to. We 
could add the `run_id` as an attribute.



-- 
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