|
@@ -1301,6 +1301,74 @@ class PerformanceMetricsLayerTestCase(BaseMetricsLayerTestCase, TestCase):
|
|
|
key=lambda elem: elem["name"],
|
|
|
)
|
|
|
|
|
|
+ def test_transform_null_to_unparameterized_with_filter(self):
|
|
|
+ for transaction, value in ((None, 0), ("/foo", 1), ("/bar", 2)):
|
|
|
+ self.store_performance_metric(
|
|
|
+ type="distribution",
|
|
|
+ name=TransactionMRI.DURATION.value,
|
|
|
+ tags={} if transaction is None else {"transaction": transaction},
|
|
|
+ value=value,
|
|
|
+ )
|
|
|
+
|
|
|
+ metrics_query = self.build_metrics_query(
|
|
|
+ before_now="1h",
|
|
|
+ granularity="1h",
|
|
|
+ select=[
|
|
|
+ MetricField(
|
|
|
+ op="count", metric_mri=TransactionMRI.DURATION.value, alias="duration_count"
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ where=[
|
|
|
+ MetricConditionField(
|
|
|
+ lhs=MetricField(
|
|
|
+ op="transform_null_to_unparameterized",
|
|
|
+ metric_mri="d:transactions/duration@millisecond",
|
|
|
+ params={"tag_key": "transaction"},
|
|
|
+ alias="transaction",
|
|
|
+ ),
|
|
|
+ op=Op.NEQ,
|
|
|
+ rhs="<< unparameterized >>",
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ limit=Limit(limit=50),
|
|
|
+ offset=Offset(offset=0),
|
|
|
+ groupby=[
|
|
|
+ MetricGroupByField(
|
|
|
+ field=MetricField(
|
|
|
+ op="transform_null_to_unparameterized",
|
|
|
+ metric_mri=TransactionMRI.DURATION.value,
|
|
|
+ params={"tag_key": "transaction"},
|
|
|
+ alias="transformed_transaction",
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ include_series=False,
|
|
|
+ )
|
|
|
+ data = get_series(
|
|
|
+ [self.project],
|
|
|
+ metrics_query=metrics_query,
|
|
|
+ include_meta=True,
|
|
|
+ use_case_id=UseCaseKey.PERFORMANCE,
|
|
|
+ )
|
|
|
+
|
|
|
+ assert sorted(data["groups"], key=lambda group: group["by"]["transformed_transaction"]) == [
|
|
|
+ {
|
|
|
+ "by": {"transformed_transaction": "/bar"},
|
|
|
+ "totals": {"duration_count": 1},
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "by": {"transformed_transaction": "/foo"},
|
|
|
+ "totals": {"duration_count": 1},
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ assert data["meta"] == sorted(
|
|
|
+ [
|
|
|
+ {"name": "duration_count", "type": "UInt64"},
|
|
|
+ {"name": "transformed_transaction", "type": "string"},
|
|
|
+ ],
|
|
|
+ key=lambda elem: elem["name"],
|
|
|
+ )
|
|
|
+
|
|
|
def test_transform_null_to_unparameterized_with_null_and_unparameterized_transactions(self):
|
|
|
for transaction, value in ((None, 0), ("<< unparameterized >>", 1)):
|
|
|
self.store_performance_metric(
|