Lee-W commented on code in PR #73991:
URL: https://github.com/apache/airflow/pull/73991#discussion_r4151242539
##########
providers/common/ai/src/airflow/providers/common/ai/observability.py:
##########
@@ -121,15 +121,30 @@ def build_run_identity_attributes(ti: Any) -> dict[str,
Any]:
Reuses core's task-span attribute keys (see ``_make_task_span``) so agent
spans filter identically to the task span they nest under, plus the
per-attempt task-instance id as the run join key carried on every span.
+ Airflow 2 task instances have no id, so the attribute is left out there.
"""
- return {
+ attributes: dict[str, Any] = {
"airflow.dag_id": ti.dag_id,
"airflow.task_id": ti.task_id,
"airflow.dag_run.run_id": ti.run_id,
"airflow.task_instance.try_number": ti.try_number,
"airflow.task_instance.map_index": ti.map_index if ti.map_index is not
None else -1,
- "airflow.task_instance.id": str(ti.id),
}
+ if (ti_id := getattr(ti, "id", None)) is not None:
+ attributes["airflow.task_instance.id"] = str(ti_id)
+ return attributes
+
+
+def task_instance_run_key(ti: Any) -> str:
Review Comment:
```suggestion
def make_task_instance_run_key(ti: Any) -> str:
```
--
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]