From 4d9ab22355f8f84b05ceaead4c9af1da3508d661 Mon Sep 17 00:00:00 2001 From: Snigdha Sharma Date: Wed, 12 Jul 2023 15:50:09 -0700 Subject: [PATCH 1/3] Emit escalating metrics --- src/sentry/tasks/post_process.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/sentry/tasks/post_process.py b/src/sentry/tasks/post_process.py index 84d4d92aee1777..f5c7876d1dae1e 100644 --- a/src/sentry/tasks/post_process.py +++ b/src/sentry/tasks/post_process.py @@ -15,6 +15,8 @@ from sentry.issues.grouptype import GroupCategory from sentry.issues.issue_occurrence import IssueOccurrence from sentry.killswitches import killswitch_matches_context +from sentry.sentry_metrics.kafka import KafkaMetricsBackend +from sentry.sentry_metrics.use_case_id_registry import UseCaseID from sentry.signals import event_processed, issue_unignored, transaction_processed from sentry.tasks.base import instrumented_task from sentry.utils import metrics @@ -114,6 +116,22 @@ def _capture_event_stats(event: Event) -> None: metrics.timing("events.size.data", event.size, tags=tags) +def _update_escalating_metrics(event: Event) -> None: + """ + Update metrics for escalating issues when an event is processed. + """ + metrics_backend = KafkaMetricsBackend() + metrics_backend.counter( + UseCaseID.ESCALATING_ISSUES, + org_id=event.project.organization_id, + project_id=event.project.id, + metric_name="event_ingested", + value=1, + tags={"group": event.group_id}, + unit=None, + ) + + def _capture_group_stats(job: PostProcessJob) -> None: event = job["event"] if not job["group_state"]["is_new"] or not should_write_event_stats(event): @@ -564,6 +582,7 @@ def get_event_raise_exception() -> Event: update_event_groups(event, group_states) bind_organization_context(event.project.organization) _capture_event_stats(event) + _update_escalating_metrics(event) group_events: Mapping[int, GroupEvent] = { ge.group_id: ge for ge in list(event.build_group_events()) From 5999cf8f8d1ec8f462b1f1de501ce50c9a527b13 Mon Sep 17 00:00:00 2001 From: Snigdha Sharma Date: Tue, 18 Jul 2023 18:04:37 -0700 Subject: [PATCH 2/3] Set tag value as string --- src/sentry/tasks/post_process.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sentry/tasks/post_process.py b/src/sentry/tasks/post_process.py index 47527efbd86902..25000806e8f143 100644 --- a/src/sentry/tasks/post_process.py +++ b/src/sentry/tasks/post_process.py @@ -128,7 +128,7 @@ def _update_escalating_metrics(event: Event) -> None: project_id=event.project.id, metric_name="event_ingested", value=1, - tags={"group": event.group_id}, + tags={"group": str(event.group_id)}, unit=None, ) From c0ef3686ca15ce5f4c2ab22e5a620b7e73add44f Mon Sep 17 00:00:00 2001 From: Snigdha Sharma Date: Thu, 20 Jul 2023 10:38:46 -0700 Subject: [PATCH 3/3] Close metrics backend --- src/sentry/tasks/post_process.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sentry/tasks/post_process.py b/src/sentry/tasks/post_process.py index 25000806e8f143..2d17a49a2ea9ee 100644 --- a/src/sentry/tasks/post_process.py +++ b/src/sentry/tasks/post_process.py @@ -131,6 +131,7 @@ def _update_escalating_metrics(event: Event) -> None: tags={"group": str(event.group_id)}, unit=None, ) + metrics_backend.close() def _capture_group_stats(job: PostProcessJob) -> None: