Skip to content

Commit

Permalink
chore(reports): add metrics to report schedule and log prune (#25080)
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro authored Aug 25, 2023
1 parent 7402379 commit 04bb73c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions superset/tasks/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from superset.reports.commands.exceptions import ReportScheduleUnexpectedError
from superset.reports.commands.execute import AsyncExecuteReportScheduleCommand
from superset.reports.commands.log_prune import AsyncPruneReportScheduleLogCommand
from superset.stats_logger import BaseStatsLogger
from superset.tasks.cron_util import cron_schedule_window
from superset.utils.celery import session_scope
from superset.utils.core import LoggerLevel
Expand All @@ -39,6 +40,9 @@ def scheduler() -> None:
"""
Celery beat main scheduler for reports
"""
stats_logger: BaseStatsLogger = app.config["STATS_LOGGER"]
stats_logger.incr("reports.scheduler")

if not is_feature_enabled("ALERT_REPORTS"):
return
with session_scope(nullpool=True) as session:
Expand Down Expand Up @@ -68,6 +72,9 @@ def scheduler() -> None:

@celery_app.task(name="reports.execute", bind=True)
def execute(self: Celery.task, report_schedule_id: int) -> None:
stats_logger: BaseStatsLogger = app.config["STATS_LOGGER"]
stats_logger.incr("reports.execute")

task_id = None
try:
task_id = execute.request.id
Expand Down Expand Up @@ -100,6 +107,9 @@ def execute(self: Celery.task, report_schedule_id: int) -> None:

@celery_app.task(name="reports.prune_log")
def prune_log() -> None:
stats_logger: BaseStatsLogger = app.config["STATS_LOGGER"]
stats_logger.incr("reports.prune_log")

try:
AsyncPruneReportScheduleLogCommand().run()
except SoftTimeLimitExceeded as ex:
Expand Down

0 comments on commit 04bb73c

Please sign in to comment.