|
@@ -1,6 +1,5 @@
|
|
|
import datetime
|
|
|
import math
|
|
|
-import re
|
|
|
from typing import List
|
|
|
from unittest import mock
|
|
|
|
|
@@ -8,7 +7,6 @@ import pytest
|
|
|
from django.utils import timezone
|
|
|
from snuba_sdk import AliasedExpression, Column, Condition, Function, Op
|
|
|
|
|
|
-from sentry import options
|
|
|
from sentry.exceptions import IncompatibleMetricsQuery
|
|
|
from sentry.search.events import constants
|
|
|
from sentry.search.events.builder import (
|
|
@@ -101,14 +99,7 @@ class MetricBuilderBaseTest(MetricsEnhancedPerformanceTestCase):
|
|
|
Condition(Column("org_id"), Op.EQ, self.organization.id),
|
|
|
]
|
|
|
|
|
|
- if not options.get("sentry-metrics.performance.tags-values-are-strings"):
|
|
|
- for string in self.METRIC_STRINGS:
|
|
|
- indexer.record(
|
|
|
- use_case_id=UseCaseKey.PERFORMANCE, org_id=self.organization.id, string=string
|
|
|
- )
|
|
|
- self.expected_tag_value_type = "UInt64"
|
|
|
- else:
|
|
|
- self.expected_tag_value_type = "String"
|
|
|
+ self.expected_tag_value_type = "String"
|
|
|
|
|
|
indexer.record(
|
|
|
use_case_id=UseCaseKey.PERFORMANCE, org_id=self.organization.id, string="transaction"
|
|
@@ -145,25 +136,14 @@ class MetricBuilderBaseTest(MetricsEnhancedPerformanceTestCase):
|
|
|
)
|
|
|
|
|
|
def build_transaction_transform(self, alias):
|
|
|
- if not options.get("sentry-metrics.performance.tags-values-are-strings"):
|
|
|
- tags_col = "tags"
|
|
|
- unparam = indexer.resolve(
|
|
|
- UseCaseKey.PERFORMANCE, self.organization.id, "<< unparameterized >>"
|
|
|
- )
|
|
|
- null = 0
|
|
|
- else:
|
|
|
- tags_col = "tags_raw"
|
|
|
- unparam = "<< unparameterized >>"
|
|
|
- null = ""
|
|
|
-
|
|
|
return Function(
|
|
|
"transform",
|
|
|
[
|
|
|
Column(
|
|
|
- f"{tags_col}[{indexer.resolve(UseCaseKey.PERFORMANCE, self.organization.id, 'transaction')}]"
|
|
|
+ f"tags_raw[{indexer.resolve(UseCaseKey.PERFORMANCE, self.organization.id, 'transaction')}]"
|
|
|
),
|
|
|
- [null],
|
|
|
- [unparam],
|
|
|
+ [""],
|
|
|
+ ["<< unparameterized >>"],
|
|
|
],
|
|
|
alias,
|
|
|
)
|
|
@@ -435,35 +415,6 @@ class MetricQueryBuilderTest(MetricBuilderBaseTest):
|
|
|
],
|
|
|
)
|
|
|
|
|
|
- def test_missing_transaction_index(self):
|
|
|
- if options.get("sentry-metrics.performance.tags-values-are-strings"):
|
|
|
- pytest.skip("test does not apply if tag values are in clickhouse")
|
|
|
-
|
|
|
- with pytest.raises(
|
|
|
- IncompatibleMetricsQuery,
|
|
|
- match=re.compile("Transaction value .* in filter not found"),
|
|
|
- ):
|
|
|
- MetricsQueryBuilder(
|
|
|
- self.params,
|
|
|
- query="transaction:something_else",
|
|
|
- dataset=Dataset.PerformanceMetrics,
|
|
|
- selected_columns=["transaction", "project", "p95(transaction.duration)"],
|
|
|
- )
|
|
|
-
|
|
|
- def test_missing_transaction_index_in_filter(self):
|
|
|
- if options.get("sentry-metrics.performance.tags-values-are-strings"):
|
|
|
- pytest.skip("test does not apply if tag values are in clickhouse")
|
|
|
- with pytest.raises(
|
|
|
- IncompatibleMetricsQuery,
|
|
|
- match=re.compile("Transaction value .* in filter not found"),
|
|
|
- ):
|
|
|
- MetricsQueryBuilder(
|
|
|
- self.params,
|
|
|
- query="transaction:[something_else, something_else2]",
|
|
|
- dataset=Dataset.PerformanceMetrics,
|
|
|
- selected_columns=["transaction", "project", "p95(transaction.duration)"],
|
|
|
- )
|
|
|
-
|
|
|
def test_incorrect_parameter_for_metrics(self):
|
|
|
with pytest.raises(IncompatibleMetricsQuery):
|
|
|
MetricsQueryBuilder(
|
|
@@ -1498,14 +1449,6 @@ class MetricQueryBuilderTest(MetricBuilderBaseTest):
|
|
|
|
|
|
expected = [mock.call(UseCaseKey.PERFORMANCE, self.organization.id, "transaction")]
|
|
|
|
|
|
- if not options.get("sentry-metrics.performance.tags-values-are-strings"):
|
|
|
- expected.append(
|
|
|
- mock.call(UseCaseKey.PERFORMANCE, self.organization.id, "foo_transaction")
|
|
|
- )
|
|
|
- expected.append(
|
|
|
- mock.call(UseCaseKey.PERFORMANCE, self.organization.id, "<< unparameterized >>")
|
|
|
- )
|
|
|
-
|
|
|
expected.extend(
|
|
|
[
|
|
|
mock.call(
|
|
@@ -1517,9 +1460,6 @@ class MetricQueryBuilderTest(MetricBuilderBaseTest):
|
|
|
]
|
|
|
)
|
|
|
|
|
|
- if not options.get("sentry-metrics.performance.tags-values-are-strings"):
|
|
|
- expected.append(mock.call(UseCaseKey.PERFORMANCE, self.organization.id, "good"))
|
|
|
-
|
|
|
self.assertCountEqual(mock_indexer.mock_calls, expected)
|
|
|
|
|
|
def test_custom_measurement_allowed(self):
|
|
@@ -1698,36 +1638,6 @@ class TimeseriesMetricQueryBuilderTest(MetricBuilderBaseTest):
|
|
|
],
|
|
|
)
|
|
|
|
|
|
- def test_missing_transaction_index(self):
|
|
|
- if options.get("sentry-metrics.performance.tags-values-are-strings"):
|
|
|
- pytest.skip("test does not apply if tag values are in clickhouse")
|
|
|
- with pytest.raises(
|
|
|
- IncompatibleMetricsQuery,
|
|
|
- match=re.compile("Transaction value .* in filter not found"),
|
|
|
- ):
|
|
|
- TimeseriesMetricQueryBuilder(
|
|
|
- self.params,
|
|
|
- dataset=Dataset.PerformanceMetrics,
|
|
|
- interval=900,
|
|
|
- query="transaction:something_else",
|
|
|
- selected_columns=["project", "p95(transaction.duration)"],
|
|
|
- )
|
|
|
-
|
|
|
- def test_missing_transaction_index_in_filter(self):
|
|
|
- if options.get("sentry-metrics.performance.tags-values-are-strings"):
|
|
|
- pytest.skip("test does not apply if tag values are in clickhouse")
|
|
|
- with pytest.raises(
|
|
|
- IncompatibleMetricsQuery,
|
|
|
- match=re.compile("Transaction value .* in filter not found"),
|
|
|
- ):
|
|
|
- TimeseriesMetricQueryBuilder(
|
|
|
- self.params,
|
|
|
- dataset=Dataset.PerformanceMetrics,
|
|
|
- interval=900,
|
|
|
- query="transaction:[something_else, something_else2]",
|
|
|
- selected_columns=["p95(transaction.duration)"],
|
|
|
- )
|
|
|
-
|
|
|
def test_project_filter(self):
|
|
|
query = TimeseriesMetricQueryBuilder(
|
|
|
self.params,
|