feat(yabeda): Add sentry-yabeda adapter gem#2925
Conversation
Introduces sentry-yabeda, a Yabeda adapter that forwards metrics to Sentry. Covers all four Yabeda metric types (counter, gauge, histogram, summary), a periodic collector to drive gauge collection in push-based environments, and a full spec suite including unit and integration tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Endless method syntax (def m() = val) requires Ruby 3.0+. Replace with conventional empty method bodies (def m; end) so RuboCop using the Ruby 2.7 parser does not reject the file. Co-Authored-By: Claude Sonnet 4.6 <noreply@example.com>
The app is configured as api_only but inherited from ActionController::Base, which includes CSRF protection middleware. Switch to ActionController::API to align with the api_only setting and eliminate the CSRF warning. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…bled Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
sl0thentr0py
left a comment
There was a problem hiding this comment.
in the current start_/stop_collector model this is not very useful. Sentry generally does things automagically so the ideal design is that users just enable/add this gem and then something happens automatically, not that they have to start and stop it wherever in their code.
The app was never referenced by any spec or CI step and carried maintenance weight (Gemfile.lock, SQLite DB, log files). The sentry-yabeda adapter is already covered by unit and integration specs in sentry-yabeda/spec/. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add sentry_yabeda_test.yml following the same pattern as other gem workflows (resque, delayed_job, opentelemetry). Wire it into tests.yml so it runs on every PR and push to master, and is included in the CodeCov notification gate. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the detailed standalone sentry-yabeda README with a minimal one matching the per-gem style used across the repo. Add sentry-yabeda to the badge table, install snippet, and integrations list in the root README. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Same badge table row, install snippet, and integrations list entry as the root README — keeps the gem-level README in sync. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove the manual start_collector!/stop_collector! API. The periodic gauge collector now starts automatically when Sentry is initialized with enable_metrics: true, via an after(:configured) hook — consistent with how other Sentry integrations wire into the SDK lifecycle. Collector follows the same initialization pattern as SessionFlusher and BackpressureMonitor, taking a configuration positional argument and calling super(configuration.sdk_logger, interval). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Collector thread leaks when re-initializing with metrics disabled
- Collector teardown is now unconditional before checking enable_metrics, and the masking spec line was removed to verify re-initialization with metrics disabled leaves no collector.
Or push these changes by commenting:
@cursor push 6bf7f66c8d
Preview (6bf7f66c8d)
diff --git a/sentry-yabeda/lib/sentry/yabeda/configuration.rb b/sentry-yabeda/lib/sentry/yabeda/configuration.rb
--- a/sentry-yabeda/lib/sentry/yabeda/configuration.rb
+++ b/sentry-yabeda/lib/sentry/yabeda/configuration.rb
@@ -3,8 +3,10 @@
module Sentry
class Configuration
after(:configured) do
+ Sentry::Yabeda.collector&.kill
+ Sentry::Yabeda.collector = nil
+
if enable_metrics
- Sentry::Yabeda.collector&.kill
Sentry::Yabeda.collector = Sentry::Yabeda::Collector.new(self)
end
end
diff --git a/sentry-yabeda/spec/sentry/yabeda/collector_spec.rb b/sentry-yabeda/spec/sentry/yabeda/collector_spec.rb
--- a/sentry-yabeda/spec/sentry/yabeda/collector_spec.rb
+++ b/sentry-yabeda/spec/sentry/yabeda/collector_spec.rb
@@ -28,7 +28,6 @@
it "does not start when enable_metrics is false" do
Sentry.close
- Sentry::Yabeda.collector = nil
Sentry.init do |config|
config.dsn = DUMMY_DSNThis Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 855c165. Configure here.
| Sentry::Yabeda.collector&.kill | ||
| Sentry::Yabeda.collector = Sentry::Yabeda::Collector.new(self) | ||
| end | ||
| end |
There was a problem hiding this comment.
Collector thread leaks when re-initializing with metrics disabled
Medium Severity
The Sentry::Yabeda.collector&.kill call is inside the if enable_metrics guard, so when Sentry is re-initialized with enable_metrics = false, any previously running collector thread is never killed and leaks. The kill and nil-assignment need to happen unconditionally, before deciding whether to create a new collector. The corresponding test masks this bug by manually setting Sentry::Yabeda.collector = nil before re-initialization.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 855c165. Configure here.
There was a problem hiding this comment.
for completeness and ensuring no data loss on shutdown, we need:
- a final flush/collect during
close - for this, since this is coming from another gem, we need another callback called
:closedregistered from the gem and callflushthere - move the
killin the:configuredcallback to this new:closedcallback



Sentry Ruby gem that connects Yabeda metrics to Sentry Metrics.
What it does
counter➡️Sentry.metrics.countgauge➡️Sentry.metrics.gaugehistogram/summary➡️Sentry.metrics.distributionYabeda.collect!(needed because Yabeda is pull-based, while Sentry is push-based).
start_collector!andstop_collector!to control this worker (must run afterSentry.init).Fixes RUBY-161
Fixes #2899