This commit is contained in:
Kenneth Kehl
2025-07-10 14:29:46 -07:00
parent c81264f098
commit 8fa893895c
4 changed files with 0 additions and 169 deletions

View File

@@ -4,7 +4,6 @@ from flask import current_app
from app import notify_celery
from app.config import QueueNames
from app.cronitor import cronitor
from app.dao.fact_billing_dao import fetch_billing_data_for_day, update_fact_billing
from app.dao.fact_notification_status_dao import update_fact_notification_status
from app.dao.notifications_dao import get_service_ids_with_notifications_on_date
@@ -13,7 +12,6 @@ from app.utils import utc_now
@notify_celery.task(name="create-nightly-billing")
@cronitor("create-nightly-billing")
def create_nightly_billing(day_start=None):
# day_start is a datetime.date() object. e.g.
# up to 4 days of data counting back from day_start is consolidated
@@ -58,7 +56,6 @@ def create_nightly_billing_for_day(process_day):
@notify_celery.task(name="create-nightly-notification-status")
@cronitor("create-nightly-notification-status")
def create_nightly_notification_status():
"""
Aggregate notification statuses into rows in ft_notification_status.

View File

@@ -124,10 +124,6 @@ class Config(object):
# Logging
DEBUG = False
# Monitoring
CRONITOR_ENABLED = False
CRONITOR_KEYS = json.loads(getenv("CRONITOR_KEYS", "{}"))
# Antivirus
ANTIVIRUS_ENABLED = getenv("ANTIVIRUS_ENABLED", "1") == "1"
@@ -411,7 +407,6 @@ class Production(Config):
)
FROM_NUMBER = "Notify.gov"
CRONITOR_ENABLED = True
class Staging(Production):

View File

@@ -1,61 +0,0 @@
from functools import wraps
import requests
from flask import current_app
def cronitor(task_name):
def decorator(func):
def ping_cronitor(command):
if not current_app.config["CRONITOR_ENABLED"]:
return
# it's useful to have a log that a periodic task has started in case it
# get stuck without generating any other logs - we know it got this far
current_app.logger.info(f"Pinging Cronitor for Celery task {task_name}")
task_slug = current_app.config["CRONITOR_KEYS"].get(task_name)
if not task_slug:
current_app.logger.error(
"Cronitor enabled but task_name {} not found in environment".format(
task_name
)
)
return
if command not in {"run", "complete", "fail"}:
raise ValueError(
"command {} not a valid cronitor command".format(command)
)
try:
resp = requests.get(
"https://cronitor.link/{}/{}".format(task_slug, command),
# cronitor limits msg to 1000 characters
params={
"host": current_app.config["API_HOST_NAME"],
},
timeout=30,
)
resp.raise_for_status()
except requests.RequestException as e:
current_app.logger.warning(
"Cronitor API failed for task {} due to {}".format(
task_name, repr(e)
)
)
@wraps(func)
def inner_decorator(*args, **kwargs):
ping_cronitor("run")
status = "fail"
try:
ret = func(*args, **kwargs)
status = "complete"
return ret
finally:
ping_cronitor(status)
return inner_decorator
return decorator