nailo2c opened a new pull request, #52815:
URL: https://github.com/apache/airflow/pull/52815

   Closes: #12368
   
   # Why
   
   Addresses #12368, expose a gauge metric `executor.running_dags` so operators 
can monitor how many DAGs are currently running.
   
   # How
   
   Add a lightweight metric emitter `_emit_running_dags_metric()`
   
   # What
   
   I started a local Breeze environment with StatsD enabled: `breeze 
start-airflow --integration statsd`
   
   I then used the following example DAG to verify that the new metric is 
emitted:
   
   ```python
   import pendulum
   from airflow import DAG
   from airflow.operators.bash import BashOperator
   from airflow.operators.empty import EmptyOperator
   
   
   def build_simple_dag(dag_id: str) -> DAG:
       with DAG(
           dag_id     = dag_id,
           schedule   = "@daily",
           start_date = pendulum.now("UTC").subtract(days=10),
           catchup    = True,
           tags       = ["statsd-demo"],
       ) as dag:
           start  = EmptyOperator(task_id="start")
           sleep  = BashOperator(task_id="sleep_5m", bash_command="sleep 300")
           finish = EmptyOperator(task_id="finish")
   
           start >> sleep >> finish
       return dag
   
   for i in range(2):
       globals()[f"example_statsd_{i}"] = 
build_simple_dag(f"example_statsd_{i}")
   ```
   
   StatsD: http://localhost:29102/metrics
   
![feat-12368-statsd](https://github.com/user-attachments/assets/c820bb5b-6d71-49f1-aae3-0f08011155d7)
   
   Grafana: http://localhost:23000
   
![feat-12368-grafana](https://github.com/user-attachments/assets/ca129a46-9e98-4e57-8549-12406bbdc09a)
   
   


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