Просмотр исходного кода

fix(generic-metrics): Inject aggregation option in api tests (#54144)

# Overview

https://github.com/getsentry/snuba/pull/4578 makes changes to snuba
consumer that only applies the histogram aggregation iff it contains the
specific aggregation option tag.

This pr adds that aggregation option to snuba API tests that queries
histograms, so https://github.com/getsentry/snuba/pull/4578 can be
unblocked.
John 1 год назад
Родитель
Сommit
0be76a5543

+ 4 - 0
src/sentry/testutils/cases.py

@@ -1485,6 +1485,7 @@ class BaseMetricsLayerTestCase(BaseMetricsTestCase):
         hours_before_now: int = 0,
         hours_before_now: int = 0,
         minutes_before_now: int = 0,
         minutes_before_now: int = 0,
         seconds_before_now: int = 0,
         seconds_before_now: int = 0,
+        aggregation_option: Optional[AggregationOption] = None,
     ):
     ):
         # We subtract one second in order to account for right non-inclusivity in the query. If we wouldn't do this
         # We subtract one second in order to account for right non-inclusivity in the query. If we wouldn't do this
         # some data won't be returned (this applies only if we use self.now() in the "end" bound of the query).
         # some data won't be returned (this applies only if we use self.now() in the "end" bound of the query).
@@ -1514,6 +1515,7 @@ class BaseMetricsLayerTestCase(BaseMetricsTestCase):
             ),
             ),
             value=value,
             value=value,
             use_case_id=use_case_id,
             use_case_id=use_case_id,
+            aggregation_option=aggregation_option,
         )
         )
 
 
     @staticmethod
     @staticmethod
@@ -1559,6 +1561,7 @@ class BaseMetricsLayerTestCase(BaseMetricsTestCase):
         hours_before_now: int = 0,
         hours_before_now: int = 0,
         minutes_before_now: int = 0,
         minutes_before_now: int = 0,
         seconds_before_now: int = 0,
         seconds_before_now: int = 0,
+        aggregation_option: Optional[AggregationOption] = None,
     ):
     ):
         self._store_metric(
         self._store_metric(
             type=type,
             type=type,
@@ -1572,6 +1575,7 @@ class BaseMetricsLayerTestCase(BaseMetricsTestCase):
             hours_before_now=hours_before_now,
             hours_before_now=hours_before_now,
             minutes_before_now=minutes_before_now,
             minutes_before_now=minutes_before_now,
             seconds_before_now=seconds_before_now,
             seconds_before_now=seconds_before_now,
+            aggregation_option=aggregation_option,
         )
         )
 
 
     def store_release_health_metric(
     def store_release_health_metric(

+ 2 - 0
tests/sentry/snuba/metrics/test_metrics_layer/test_metrics_enhanced_performance.py

@@ -19,6 +19,7 @@ from sentry.models import (
     TransactionMetric,
     TransactionMetric,
 )
 )
 from sentry.sentry_metrics import indexer
 from sentry.sentry_metrics import indexer
+from sentry.sentry_metrics.aggregation_option_registry import AggregationOption
 from sentry.sentry_metrics.use_case_id_registry import UseCaseID
 from sentry.sentry_metrics.use_case_id_registry import UseCaseID
 from sentry.snuba.metrics import (
 from sentry.snuba.metrics import (
     MAX_POINTS,
     MAX_POINTS,
@@ -1091,6 +1092,7 @@ class PerformanceMetricsLayerTestCase(BaseMetricsLayerTestCase, TestCase):
                     name=TransactionMRI.MEASUREMENTS_LCP.value,
                     name=TransactionMRI.MEASUREMENTS_LCP.value,
                     tags={tag: value},
                     tags={tag: value},
                     value=subvalue,
                     value=subvalue,
+                    aggregation_option=AggregationOption.HIST,
                 )
                 )
 
 
         metrics_query = self.build_metrics_query(
         metrics_query = self.build_metrics_query(