Skip to content

Commit

Permalink
Fix broken stat scheduler_loop_duration (#42886) (#43544)
Browse files Browse the repository at this point in the history
* wip

* wip

* fix lint err

---------

Co-authored-by: venkat <[email protected]>
(cherry picked from commit 60b8056)

Co-authored-by: Venkat VJ <[email protected]>
(cherry picked from commit 842c60a)
  • Loading branch information
potiuk authored and utkarsharma2 committed Nov 1, 2024
1 parent 23370b5 commit 5854ff0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions airflow/jobs/scheduler_job_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,16 +1105,18 @@ def _run_scheduler_loop(self) -> None:
)

for loop_count in itertools.count(start=1):
with Trace.start_span(span_name="scheduler_job_loop", component="SchedulerJobRunner") as span:
with Trace.start_span(
span_name="scheduler_job_loop", component="SchedulerJobRunner"
) as span, Stats.timer("scheduler.scheduler_loop_duration") as timer:
span.set_attribute("category", "scheduler")
span.set_attribute("loop_count", loop_count)
with Stats.timer("scheduler.scheduler_loop_duration") as timer:
if self.using_sqlite and self.processor_agent:
self.processor_agent.run_single_parsing_loop()
# For the sqlite case w/ 1 thread, wait until the processor
# is finished to avoid concurrent access to the DB.
self.log.debug("Waiting for processors to finish since we're using sqlite")
self.processor_agent.wait_until_finished()

if self.using_sqlite and self.processor_agent:
self.processor_agent.run_single_parsing_loop()
# For the sqlite case w/ 1 thread, wait until the processor
# is finished to avoid concurrent access to the DB.
self.log.debug("Waiting for processors to finish since we're using sqlite")
self.processor_agent.wait_until_finished()

with create_session() as session:
# This will schedule for as many executors as possible.
Expand Down

0 comments on commit 5854ff0

Please sign in to comment.