Skip to content

Commit

Permalink
Improve tracing of cmk-ui-job-scheduler
Browse files Browse the repository at this point in the history
Change-Id: Iec4f3071d1d0e1cc6fc0c5fc6ed3f92ce2e6a225
  • Loading branch information
LarsMichelsen committed Nov 15, 2024
1 parent 624589d commit a25fa6f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmk/gui/job_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
from cmk.trace.export import exporter_from_config, init_span_processor
from cmk.trace.logs import add_span_log_handler

tracer = trace.get_tracer()


def _pid_file(omd_root: Path) -> Path:
return omd_root / "tmp" / "run" / "cmk-ui-job-scheduler.pid"
Expand Down Expand Up @@ -85,14 +87,18 @@ def _run_scheduler() -> None:
)


@tracer.start_as_current_span("_run_scheduled_jobs")
def _run_scheduled_jobs() -> None:
logger.debug("Starting cron jobs")

for job in cron_job_registry.values():
try:
logger.debug("Starting [%s]", job.name)
job.callable()
logger.debug("Finished [%s]", job.name)
with tracer.start_as_current_span(
f"run_cron_job[{job.name}]", attributes={"cmk.gui.job_name": job.name}
):
logger.debug("Starting [%s]", job.name)
job.callable()
logger.debug("Finished [%s]", job.name)
except Exception:
crash = create_gui_crash_report()
logger.error(
Expand Down

0 comments on commit a25fa6f

Please sign in to comment.