Skip to content

perf(sdk): Add regex pattern support to traces sampler route matching#115874

Merged
obostjancic merged 2 commits into
masterfrom
ogi/ai-conversations-sampled-route-pattern
May 20, 2026
Merged

perf(sdk): Add regex pattern support to traces sampler route matching#115874
obostjancic merged 2 commits into
masterfrom
ogi/ai-conversations-sampled-route-pattern

Conversation

@obostjancic
Copy link
Copy Markdown
Member

@obostjancic obostjancic commented May 20, 2026

Adds SAMPLED_ROUTE_PATTERNS — a list of (compiled_regex, rate) tuples — as a complement to the existing exact-match SAMPLED_ROUTES dict. traces_sampler now falls through to pattern matching when no exact route matches.

Uses this to sample all hits to the ai-conversations endpoints at 100% without hardcoding a specific org slug (a previous attempt at this used /api/0/organizations/sentry/ai-conversations/ directly, which was cleaned up in #108016).

Routes covered

# urls.py
r"^(?P<organization_id_or_slug>[^/]+)/ai-conversations/$"
r"^(?P<organization_id_or_slug>[^/]+)/ai-conversations/(?P<conversation_id>[^/]+)/$"
# sdk.py
SAMPLED_ROUTE_PATTERNS: list[tuple[re.Pattern[str], float]] = [
    (re.compile(r"^/api/0/organizations/[^/]+/ai-conversations/"), 1.0),
]

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 20, 2026
@obostjancic obostjancic merged commit 0f88e7b into master May 20, 2026
83 checks passed
@obostjancic obostjancic deleted the ogi/ai-conversations-sampled-route-pattern branch May 20, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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