ashb commented on code in PR #63568:
URL: https://github.com/apache/airflow/pull/63568#discussion_r2974524680
##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -431,6 +436,45 @@ def ti_update_state(
)
+def _emit_task_span(ti, state):
+ # just to be safe
+ if not ti.dag_run:
+ return
+ if not isinstance(ti.dag_run.context_carrier, dict):
+ return
+ if not isinstance(ti.context_carrier, dict):
+ return
+ dr_ctx =
TraceContextTextMapPropagator().extract(ti.dag_run.context_carrier)
+
+ ti_ctx = TraceContextTextMapPropagator().extract(ti.context_carrier)
+ ti_span = trace.get_current_span(context=ti_ctx)
+ span_context = ti_span.get_span_context()
+ start_time_candidates = (x for x in (ti.queued_dttm, ti.start_date,
timezone.utcnow()) if x)
+ name = f"task_run.{ti.task_id}"
+ if ti.map_index >= 0:
+ name += f"_{ti.map_index}"
+ with override_ids(span_context.trace_id, span_context.span_id):
+ span = tracer.start_span(
+ name=name,
+ start_time=int(min(start_time_candidates).timestamp() * 1e9),
+ context=dr_ctx,
+ )
+
+ span.set_attributes(
Review Comment:
Does the `ti.id` (the uuid) appear somewhere already?
--
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]