ashb commented on code in PR #63308:
URL: https://github.com/apache/airflow/pull/63308#discussion_r2934902169


##########
airflow-core/src/airflow/models/dagrun.py:
##########
@@ -364,6 +366,7 @@ def __init__(
         self.creating_job_id = creating_job_id
         self.backfill_id = backfill_id
         self.clear_number = 0
+        self.triggered_at = timezone.utcnow()

Review Comment:
   Question about semantics: what value should this have for scheduled dags?
   
   I think I'm only hesitating cos of the "triggered" part of the name



##########
airflow-core/src/airflow/models/dagrun.py:
##########
@@ -1025,17 +1028,22 @@ def _emit_dagrun_span(self, state: DagRunState):
                 "airflow.dag_run.run_id": self.run_id,
             }
             if self.logical_date:
-                attributes["airflow.dag_run.logical_date"] = 
str(self.logical_date)
+                attributes["airflow.dag_run.logical_date"] = 
str(self.logical_date.timestamp() * 1e9)
             if self.partition_key:
-                attributes["airflow.dag_run.partition_key"] = 
str(self.partition_key)
+                attributes["airflow.dag_run.partition_key"] = 
self.partition_key
             span = tracer.start_span(
                 name=f"dag_run.{self.dag_id}",
-                start_time=int((self.start_date or 
timezone.utcnow()).timestamp() * 1e9),
+                start_time=int((self.triggered_at or 
timezone.utcnow()).timestamp() * 1e9),
                 attributes=attributes,
                 context=context.Context(),
             )
             status_code = StatusCode.OK if state == DagRunState.SUCCESS else 
StatusCode.ERROR
             span.set_status(status_code)
+            span.add_event(
+                "airflow.dag_run.start_time",
+                attributes=attributes,
+                timestamp=int((self.start_date and self.start_date.timestamp() 
or timezone.utcnow()) * 1e9),

Review Comment:
   This seems a bit suspect- start date should be set already, but if it's not 
we shouldn't synthesise a value



##########
airflow-core/src/airflow/migrations/versions/0108_3_2_0_add_triggered_at_to_dag_run.py:
##########
@@ -0,0 +1,61 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Add triggered_at to dag_run table.
+
+Revision ID: cd799060f00b
+Revises: 6222ce48e289
+Create Date: 2026-03-10 00:00:00.000000
+
+"""
+
+from __future__ import annotations
+
+import sqlalchemy as sa
+from alembic import op
+
+from airflow.utils.sqlalchemy import UtcDateTime
+
+revision = "cd799060f00b"
+down_revision = "6222ce48e289"
+branch_labels = None
+depends_on = None
+airflow_version = "3.2.0"
+
+
+def upgrade():
+    """Add triggered_at column to dag_run table."""
+    with op.batch_alter_table("dag_run", schema=None) as batch_op:
+        batch_op.add_column(
+            sa.Column(
+                "triggered_at",
+                UtcDateTime,
+                nullable=True,
+            )
+        )
+    # Back-fill existing rows using created_at as a reasonable approximation.
+    op.execute("UPDATE dag_run SET triggered_at = created_at WHERE 
triggered_at IS NULL")

Review Comment:
   How long will this take for large installs?



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