fix(simple_metrics): update adaptive state even without thresholds so removed thresholds recover (SIENTIAPDE-2191)
This commit is contained in:
@@ -537,7 +537,7 @@ class ModelMetrics(SientiaMonitoring):
|
||||
- metadata (dict): Workflow metadata; `schedule_name` identifies the doc.
|
||||
- simple_metrics (list[dict]): Rows from `calculate_simple_metrics`; empty for an
|
||||
empty or under-sampled window, which counts as a non-breach run.
|
||||
- thresholds (dict): `simple_metrics_thresholds` from `model_config`.
|
||||
- thresholds (dict): `simple_metrics_thresholds` from `model_config` (may be None: no breach).
|
||||
- interval_minutes (int): Window size, used to compute the recovery runs.
|
||||
|
||||
Return:
|
||||
|
||||
@@ -77,7 +77,7 @@ class SimpleMetrics:
|
||||
if target_data and not enough_samples:
|
||||
workflow.logger.info(
|
||||
f'{len(target_data)} rows < simple_metrics_min_samples={min_samples}: '
|
||||
'threshold alerting skipped'
|
||||
'threshold alerting and escalation skipped'
|
||||
)
|
||||
|
||||
simple_metrics = None
|
||||
@@ -114,17 +114,15 @@ class SimpleMetrics:
|
||||
start_to_close_timeout=timedelta(seconds=300),
|
||||
)
|
||||
|
||||
if not thresholds:
|
||||
# No thresholds = no breach possible, so skip the Mongo round trip.
|
||||
return
|
||||
|
||||
try:
|
||||
await workflow.execute_activity_method(
|
||||
Activities.update_simple_metrics_adaptive_state,
|
||||
{
|
||||
**metadata,
|
||||
# Only a valid breach escalates: an empty or under-sampled window is sent as
|
||||
# no rows, which counts as a healthy run (spec decision 8).
|
||||
# no rows, which counts as a healthy run (spec decision 8). Always called, even
|
||||
# without thresholds (no breach), so an escalated doc recovers after they are
|
||||
# removed.
|
||||
'simple_metrics': (simple_metrics or []) if enough_samples else [],
|
||||
'thresholds': thresholds,
|
||||
'interval_minutes': interval_minutes,
|
||||
|
||||
Reference in New Issue
Block a user