AutomationDev85 commented on code in PR #70013:
URL: https://github.com/apache/airflow/pull/70013#discussion_r3718395676


##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -3245,10 +3245,17 @@ def _emit_ti_metrics(self, *, session: Session = 
NEW_SESSION) -> None:
             self.previous_ti_metrics[state] = ti_metrics
 
     @provide_session
-    def _emit_running_dags_metric(self, *, session: Session = NEW_SESSION) -> 
None:
-        stmt = select(func.count()).select_from(DagRun).where(DagRun.state == 
DagRunState.RUNNING)
-        running_dags = float(session.scalar(stmt) or 0)
-        stats.gauge("scheduler.dagruns.running", running_dags)
+    def _emit_dag_runs_metric(self, *, session: Session = NEW_SESSION) -> None:
+        stmt = (
+            select(DagRun.dag_id, DagRun.state, func.count().label("count"))
+            .where(DagRun.state.in_([DagRunState.RUNNING, DagRunState.QUEUED]))
+            .group_by(DagRun.dag_id, DagRun.state)
+        )
+        for dag_id, state, count in session.execute(stmt).all():

Review Comment:
   @potiuk Thanks for your review. This is a really good point. I did not 
thought about that. I added a config flag to enable or disable DAG_ID tags.



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