Skip to content

feat(dynamic-sampling): add is_segment filter for span metrics in boost_low_volume_projects#106954

Merged
shellmayr merged 7 commits intomasterfrom
shellmayr/feat/ds-boost-low-volume-projects-span-metric
Jan 28, 2026
Merged

feat(dynamic-sampling): add is_segment filter for span metrics in boost_low_volume_projects#106954
shellmayr merged 7 commits intomasterfrom
shellmayr/feat/ds-boost-low-volume-projects-span-metric

Conversation

@shellmayr
Copy link
Member

@shellmayr shellmayr commented Jan 26, 2026

Add support for querying span metrics in boost_low_volume_projects by:

  • Introduces new measure SEGMENTS in addition to SPANS and TRANSACTIONS. This is done primarily to differentiate between spans and segments - spans should continue to be used for the queries for DS on AM3
  • Using dynamic use_case_id (SPANS vs TRANSACTIONS) based on the measure

Closes TET-1679

…st_low_volume_projects

Add support for querying span metrics in boost_low_volume_projects by:
- Adding is_segment filter when using SamplingMeasure.SPANS to only count root spans
- Using dynamic use_case_id (SPANS vs TRANSACTIONS) based on the measure

This allows the task to correctly query span-based metrics that include the is_segment tag
to identify root spans.
@linear
Copy link

linear bot commented Jan 26, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 26, 2026
…st_low_volume_projects

Add support for querying span metrics in boost_low_volume_projects by:
- Adding is_segment filter when using SamplingMeasure.SPANS to only count root spans
- Using dynamic use_case_id (SPANS vs TRANSACTIONS) based on the measure

This allows the task to correctly query span-based metrics that include the is_segment tag
to identify root spans.
@shellmayr shellmayr marked this pull request as ready for review January 27, 2026 14:29
@shellmayr shellmayr requested a review from a team as a code owner January 27, 2026 14:29

SPANS = "spans"
TRANSACTIONS = "transactions"
SEGMENTS = "segments"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The new SamplingMeasure.SEGMENTS enum is defined and configured, but no production code path can ever select it, rendering the feature non-functional.
Severity: MEDIUM

Suggested Fix

Modify the partition_by_measure() function to correctly return SamplingMeasure.SEGMENTS for organizations that should be using this measure. This likely involves adding a new option, such as "dynamic-sampling.measure.segments", and checking for it within the function to route organizations to the new SEGMENTS logic.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/sentry/dynamic_sampling/types.py#L27

Potential issue: The code introduces a new `SamplingMeasure.SEGMENTS` enum member and
its configuration in `MEASURE_CONFIGS` to allow counting spans with the
`is_segment=true` tag. However, the `partition_by_measure()` function, which determines
the sampling measure for an organization, is never updated to return
`SamplingMeasure.SEGMENTS`. It only checks for the `"dynamic-sampling.measure.spans"`
option and returns `SamplingMeasure.SPANS`. As a result, the new logic for counting
segments is never executed in production, and the system will continue to count all
spans instead of just segments. This makes the feature incomplete and non-functional.

Did we get this right? 👍 / 👎 to inform future reviews.

@shellmayr shellmayr merged commit bd5c47f into master Jan 28, 2026
66 checks passed
@shellmayr shellmayr deleted the shellmayr/feat/ds-boost-low-volume-projects-span-metric branch January 28, 2026 10:24
priscilawebdev pushed a commit that referenced this pull request Feb 2, 2026
…st_low_volume_projects (#106954)

Add support for querying span metrics in boost_low_volume_projects by:
- Introduces new measure SEGMENTS in addition to SPANS and TRANSACTIONS.
This is done primarily to differentiate between spans and segments -
spans should continue to be used for the queries for DS on AM3
- Using dynamic use_case_id (SPANS vs TRANSACTIONS) based on the measure
@github-actions github-actions bot locked and limited conversation to collaborators Feb 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants