oncall-engine/engine/apps/metrics_exporter/signals.py
Ildar Iskhakov 2fdd885abe
Move new alert group metric creation into async task (#3451)
# What this PR does

Moving metrics creation into separate task to make alert ingestion more
robust

## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

---------

Co-authored-by: Julia <ferril.darkdiver@gmail.com>
2023-11-29 12:45:36 +00:00

14 lines
467 B
Python

from apps.alerts.constants import AlertGroupState
from apps.alerts.signals import alert_group_created_signal
def on_alert_group_created(**kwargs):
alert_group = kwargs["alert_group"]
if alert_group.is_maintenance_incident is True:
return
alert_group._update_metrics(
organization_id=alert_group.channel.organization_id, previous_state=None, state=AlertGroupState.FIRING
)
alert_group_created_signal.connect(on_alert_group_created)