Skip to content

feat(ruby): Add feature flag support - #3108

Merged
sl0thentr0py merged 3 commits into
getsentry:masterfrom
jespersandnielsen:feat/feature_flags
Nov 4, 2026
Merged

sl0thentr0py merged 3 commits into
getsentry:masterfrom
jespersandnielsen:feat/feature_flags

Conversation

@jespersandnielsen

@jespersandnielsen jespersandnielsen commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Add Sentry.add_feature_flag and Scope#add_feature_flag to record boolean flag evaluations. Flags are kept in a 100-entry LRU buffer on the scope, attached to error events as contexts.flags.values (not transactions), and recorded on the active span as flag.evaluation.* data (max 10 per span).

Thanks for your Pull Request 🎉

Please keep these instructions in mind so we can review it more efficiently:

  • Add the references of all the related GH issues, Linear IDs or PRs in the description
  • Whether it's a new feature or a bug fix, make sure they're covered by new test cases
  • If this PR contains any refactoring work, please give it its own commit(s)
  • Finally, please add an entry to the corresponding changelog
  • PR title should use conventional commit style (feat:, fix:, ref:, meta:)

Other Notes

Description

Describe your changes:

@jespersandnielsen
jespersandnielsen marked this pull request as ready for review October 1, 2026 11:36
@jespersandnielsen jespersandnielsen changed the title feat: Add feature flag support feat(ruby): Add feature flag support Oct 29, 2026
@jespersandnielsen

Copy link
Copy Markdown
Contributor Author

@sl0thentr0py What is needed in order to merge this PR?

Add Sentry.add_feature_flag and Scope#add_feature_flag to record boolean
flag evaluations. Flags are kept in a 100-entry LRU buffer on the scope,
attached to error events as contexts.flags.values (not transactions), and
recorded on the active span as flag.evaluation.* data (max 10 per span).
@sl0thentr0py

Copy link
Copy Markdown
Member

thx @jespersandnielsen, I'll make some small changes and then merge it

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread sentry-ruby/lib/sentry/scope.rb Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 28220bc. Configure here.

def set_flag(name, result)
flag = "#{SPAN_FLAG_ATTRIBUTE_PREFIX}#{name}"
@flags[flag] = result if @flags.size < MAX_FLAGS
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Span flags skip updates at cap

Medium Severity

Once a span already holds 10 feature flags, set_flag rejects every write, including a new result for a name that is already stored. The scope buffer still keeps the latest evaluation, so error events and the active span can disagree on the same flag.evaluation.* value after a re-evaluation.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 28220bc. Configure here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

matches python behavior 🤷 agree that the logic is a bit whatever

@sl0thentr0py
sl0thentr0py merged commit 255fdf2 into getsentry:master Nov 4, 2026
155 checks passed
@jespersandnielsen
jespersandnielsen deleted the feat/feature_flags branch November 4, 2026 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for tracking feature flags

2 participants