mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
chore(reports): add metrics to report schedule and log prune (#25080)
This commit is contained in:
parent
7402379346
commit
04bb73cf27
@ -26,6 +26,7 @@ from superset.extensions import celery_app
|
|||||||
from superset.reports.commands.exceptions import ReportScheduleUnexpectedError
|
from superset.reports.commands.exceptions import ReportScheduleUnexpectedError
|
||||||
from superset.reports.commands.execute import AsyncExecuteReportScheduleCommand
|
from superset.reports.commands.execute import AsyncExecuteReportScheduleCommand
|
||||||
from superset.reports.commands.log_prune import AsyncPruneReportScheduleLogCommand
|
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.tasks.cron_util import cron_schedule_window
|
||||||
from superset.utils.celery import session_scope
|
from superset.utils.celery import session_scope
|
||||||
from superset.utils.core import LoggerLevel
|
from superset.utils.core import LoggerLevel
|
||||||
@ -39,6 +40,9 @@ def scheduler() -> None:
|
|||||||
"""
|
"""
|
||||||
Celery beat main scheduler for reports
|
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"):
|
if not is_feature_enabled("ALERT_REPORTS"):
|
||||||
return
|
return
|
||||||
with session_scope(nullpool=True) as session:
|
with session_scope(nullpool=True) as session:
|
||||||
@ -68,6 +72,9 @@ def scheduler() -> None:
|
|||||||
|
|
||||||
@celery_app.task(name="reports.execute", bind=True)
|
@celery_app.task(name="reports.execute", bind=True)
|
||||||
def execute(self: Celery.task, report_schedule_id: int) -> None:
|
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
|
task_id = None
|
||||||
try:
|
try:
|
||||||
task_id = execute.request.id
|
task_id = execute.request.id
|
||||||
@ -100,6 +107,9 @@ def execute(self: Celery.task, report_schedule_id: int) -> None:
|
|||||||
|
|
||||||
@celery_app.task(name="reports.prune_log")
|
@celery_app.task(name="reports.prune_log")
|
||||||
def prune_log() -> None:
|
def prune_log() -> None:
|
||||||
|
stats_logger: BaseStatsLogger = app.config["STATS_LOGGER"]
|
||||||
|
stats_logger.incr("reports.prune_log")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
AsyncPruneReportScheduleLogCommand().run()
|
AsyncPruneReportScheduleLogCommand().run()
|
||||||
except SoftTimeLimitExceeded as ex:
|
except SoftTimeLimitExceeded as ex:
|
||||||
|
Loading…
Reference in New Issue
Block a user