This is an automated email from the ASF dual-hosted git repository.
husseinawala pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 8c43fc5e78 Add metric `triggerer_heartbeat` (#33320)
8c43fc5e78 is described below
commit 8c43fc5e783f01ab916c7f4469756f4bcd9a02aa
Author: Vincent <[email protected]>
AuthorDate: Fri Aug 11 19:12:56 2023 -0400
Add metric `triggerer_heartbeat` (#33320)
* Add metric `triggerer_heartbeat`
* Fix copy paste
---
airflow/jobs/triggerer_job_runner.py | 7 ++++++-
.../administration-and-deployment/logging-monitoring/metrics.rst | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/airflow/jobs/triggerer_job_runner.py
b/airflow/jobs/triggerer_job_runner.py
index 9f8dac6184..77fe95ed7f 100644
--- a/airflow/jobs/triggerer_job_runner.py
+++ b/airflow/jobs/triggerer_job_runner.py
@@ -31,6 +31,7 @@ from queue import SimpleQueue
from typing import TYPE_CHECKING
from sqlalchemy import func
+from sqlalchemy.orm import Session
from airflow.configuration import conf
from airflow.jobs.base_job_runner import BaseJobRunner
@@ -54,7 +55,7 @@ from airflow.utils.log.trigger_handler import (
ctx_trigger_id,
)
from airflow.utils.module_loading import import_string
-from airflow.utils.session import provide_session
+from airflow.utils.session import NEW_SESSION, provide_session
if TYPE_CHECKING:
from airflow.models import TaskInstance
@@ -280,6 +281,10 @@ class TriggererJobRunner(BaseJobRunner["Job |
JobPydantic"], LoggingMixin):
# Set up runner async thread
self.trigger_runner = TriggerRunner()
+ @provide_session
+ def heartbeat_callback(self, session: Session = NEW_SESSION) -> None:
+ Stats.incr("triggerer_heartbeat", 1, 1)
+
def register_signals(self) -> None:
"""Register signals that stop child processes."""
signal.signal(signal.SIGINT, self._exit_gracefully)
diff --git
a/docs/apache-airflow/administration-and-deployment/logging-monitoring/metrics.rst
b/docs/apache-airflow/administration-and-deployment/logging-monitoring/metrics.rst
index b18d05a877..224f4fdbeb 100644
---
a/docs/apache-airflow/administration-and-deployment/logging-monitoring/metrics.rst
+++
b/docs/apache-airflow/administration-and-deployment/logging-monitoring/metrics.rst
@@ -182,6 +182,7 @@ Name
Descripti
``task_restored_to_dag.<dag_id>`` Number
of tasks restored for a given dag (i.e. task instance which was
previously in REMOVED state in the DB is added to DAG file)
``task_instance_created_<operator_name>`` Number
of tasks instances created for a given Operator
+``triggerer_heartbeat``
Triggerer heartbeats
``triggers.blocked_main_thread`` Number
of triggers that blocked the main thread (likely due to not being
fully
asynchronous)
``triggers.failed`` Number
of triggers that errored before they could fire an event