Skip to content

Commit

Permalink
fix(dynamic-sampling): add missing targetSampleRate to DetailedOrgani…
Browse files Browse the repository at this point in the history
…zationSerializer
  • Loading branch information
constantinius committed Oct 17, 2024
1 parent fcece96 commit 8bf6166
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/sentry/api/serializers/models/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
SAFE_FIELDS_DEFAULT,
SCRAPE_JAVASCRIPT_DEFAULT,
SENSITIVE_FIELDS_DEFAULT,
TARGET_SAMPLE_RATE_DEFAULT,
UPTIME_AUTODETECTION,
ObjectStatus,
)
Expand Down Expand Up @@ -612,6 +613,11 @@ def serialize( # type: ignore[explicit-override, override]
obj.get_option("sentry:uptime_autodetection", UPTIME_AUTODETECTION)
)

if features.has("organizations:dynamic-sampling-custom", obj, actor=user):
context["targetSampleRate"] = float(
obj.get_option("sentry:target_sample_rate", TARGET_SAMPLE_RATE_DEFAULT)
)

trusted_relays_raw = obj.get_option("sentry:trusted-relays") or []
# serialize trusted relays info into their external form
context["trustedRelays"] = [TrustedRelaySerializer(raw).data for raw in trusted_relays_raw]
Expand Down
5 changes: 5 additions & 0 deletions tests/sentry/api/endpoints/test_organization_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ def test_is_dynamically_sampled(self):
assert not response.data["isDynamicallySampled"]
assert "planSampleRate" not in response.data

def test_dynamic_sampling_custom_target_sample_rate(self):
with self.feature({"organizations:dynamic-sampling-custom": True}):
response = self.get_success_response(self.organization.slug)
assert response.data["targetSampleRate"] == 1.0

def test_sensitive_fields_too_long(self):
value = 1000 * ["0123456789"] + ["1"]
resp = self.get_response(self.organization.slug, method="put", sensitiveFields=value)
Expand Down

0 comments on commit 8bf6166

Please sign in to comment.