Skip to content

Commit 07f2b75

Browse files
vgrozdanicpriscilawebdev
authored andcommitted
chore(metrics) Capture a message when trying to query metrics with different namespaces (#73934)
Capture a sentry message when querying error occurs. I have chosen to capture message instead of sending a metric, because we are deprecating metrics API and it would be bad practice to continue using it. Temporally closes: #73928
1 parent 3d68492 commit 07f2b75

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/sentry/sentry_metrics/querying/visitors/query_expression.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from collections.abc import Sequence
22
from typing import Any
33

4+
import sentry_sdk
45
from snuba_sdk import AliasedExpression, Column, Condition, Formula, Op, Timeseries
56
from snuba_sdk.conditions import ConditionGroup
67

@@ -126,6 +127,12 @@ def _visit_timeseries(self, timeseries: Timeseries) -> QueryExpression:
126127
if self._query_namespace is None:
127128
self._query_namespace = namespace
128129
elif self._query_namespace != namespace:
130+
with sentry_sdk.isolation_scope() as scope:
131+
scope.set_extra("query_namespace", self._query_namespace)
132+
scope.set_extra("namespace", namespace)
133+
sentry_sdk.capture_message(
134+
"Querying metrics belonging to different namespaces is not allowed"
135+
)
129136
raise InvalidMetricsQueryError(
130137
"Querying metrics belonging to different namespaces is not allowed"
131138
)

0 commit comments

Comments
 (0)