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


##########
airflow-core/tests/unit/jobs/test_scheduler_job.py:
##########
@@ -7086,6 +7086,33 @@ def 
test_process_expired_deadlines_no_deadlines_found(self, mock_handle_miss, se
         # The handler should not be called, but no exceptions should be raised 
either.`
         mock_handle_miss.assert_not_called()
 
+    def test_emit_running_dags_metric(self, dag_maker, monkeypatch):
+        """Test that the running_dags metric is emitted correctly."""
+        from airflow.utils.state import DagRunState
+
+        with dag_maker("metric_dag") as dag:
+            _ = dag
+        dag_maker.create_dagrun(run_id="run_1", state=DagRunState.RUNNING, 
logical_date=timezone.utcnow())
+        dag_maker.create_dagrun(
+            run_id="run_2", state=DagRunState.RUNNING, 
logical_date=timezone.utcnow() + timedelta(hours=1)
+        )
+
+        recorded: list[tuple[str, int]] = []
+
+        def _fake_gauge(metric: str, value: int, *_, **__):
+            recorded.append((metric, value))
+
+        monkeypatch.setattr("airflow.dag_processing.manager.Stats.gauge", 
_fake_gauge, raising=True)
+
+        with conf_vars({("metrics", "statsd_on"): "True"}):
+            # mock_executor = MagicMock(spec=BaseExecutor)
+            # scheduler_job = Job(executor=mock_executor)

Review Comment:
   Oops, I forgot to delete that. I'll remove it now. Thanks for catching it!



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