diff --git a/src/sentry/search/events/datasets/spans_metrics.py b/src/sentry/search/events/datasets/spans_metrics.py index 50f41e4be6b4a3..37a0aa5eeafb54 100644 --- a/src/sentry/search/events/datasets/spans_metrics.py +++ b/src/sentry/search/events/datasets/spans_metrics.py @@ -27,7 +27,10 @@ class Args(TypedDict): class SpansMetricsDatasetConfig(DatasetConfig): missing_function_error = IncompatibleMetricsQuery - nullable_metrics = {constants.SPAN_MESSAGING_LATENCY} + nullable_metrics = { + constants.SPAN_MESSAGING_LATENCY, + constants.SPAN_METRICS_MAP["cache.item_size"], + } def __init__(self, builder: spans_metrics.SpansMetricsQueryBuilder): self.builder = builder diff --git a/tests/snuba/api/endpoints/test_organization_events_span_metrics.py b/tests/snuba/api/endpoints/test_organization_events_span_metrics.py index 96d13a97d5c921..b1a20dd2845adb 100644 --- a/tests/snuba/api/endpoints/test_organization_events_span_metrics.py +++ b/tests/snuba/api/endpoints/test_organization_events_span_metrics.py @@ -1741,6 +1741,37 @@ def test_messaging_does_not_exist_as_metric(self): meta = response.data["meta"] assert meta["fields"]["avg(messaging.message.receive.latency)"] == "null" + def test_cache_item_size_does_not_exist_as_metric(self): + self.store_span_metric( + 100, + internal_metric=constants.SPAN_METRICS_MAP["span.duration"], + tags={"cache.item": "true"}, + timestamp=self.min_ago, + ) + response = self.do_request( + { + "field": [ + "avg(cache.item_size)", + "avg(span.duration)", + ], + "query": "", + "project": self.project.id, + "dataset": "spansMetrics", + "statsPeriod": "1h", + } + ) + + assert response.status_code == 200, response.content + data = response.data["data"] + assert data == [ + { + "avg(cache.item_size)": None, + "avg(span.duration)": 100, + }, + ] + meta = response.data["meta"] + assert meta["fields"]["avg(cache.item_size)"] == "null" + def test_trace_status_rate(self): self.store_span_metric( 1,