Skip to content

Commit 7796c1f

Browse files
dingsdaxclaude
andauthored
docs(ruby): Add Yabeda integration guide (#17732)
## DESCRIBE YOUR PR Add a docs page for `sentry-yabeda`, the Yabeda adapter gem that bridges Yabeda metrics to Sentry Application Metrics. The `sentry-yabeda` gem is being added to the Ruby SDK in [getsentry/sentry-ruby#2925](getsentry/sentry-ruby#2925). This page documents the integration for end users. - Installation and configuration - Metric type mapping (counter, gauge, histogram, summary) - Usage with Yabeda plugins (puma, gc, activerecord) - Pull-based vs push-based collection and the periodic collector - Defining custom metrics - When to use Yabeda vs direct `Sentry.metrics.*` calls - Scaling considerations for high-volume use cases ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 88de69b commit 7796c1f

3 files changed

Lines changed: 134 additions & 0 deletions

File tree

docs/platforms/ruby/common/integrations/index.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Simply add the relevant gems to your Gemfile and run `bundle install` to install
2222
| <LinkWithPlatformIcon platform="ruby.delayed_job" label="Delayed Job" url="/platforms/ruby/guides/delayed_job/" /> | `gem "sentry-delayed_job"` |
2323
| <LinkWithPlatformIcon platform="ruby.resque" label="Resque" url="/platforms/ruby/guides/resque" /> | `gem "sentry-resque"` |
2424
| <LinkWithPlatformIcon platform="ruby.opentelemetry" label="OpenTelemetry" url="/platforms/ruby/tracing/instrumentation/opentelemetry" /> | `gem "sentry-opentelemetry"` |
25+
| <LinkWithPlatformIcon platform="ruby" label="Yabeda" url="/platforms/ruby/integrations/yabeda" /> | `gem "sentry-yabeda"` |
2526

2627
## Patches
2728

@@ -71,6 +72,10 @@ The OpenTelemetry integration is used for exporting spans instrumented by an Ope
7172

7273
The [OTLP integration](/platforms/ruby/integrations/otlp/) configures the Sentry SDK to automatically send trace data instrumented by an OpenTelemetry SDK to Sentry via the OpenTelemetry Protocol (OTLP). This is the recommended approach for sending OpenTelemetry traces to Sentry.
7374

75+
### Yabeda
76+
77+
The [Yabeda integration](/platforms/ruby/integrations/yabeda/) connects [Yabeda](https://github.com/yabeda-rb/yabeda) to Sentry's [Application Metrics](/platforms/ruby/metrics/), forwarding any metrics defined with Yabeda or collected by Yabeda plugins to Sentry automatically.
78+
7479
### HTTP Requests
7580

7681
Outgoing HTTP Requests are instrumented as Spans by the `:http` (for requests done with `Net::HTTP`) and `:faraday` patches.
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
title: Yabeda
3+
description: "Send Yabeda metrics to Sentry using the sentry-yabeda adapter gem."
4+
---
5+
6+
The `sentry-yabeda` gem is a Yabeda adapter that connects [Yabeda](https://github.com/yabeda-rb/yabeda) to Sentry's [Application Metrics](/platforms/ruby/metrics/). Any metric you define with Yabeda, or that a Yabeda plugin collects, automatically forwards to Sentry with no changes to plugin code.
7+
8+
This is especially useful when you already have Yabeda plugins collecting process-level runtime data (GC pressure, thread pool utilization, connection pool stats) that tracing alone can't capture.
9+
10+
## Install
11+
12+
Add the gems to your `Gemfile`:
13+
14+
```ruby
15+
gem "sentry-ruby"
16+
gem "sentry-yabeda"
17+
```
18+
19+
Then run:
20+
21+
```bash
22+
bundle install
23+
```
24+
25+
## Configure
26+
27+
Initialize Sentry with metrics enabled. The Yabeda adapter registers itself automatically when `sentry-yabeda` is required — there's no extra setup:
28+
29+
```ruby
30+
Sentry.init do |config|
31+
config.dsn = ENV["SENTRY_DSN"]
32+
config.enable_metrics = true
33+
end
34+
```
35+
36+
All Yabeda metrics now flow to Sentry.
37+
38+
## Metric Type Mapping
39+
40+
Yabeda metric types translate to Sentry as follows:
41+
42+
| Yabeda type | Sentry method | Notes |
43+
| ----------- | ----------------------------- | -------------------------- |
44+
| `counter` | `Sentry.metrics.count` | |
45+
| `gauge` | `Sentry.metrics.gauge` | |
46+
| `histogram` | `Sentry.metrics.distribution` | |
47+
| `summary` | `Sentry.metrics.distribution` | Sentry has no summary type |
48+
49+
Metric names combine the Yabeda group and name with a dot separator. A counter named `orders_created` in group `myapp` becomes `myapp.orders_created` in Sentry.
50+
51+
Tags are passed through as metric attributes.
52+
53+
## Usage With Yabeda Plugins
54+
55+
Yabeda has a rich plugin ecosystem. Some examples that work well with Sentry:
56+
57+
| Plugin | What it captures |
58+
| ----------------------------------------------------------------------- | ----------------------------------------- |
59+
| [yabeda-puma-plugin](https://github.com/yabeda-rb/yabeda-puma-plugin) | Thread pool utilization, backlog, workers |
60+
| [yabeda-gc](https://github.com/ianks/yabeda-gc) | GC pause time, heap stats |
61+
| [yabeda-activerecord](https://github.com/yabeda-rb/yabeda-activerecord) | Connection pool size, busy/idle/waiting |
62+
63+
Add the plugin gems and they'll start forwarding metrics to Sentry immediately.
64+
65+
### Pull-Based vs Push-Based Collection
66+
67+
Some Yabeda plugins use `collect` blocks to gather metrics. This is a pull-based pattern designed for Prometheus, where a scrape request triggers collection. Since Sentry is push-based, `sentry-yabeda` runs a background thread that calls `Yabeda.collect!` every 15 seconds to drive these plugins.
68+
69+
This collector starts automatically when `enable_metrics` is `true`. Event-driven metrics (counters, histograms) flow to Sentry immediately — only pull-based gauges (like GC stats or Puma thread pool metrics) depend on the collector.
70+
71+
<Alert>
72+
73+
Metrics collected by the background thread won't carry trace context since they aren't tied to a specific request.
74+
75+
</Alert>
76+
77+
### Puma Configuration
78+
79+
If you're using `yabeda-puma-plugin`, enable the Puma control app so the plugin can fetch thread and backlog stats:
80+
81+
```ruby
82+
# config/puma.rb
83+
activate_control_app "unix://tmp/pumactl.sock", no_token: true
84+
plugin :yabeda
85+
```
86+
87+
## Defining Custom Metrics
88+
89+
You can define your own metrics with Yabeda and they'll automatically appear in Sentry:
90+
91+
```ruby
92+
Yabeda.configure do
93+
group :myapp do
94+
counter :orders_created, comment: "Orders placed", tags: %i[region]
95+
gauge :queue_depth, comment: "Jobs waiting", tags: %i[queue_name]
96+
histogram :response_time, comment: "Response time", unit: :milliseconds, tags: %i[controller]
97+
end
98+
end
99+
```
100+
101+
Then use them in your application code:
102+
103+
```ruby
104+
Yabeda.myapp.orders_created.increment({ region: "us-east" })
105+
Yabeda.myapp.queue_depth.set({ queue_name: "default" }, 42)
106+
Yabeda.myapp.response_time.measure({ controller: "orders" }, 150.5)
107+
```
108+
109+
## When to Use Yabeda vs. Direct Sentry Metrics
110+
111+
Use **Yabeda** when:
112+
113+
- You already have Yabeda plugins in your stack and want their data in Sentry.
114+
- You want vendor-neutral metric definitions that can target multiple adapters (Sentry, Prometheus, Datadog) simultaneously.
115+
116+
Use **direct `Sentry.metrics.*` calls** when:
117+
118+
- You're tracking a one-off business event and don't need a full metrics framework.
119+
- You want trace-correlated metrics tied to specific transactions.
120+
121+
Both approaches can coexist in the same application.
122+
123+
## Scaling Considerations
124+
125+
Routing Yabeda metrics to Sentry works well for application-level data: business events, runtime diagnostics, and the kind of process-level gauges the plugins above collect. Sentry stores a row per metric event, so tracking anything from a handful of custom counters up to a moderate volume of plugin gauges is absolutely viable.
126+
127+
At very high collection volumes (think: hundreds of nodes in a Kubernetes cluster each emitting per-second metrics), tools like Prometheus that pre-aggregate and compact data are purpose-built for that scale.

docs/platforms/ruby/common/metrics/index.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Sentry metrics help you pinpoint and solve issues that impact user experience an
1313

1414
Once in Sentry, these metrics can be viewed alongside relevant errors, and searched using their individual attributes.
1515

16+
If you already use [Yabeda](https://github.com/yabeda-rb/yabeda) for metrics collection, the [Yabeda integration](/platforms/ruby/integrations/yabeda/) can forward all Yabeda metrics to Sentry automatically.
17+
1618
## Requirements
1719

1820
<PlatformContent includePath="metrics/requirements" />

0 commit comments

Comments
 (0)