Skip to content

ref(utils): Various clarifications in SafeRolloutComparator code#115946

Merged
lobsterkatie merged 19 commits into
masterfrom
kmclb-clarify-language-in-SafeRolloutComparator-code
May 26, 2026
Merged

ref(utils): Various clarifications in SafeRolloutComparator code#115946
lobsterkatie merged 19 commits into
masterfrom
kmclb-clarify-language-in-SafeRolloutComparator-code

Conversation

@lobsterkatie
Copy link
Copy Markdown
Member

@lobsterkatie lobsterkatie commented May 20, 2026

This makes some clarifying changes to the SafeRolloutComparator utility, based on my experience getting oriented to using it. No behavioral changes.

  • Rename the internal option-name-generation methods to make it clearer a) that "eval" means "run the experimental code" and b) what is being block- or allowlisted per callsite (either running the experiment or using the results of the experiment).
  • Expand the example code in the docstring.
  • Tweak docstrings and comments for various methods.
  • Rename a few other variables.
  • Remove TODOs about creating a dashboard, since that's been done.
  • Consolidate imports.
  • Create constants for option names in tests, just to cut down on verbosity.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 20, 2026
@lobsterkatie lobsterkatie added the Trigger: Override Selective Testing Run the full test suite; necessary in cases where selected tests are flaky due to reshuffling label May 20, 2026
@lobsterkatie lobsterkatie force-pushed the kmclb-clarify-language-in-SafeRolloutComparator-code branch from 96d8e03 to eb960be Compare May 20, 2026 20:39
3. Start rolling out the "evaluate experimental branch" option.
4. Monitor correctness through standard dashboard. (TODO @cpaul: build dashboard)
5. Start adding known-good callsites to the "use experimental branch" allowlist.
1. Set up your `SafeRolloutComparator` subclass (in Sentry) & options (in options automator).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How do we handle referencing internal repos (like options automator) in open-source repos?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Their existence isn't a secret - we talk about the automator here, here, and here, for example, and getsentry here, here, and here.

Comment thread src/sentry/utils/rollout.py Outdated
4. Monitor correctness through standard dashboard. (TODO @cpaul: build dashboard)
5. Start adding known-good callsites to the "use experimental branch" allowlist.
1. Set up your `SafeRolloutComparator` subclass (in Sentry) & options (in options automator).
2. Add code like that below your first callsite. (Further callsites can be added at any time.)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"Add code like that" — what does this mean?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Meant to be "code like that [that you can find] below," but I get how it can be read ambiguously. Changed to Use the comparator in your first callsite (see example below)..

Comment thread src/sentry/utils/rollout.py Outdated
1. Set up your `SafeRolloutComparator` subclass (in Sentry) & options (in options automator).
2. Add code like that below your first callsite. (Further callsites can be added at any time.)
3. Start rolling out the experiment by switching the "should run experiment" option to True
and increasing the sample rate option.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"increasing" is wrong here — default sample rate is 1.0 ==> 100%, so folks can OPTIONALLY set the sample rate option but don't have to.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, right. Good catch. Changed to Start rolling out the experiment by switching the "should run experiment" option to True and, if you've set a sample rate option, increasing the sample rate. (If not set, the sample rate defaults to 100%.)

Comment thread src/sentry/utils/rollout.py Outdated
and increasing the sample rate option.
4. Monitor correctness using the metrics and optional mismatch logs emitted when the
experimental branch is run.
5. Start adding known-good callsites to the "use new data" allowlist.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The method is called should_use_experimental_data but the allowlist uses new — IMO we should unify on experimental vs new.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Used new for length reasons, but can switch it back to experimental.

use_experimental_data: bool,
is_exact_match: bool,
is_reasonable_match: bool | None,
is_experimental_data_nullish: bool | None,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: I'd keep as null_result to keep consistency with what we're sending to DataDog.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I left all of the DD and logging labels alone so as not to break existing dashboards, etc, but I like "nullish" because is sort of the equivalent of "falsy" - an empty list isn't the same as an actual None, for example, the same way an empty string isn't the same as False.

experimental_data: TData,
callsite: str,
is_experimental_data_a_null_result: bool | None = None,
is_experimental_data_nullish: bool | None = None,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See above re: nullish

Comment on lines +344 to +345
control_data_func: Callable[[], TData],
experimental_data_func: Callable[[], TData],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: I like thunk. Will let you choose though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's a neat word, just not sure how widely understood it's going to be.

@lobsterkatie lobsterkatie force-pushed the kmclb-clarify-language-in-SafeRolloutComparator-code branch from eb960be to 2f4f867 Compare May 21, 2026 21:29
@lobsterkatie lobsterkatie marked this pull request as ready for review May 26, 2026 17:32
@lobsterkatie lobsterkatie requested review from a team as code owners May 26, 2026 17:32
@lobsterkatie lobsterkatie requested review from a team as code owners May 26, 2026 17:32
@lobsterkatie lobsterkatie merged commit 9d49bb6 into master May 26, 2026
115 of 117 checks passed
@lobsterkatie lobsterkatie deleted the kmclb-clarify-language-in-SafeRolloutComparator-code branch May 26, 2026 17:32
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 Trigger: Override Selective Testing Run the full test suite; necessary in cases where selected tests are flaky due to reshuffling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants