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


##########
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:
   Hi @jason810496, thanks for the review. I've gone through the code again and 
I think you're right. Let me update the patch accordingly.



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