Skip to content

Reproduction for sentry-ruby#2842#1

Merged
sl0thentr0py merged 1 commit intomainfrom
repro/sentry-ruby-2842
Feb 24, 2026
Merged

Reproduction for sentry-ruby#2842#1
sl0thentr0py merged 1 commit intomainfrom
repro/sentry-ruby-2842

Conversation

@sl0thentr0py
Copy link
Member

Summary

  • Reproduces issue where Sentry.metrics.count doesn't emit user attributes (user.id, user.email) even when Sentry.set_user has been called
  • Minimal Rails 8 app that sets user info in ApplicationController and emits a metric in TestController
  • Demonstrates that user info IS present in the Sentry scope but NOT included in metrics

Issue: getsentry/sentry-ruby#2842

Test plan

  • Run bundle install in sentry-ruby/2842/
  • Set SENTRY_DSN environment variable
  • Run bundle exec rails server
  • Visit http://localhost:3000/test
  • Verify user info is logged to console
  • Check Sentry dashboard to confirm metric lacks user attributes

🤖 Generated with Claude Code

config.load_defaults 8.0
config.eager_load = false
config.secret_key_base = "test_secret_key_base_for_reproduction"
end
Copy link

Choose a reason for hiding this comment

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

Hardcoded Rails secret key base

Medium Severity

config.secret_key_base is hardcoded in config/application.rb, which risks leaking a valid secret into version control. If this app is ever run beyond a purely local repro (or copied as a template), sessions/cookies and other signed data can become forgeable.

Fix in Cursor Fix in Web

Demonstrates that Sentry.metrics.count does not emit user attributes
(user.id, user.email) even when Sentry.set_user has been called and
the user information is present in the scope.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sl0thentr0py sl0thentr0py force-pushed the repro/sentry-ruby-2842 branch from 2cfe13e to 05ce3e0 Compare February 24, 2026 12:09
@sl0thentr0py sl0thentr0py merged commit ed10e2d into main Feb 24, 2026
4 of 5 checks passed
@sl0thentr0py sl0thentr0py deleted the repro/sentry-ruby-2842 branch February 24, 2026 12:10
Copy link

@cursor cursor bot left a comment

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.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

config.before_send_metric = lambda do |event|
puts "[Sentry] Sending event: #{event.to_h}"
event
end
Copy link

Choose a reason for hiding this comment

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

Callback may crash and silently drop metrics

Medium Severity

The before_send_metric callback calls event.to_h on the metric object, but the MetricEvent type received by this callback is not a documented subclass of Sentry::Event (which defines to_h). Its documented interface only exposes name, attributes, span_id, trace_id, and timestamp. If to_h is not defined on this object, the callback raises NoMethodError, which sentry-ruby catches internally and silently drops the metric — making the reproduction appear as if no metric was sent at all, rather than demonstrating the actual user-attributes-missing issue.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants