Browse Source

fix(metrics): Fix pipeline name in post_process metric reporting (#58453)

https://github.com/getsentry/sentry/pull/58304/ added pipeline into our
metric reporting. However, it should be `pipeline_step.__name__`
Hubert Chan 1 year ago
parent
commit
d132b4c03a
2 changed files with 8 additions and 3 deletions
  1. 2 2
      src/sentry/tasks/post_process.py
  2. 6 1
      tests/sentry/tasks/test_post_process.py

+ 2 - 2
src/sentry/tasks/post_process.py

@@ -659,7 +659,7 @@ def run_post_process_job(job: PostProcessJob):
                 "sentry.tasks.post_process.post_process_group.exception",
                 tags={
                     "issue_category": issue_category_metric,
-                    "pipeline": pipeline,
+                    "pipeline": pipeline_step.__name__,
                 },
             )
             logger.exception(
@@ -671,7 +671,7 @@ def run_post_process_job(job: PostProcessJob):
                 "sentry.tasks.post_process.post_process_group.completed",
                 tags={
                     "issue_category": issue_category_metric,
-                    "pipeline": pipeline,
+                    "pipeline": pipeline_step.__name__,
                 },
             )
 

+ 6 - 1
tests/sentry/tasks/test_post_process.py

@@ -1759,7 +1759,8 @@ class PostProcessGroupErrorTest(
 
     @with_feature("organizations:escalating-metrics-backend")
     @patch("sentry.sentry_metrics.client.generic_metrics_backend.counter")
-    def test_generic_metrics_backend_counter(self, generic_metrics_backend_mock):
+    @patch("sentry.utils.metrics.incr")
+    def test_generic_metrics_backend_counter(self, metric_incr_mock, generic_metrics_backend_mock):
         min_ago = iso_format(before_now(minutes=1))
         event = self.create_event(
             data={
@@ -1782,6 +1783,10 @@ class PostProcessGroupErrorTest(
         )
 
         assert generic_metrics_backend_mock.call_count == 1
+        metric_incr_mock.assert_any_call(
+            "sentry.tasks.post_process.post_process_group.completed",
+            tags={"issue_category": "error", "pipeline": "process_rules"},
+        )
 
 
 @region_silo_test