Skip to content

Commit dda75a4

Browse files
k-fishpriscilawebdev
authored andcommitted
fix(tracemetrics): Fix denylist keys (#102157)
This way you we can actually fix denylist keys based on their final value, not an intermediate value you have to look up s.
1 parent 79d1ebf commit dda75a4

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/sentry/metrics/sentry_sdk.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def incr(
3636
unit: str | None = None,
3737
stacklevel: int = 0,
3838
) -> None:
39-
if not self._should_send(key):
39+
full_key = self._get_key(key)
40+
if not self._should_send(full_key):
4041
return
4142

4243
if not self._should_sample(sample_rate):
@@ -47,7 +48,7 @@ def incr(
4748
metric_attributes["instance"] = instance
4849

4950
metrics.count(
50-
self._get_key(key),
51+
full_key,
5152
amount,
5253
unit=unit,
5354
attributes=metric_attributes,
@@ -74,7 +75,8 @@ def gauge(
7475
unit: str | None = None,
7576
stacklevel: int = 0,
7677
) -> None:
77-
if not self._should_send(key):
78+
full_key = self._get_key(key)
79+
if not self._should_send(full_key):
7880
return
7981

8082
if not self._should_sample(sample_rate):
@@ -85,7 +87,7 @@ def gauge(
8587
metric_attributes["instance"] = instance
8688

8789
metrics.gauge(
88-
self._get_key(key),
90+
full_key,
8991
value,
9092
unit=unit,
9193
attributes=metric_attributes,
@@ -101,7 +103,8 @@ def distribution(
101103
unit: str | None = None,
102104
stacklevel: int = 0,
103105
) -> None:
104-
if not self._should_send(key):
106+
full_key = self._get_key(key)
107+
if not self._should_send(full_key):
105108
return
106109

107110
if not self._should_sample(sample_rate):
@@ -112,7 +115,7 @@ def distribution(
112115
metric_attributes["instance"] = instance
113116

114117
metrics.distribution(
115-
self._get_key(key),
118+
full_key,
116119
value,
117120
unit=unit,
118121
attributes=metric_attributes,

tests/sentry/metrics/test_dualwrite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_dualwrite_experimental_backend(dogstatsd_incr, sentry_sdk_incr):
4242
backend = DualWriteMetricsBackend(
4343
primary_backend="sentry.metrics.dogstatsd.DogStatsdMetricsBackend",
4444
experimental_backend="sentry.metrics.sentry_sdk.SentrySDKMetricsBackend",
45-
experimental_args={"deny_list": ["denied"], "experimental_sample_rate": 1.0},
45+
experimental_args={"deny_list": ["sentry.denied"], "experimental_sample_rate": 1.0},
4646
)
4747

4848
backend.incr("allowed", tags={"test": "tag"}, unit="none")

tests/sentry/metrics/test_sentry_sdk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_incr_sampling(self, mock_count):
8585
@mock.patch("sentry_sdk._metrics.count")
8686
def test_incr_deny_list(self, mock_count):
8787
backend = SentrySDKMetricsBackend(
88-
prefix="test.", experimental_sample_rate=1.0, deny_list=["denied"]
88+
prefix="test.", experimental_sample_rate=1.0, deny_list=["test.denied"]
8989
)
9090
backend.incr("denied.metric", amount=1)
9191
mock_count.assert_not_called()

0 commit comments

Comments
 (0)