Emit scheduler.executor_events_duration per executor#68152
Open
dkranchii wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wrap
_process_executor_events()in a per-executorstats.timernamedscheduler.executor_events_duration, tagged by executor class name. Multi-executor deployments can now attribute per-loop event-processing cost to each configured executor, instead of only seeing it baked into the aggregatescheduler.scheduler_loop_duration.This mirrors the precedent set by #66808, which added
scheduler.executor_heartbeat_durationforexecutor.heartbeat(). The two timers sit side-by-side, so operators can localize which stage of the scheduler loop a given executor is slowing down.Why
Today, when the scheduler loop runs long in a multi-executor deployment, operators can see the aggregate via
scheduler.scheduler_loop_durationbut cannot tell which executor's event processing is to blame. Adding a per-executor timer for_process_executor_eventsgives the same granular signal the heartbeat timer added — single-file, additive, zero-cost when metrics are disabled.Changes
airflow-core/src/airflow/jobs/scheduler_job_runner.py— wrap the per-executor_process_executor_events()call instats.timer("scheduler.executor_events_duration", tags={"executor": type(executor).__name__}).shared/observability/src/airflow_shared/observability/metrics/metrics_template.yaml— declare the new timer in the metrics registry.airflow-core/tests/unit/jobs/test_scheduler_job.py— addtest_process_executor_events_emits_timer, mirroring the existingtest_executor_heartbeat_emits_timerstructure.Test plan
test_process_executor_events_emits_timerasserts the timer is emitted once per executor with the expected tag.test_executor_heartbeat_emits_timerstill passes (sibling test, same loop).ruff format/ruff checkclean.prek run --from-ref main --stage pre-commitand--stage manualclean (excluding host-only mypy/breeze hooks; CI will run them).Notes
CLAUDE.md: new optional metrics are not major/breaking.Was generative AI tooling used to co-author this PR?