Skip to content

Commit

Permalink
feat(dynamic-sampling): return no org sample rates in project mode in…
Browse files Browse the repository at this point in the history
… OrganizationDetails endpoint (#81726)
  • Loading branch information
shellmayr authored Dec 6, 2024
1 parent cb5bd49 commit 1fd4fe8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/sentry/api/serializers/models/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,13 @@ def serialize( # type: ignore[explicit-override, override]
if sample_rate is not None:
context["planSampleRate"] = sample_rate

desired_sample_rate, _ = get_org_sample_rate(org_id=obj.id, default_sample_rate=sample_rate)
if is_project_mode_sampling(obj):
desired_sample_rate = None
else:
desired_sample_rate, _ = get_org_sample_rate(
org_id=obj.id, default_sample_rate=sample_rate
)

if desired_sample_rate is not None:
context["desiredSampleRate"] = desired_sample_rate

Expand Down
4 changes: 4 additions & 0 deletions tests/sentry/api/endpoints/test_organization_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ def test_is_dynamically_sampled_org_option(self):
with self.feature({"organizations:dynamic-sampling-custom": True}):
response = self.get_success_response(self.organization.slug)
assert response.data["isDynamicallySampled"]
assert "planSampleRate" in response.data
assert "desiredSampleRate" in response.data

self.organization.update_option(
"sentry:sampling_mode", DynamicSamplingMode.ORGANIZATION.value
Expand All @@ -365,6 +367,8 @@ def test_is_dynamically_sampled_proj_option(self):
with self.feature({"organizations:dynamic-sampling-custom": True}):
response = self.get_success_response(self.organization.slug)
assert response.data["isDynamicallySampled"]
assert "planSampleRate" not in response.data
assert "desiredSampleRate" not in response.data

def test_dynamic_sampling_custom_target_sample_rate(self):
with self.feature({"organizations:dynamic-sampling-custom": True}):
Expand Down

0 comments on commit 1fd4fe8

Please sign in to comment.