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
dingsdax added a commit to getsentry/sentry-changelog that referenced this pull request Nov 18, 2026
Adds a changelog post for [sentry-ruby
7.3.0](https://github.com/getsentry/sentry-ruby/releases/tag/7.3.0), so
Ruby users hear about the release's new features in the changelog and in
Sentry's "What's New" panel (scoped to Ruby, Rails, and Rack orgs) and
not only in the GitHub release notes.

The post is framed around background work that fails quietly, and each
section leads with the problem it solves:

- **Know when a GoodJob cron job fails or never runs**:
`config.enabled_patches << :good_job_cron` puts every GoodJob cron entry
under Crons monitoring (getsentry/sentry-ruby#3200)
- **See which feature flags were on when an error happened**:
`Sentry.add_feature_flag` attaches flag evaluations to errors and spans
(getsentry/sentry-ruby#3108)
- **Spot jobs piling up in the queue**: ActiveJob, Sidekiq, and Resque
jobs report queue wait time and payload size for the Queues dashboard
(getsentry/sentry-ruby#3133)

It closes with `Sentry.logger` block support
(getsentry/sentry-ruby#3178), then links the full release notes. The new
job extensions API (getsentry/sentry-ruby#3129) is left out because it
only matters to people who maintain job backends. Nothing breaks.

Open decisions:
- The entry is `published: false`, so merging only creates it. To go
live, set `published: true` before merge or publish it from the admin
UI.
- `author` is left unset because I couldn't confirm which email belongs
to an existing changelog user. Add one if you want the post attributed.

<!-- junior-request-attribution:start -->
via @dingsdax.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3Ab5614f77a180622dc700158a -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/local%3Aweb%3Ab5614f77a180622dc700158a)
[[Sentry]](https://sentry.sentry.io/explore/conversations/local%3Aweb%3Ab5614f77a180622dc700158a/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: johdax <114897+dingsdax@users.noreply.github.com>
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