bugwatch-ruby 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +49 -0
- data/lib/bugwatch/db_tracker.rb +2 -0
- data/lib/bugwatch/middleware.rb +2 -0
- data/lib/bugwatch/version.rb +1 -1
- data/lib/bugwatch.rb +11 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d6a47f1c5176ec17f87160b5ab4a273e6ef68e76dee98f6e60ee5da474a61fd
|
|
4
|
+
data.tar.gz: 713ab0b06839f57c473a98c8f3e1cd46f2f43b2c9ccfef2b18d7ba0e3abb1076
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cb255c2fcfe9562b06320de183bc1ee141f394eacb327eb6ad71739a662aaeb435f5da3248404a7074b45e6a397612d86fe8d243918284196cb7e3892c193f8a
|
|
7
|
+
data.tar.gz: 9ce11bcc466b319298cb788f51cdb1c89f00f6b3126189d02c9a7838eeb6f087291bb0864bc5115734849a1af966f2995385a627a057befbf815c63354e122ee
|
data/README.md
CHANGED
|
@@ -181,6 +181,55 @@ Bugwatch.send_feedback(
|
|
|
181
181
|
)
|
|
182
182
|
```
|
|
183
183
|
|
|
184
|
+
## Database query tracking
|
|
185
|
+
|
|
186
|
+
The gem automatically subscribes to `sql.active_record` notifications and reports query performance data to your BugWatch instance. DB tracking is **enabled by default** — no extra setup required.
|
|
187
|
+
|
|
188
|
+
### Configuration
|
|
189
|
+
|
|
190
|
+
```ruby
|
|
191
|
+
# config/initializers/bugwatch.rb
|
|
192
|
+
Bugwatch.configure do |c|
|
|
193
|
+
# ... existing config ...
|
|
194
|
+
|
|
195
|
+
c.enable_db_tracking = true # default: true — set false to disable
|
|
196
|
+
c.db_sample_rate = 1.0 # 0.0–1.0 — fraction of requests to track (default: 1.0)
|
|
197
|
+
c.db_query_threshold_ms = 0 # only collect queries slower than this (default: 0 = all)
|
|
198
|
+
c.max_queries_per_request = 200 # cap per request to limit overhead (default: 200)
|
|
199
|
+
end
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
| Option | Default | Description |
|
|
203
|
+
|--------|---------|-------------|
|
|
204
|
+
| `enable_db_tracking` | `true` | Master switch for DB tracking |
|
|
205
|
+
| `db_sample_rate` | `1.0` | Fraction of requests whose queries are collected (0.0–1.0) |
|
|
206
|
+
| `db_query_threshold_ms` | `0` | Minimum query duration (ms) to collect — set higher to focus on slow queries |
|
|
207
|
+
| `max_queries_per_request` | `200` | Maximum queries stored per request |
|
|
208
|
+
|
|
209
|
+
Schema operations and transaction bookkeeping (`BEGIN`, `COMMIT`, `ROLLBACK`) are automatically excluded. SQL literals are sanitized before sending, so no user data leaves your app.
|
|
210
|
+
|
|
211
|
+
### Skipping tracking
|
|
212
|
+
|
|
213
|
+
Wrap any code block with `Bugwatch.without_tracking` to suppress all performance tracking (DB queries and transaction recording) for queries executed inside it. This is useful when BugWatch monitors itself, or for any internal bookkeeping queries you don't want tracked.
|
|
214
|
+
|
|
215
|
+
```ruby
|
|
216
|
+
Bugwatch.without_tracking do
|
|
217
|
+
SomeModel.insert_all(records) # not tracked
|
|
218
|
+
end
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
In a controller:
|
|
222
|
+
|
|
223
|
+
```ruby
|
|
224
|
+
around_action :skip_tracking
|
|
225
|
+
|
|
226
|
+
private
|
|
227
|
+
|
|
228
|
+
def skip_tracking(&block)
|
|
229
|
+
Bugwatch.without_tracking(&block)
|
|
230
|
+
end
|
|
231
|
+
```
|
|
232
|
+
|
|
184
233
|
## How it works
|
|
185
234
|
|
|
186
235
|
1. `Bugwatch::Middleware` wraps your entire Rack stack.
|
data/lib/bugwatch/db_tracker.rb
CHANGED
data/lib/bugwatch/middleware.rb
CHANGED
data/lib/bugwatch/version.rb
CHANGED
data/lib/bugwatch.rb
CHANGED
|
@@ -120,6 +120,17 @@ module Bugwatch
|
|
|
120
120
|
end
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
+
def without_tracking
|
|
124
|
+
Thread.current[:bugwatch_skip_tracking] = true
|
|
125
|
+
yield
|
|
126
|
+
ensure
|
|
127
|
+
Thread.current[:bugwatch_skip_tracking] = false
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def skip_tracking?
|
|
131
|
+
Thread.current[:bugwatch_skip_tracking] == true
|
|
132
|
+
end
|
|
133
|
+
|
|
123
134
|
def transaction_buffer
|
|
124
135
|
@transaction_buffer ||= TransactionBuffer.new(config: configuration)
|
|
125
136
|
end
|