Skip to content

Commit

Permalink
feat: store messages in DAQJobHealthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
furkan-bilgin committed Oct 14, 2024
1 parent 2b54159 commit dc3eae6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/daq/jobs/healthcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from daq.base import DAQJob
from daq.jobs.handle_stats import DAQJobMessageStats, DAQJobStatsDict
from daq.models import DAQJobStats
from daq.store.models import StorableDAQJobConfig
from daq.store.models import DAQJobMessageStore, StorableDAQJobConfig
from utils.time import get_now_unix_timestamp_ms


class AlertCondition(str, Enum):
Expand Down Expand Up @@ -150,3 +151,18 @@ def send_alert(self, item: HealthcheckItem):
alert_info=item.alert_info,
)
)
if len(self.config.store_config) > 0:
self.message_out.put(
DAQJobMessageStore(
store_config=self.config.store_config,
daq_job=self,
keys=["timestamp", "severity", "message"],
data=[
[
get_now_unix_timestamp_ms(),
item.alert_info.severity,
item.alert_info.message,
]
],
)
)
5 changes: 5 additions & 0 deletions src/utils/time.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from datetime import datetime


def get_now_unix_timestamp_ms() -> int:
return int(datetime.now().timestamp() * 1000)

0 comments on commit dc3eae6

Please sign in to comment.