dead_bro 0.2.16 → 0.2.17
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/CHANGELOG.md +5 -0
- data/lib/dead_bro/version.rb +1 -1
- data/lib/dead_bro.rb +55 -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: 0e9e839180ccf5281f99f831a4d437bdadd74a835c7e8f80fe321efb8bb1c9f7
|
|
4
|
+
data.tar.gz: c85de05b244a13bac3a2786624bd67f2f18d3b08c3ab3bcaa511857f8c276b90
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 87c69d57f3c712fc993663e4f8df46ad49ec584f0ccdd3f5f1a6c5eededbc8a9542f2b0d4cee446fb049288c5d7f086528fa91f1467aa778dea4cfd4b09302e4
|
|
7
|
+
data.tar.gz: 1aed3c8185b4b1f14b7707c97c9d38baa5cb19da9c268d7f6ae11024563e4f9452048a61fdbe616a6adadb4847559f1459a0c5b695306a31a0d579a66e2b5825
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.2.17] - 2026-05-25
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- `DeadBro.track(error, **context)`: manually report a rescued exception to the DeadBro backend from any `rescue` block. Accepts any `Exception` subclass and optional keyword arguments forwarded as a `:context` hash in the payload. The report includes exception class, message, a 50-frame backtrace, `occurred_at` timestamp, environment, and any captured log lines from the current request. Never raises — APM reporting will not interfere with your application code.
|
|
7
|
+
|
|
3
8
|
## [0.2.16] - 2026-05-24
|
|
4
9
|
|
|
5
10
|
### Added
|
data/lib/dead_bro/version.rb
CHANGED
data/lib/dead_bro.rb
CHANGED
|
@@ -137,6 +137,61 @@ module DeadBro
|
|
|
137
137
|
@monitor = monitor
|
|
138
138
|
end
|
|
139
139
|
|
|
140
|
+
# Manually report a rescued exception to the DeadBro backend.
|
|
141
|
+
#
|
|
142
|
+
# Call this from any rescue block to track an error even when your app
|
|
143
|
+
# handles it gracefully and doesn't re-raise.
|
|
144
|
+
#
|
|
145
|
+
# Usage:
|
|
146
|
+
# begin
|
|
147
|
+
# charge_card(user)
|
|
148
|
+
# rescue Stripe::CardError => e
|
|
149
|
+
# DeadBro.track(e, user_id: current_user.id, plan: "pro")
|
|
150
|
+
# render json: { error: "Card declined" }, status: 422
|
|
151
|
+
# end
|
|
152
|
+
#
|
|
153
|
+
# Any keyword arguments are forwarded as a :context hash in the payload.
|
|
154
|
+
def self.track(error, **context)
|
|
155
|
+
return unless error.is_a?(Exception)
|
|
156
|
+
|
|
157
|
+
begin
|
|
158
|
+
exception_class = error.class.name.to_s
|
|
159
|
+
event_name = exception_class.empty? ? "exception.tracked" : exception_class
|
|
160
|
+
|
|
161
|
+
payload = {
|
|
162
|
+
exception_class: exception_class,
|
|
163
|
+
message: error.message.to_s[0, 1000],
|
|
164
|
+
backtrace: Array(error.backtrace).first(50),
|
|
165
|
+
occurred_at: Process.clock_gettime(Process::CLOCK_REALTIME).to_i, # report time, not raise time
|
|
166
|
+
tracked: true,
|
|
167
|
+
rails_env: env,
|
|
168
|
+
app: begin
|
|
169
|
+
if defined?(Rails) && Rails.respond_to?(:application)
|
|
170
|
+
Rails.application.class.module_parent_name
|
|
171
|
+
else
|
|
172
|
+
""
|
|
173
|
+
end
|
|
174
|
+
rescue StandardError
|
|
175
|
+
""
|
|
176
|
+
end,
|
|
177
|
+
pid: Process.pid,
|
|
178
|
+
logs: begin
|
|
179
|
+
logger.logs
|
|
180
|
+
rescue StandardError
|
|
181
|
+
[]
|
|
182
|
+
end
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
payload[:context] = context unless context.empty?
|
|
186
|
+
|
|
187
|
+
client.post_metric(event_name: event_name, payload: payload, force: true)
|
|
188
|
+
rescue StandardError => _e
|
|
189
|
+
# Never let APM reporting interfere with the host app
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
nil
|
|
193
|
+
end
|
|
194
|
+
|
|
140
195
|
# Shared constant for tracking start time (used by all subscribers)
|
|
141
196
|
TRACKING_START_TIME_KEY = :dead_bro_tracking_start_time
|
|
142
197
|
MAX_TRACKING_DURATION_SECONDS = 3600 # 1 hour
|