jason810496 commented on code in PR #52815:
URL: https://github.com/apache/airflow/pull/52815#discussion_r2448871745


##########
airflow-core/src/airflow/dag_processing/manager.py:
##########
@@ -1021,6 +1025,22 @@ def prepare_file_queue(self, known_files: dict[str, 
set[DagFileInfo]]):
         self._add_files_to_queue(to_queue, False)
         Stats.incr("dag_processing.file_path_queue_update_count")
 
+    def _is_metrics_enabled(self):
+        return (
+            conf.getboolean("metrics", "statsd_datadog_enabled", 
fallback=False)
+            or conf.getboolean("metrics", "statsd_on", fallback=False)
+            or conf.getboolean("metrics", "otel_on", fallback=False)
+        )
+
+    def _emit_running_dags_metric(self):
+        """Emit executor.running_dags gauge."""
+        if not self._is_metrics_enabled():
+            return
+        with create_session() as session:
+            stmt = select(func.count()).select_from(DagRun).where(DagRun.state 
== DagRunState.RUNNING)
+            running_dags = session.scalar(stmt)
+            Stats.gauge("executor.running_dags", running_dags)

Review Comment:
   Would it be better to place in `SchedulerJobRunner._run_scheduler_loop` 
instead of placing in DagProcessor? 
   
   Some place like:
   
https://github.com/apache/airflow/blob/f3ad20aad803196b6fc1c73c1a38560deaf31aee/airflow-core/src/airflow/jobs/scheduler_job_runner.py#L1286-L1290
   
   Since if we search with `Stats.gauge` across the codebase, there are only 
`dag_processing` or `dag_bag` related metics in DagProcessor component but not 
`executor` related metrics.
   Also `heartbeat`. IMO, Executor is more closer to Scheduler compare with 
DagProcessor.



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