brainzlab 0.1.35 → 0.1.36
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 +6 -0
- data/lib/brainzlab/beacon/client.rb +6 -4
- data/lib/brainzlab/configuration.rb +272 -301
- data/lib/brainzlab/cortex/client.rb +6 -4
- data/lib/brainzlab/debug.rb +6 -6
- data/lib/brainzlab/dendrite/client.rb +6 -4
- data/lib/brainzlab/development/logger.rb +2 -2
- data/lib/brainzlab/development/store.rb +4 -2
- data/lib/brainzlab/devtools/middleware/error_page.rb +1 -1
- data/lib/brainzlab/errors.rb +12 -5
- data/lib/brainzlab/flux/client.rb +1 -1
- data/lib/brainzlab/instrumentation/action_cable.rb +4 -4
- data/lib/brainzlab/instrumentation/action_controller.rb +12 -12
- data/lib/brainzlab/instrumentation/action_dispatch.rb +1 -1
- data/lib/brainzlab/instrumentation/action_mailbox.rb +13 -7
- data/lib/brainzlab/instrumentation/action_view.rb +33 -29
- data/lib/brainzlab/instrumentation/active_job.rb +10 -6
- data/lib/brainzlab/instrumentation/active_record.rb +24 -21
- data/lib/brainzlab/instrumentation/active_storage.rb +4 -4
- data/lib/brainzlab/instrumentation/active_support_cache.rb +8 -6
- data/lib/brainzlab/instrumentation/grape.rb +1 -3
- data/lib/brainzlab/instrumentation/rails_deprecation.rb +1 -1
- data/lib/brainzlab/instrumentation/railties.rb +2 -2
- data/lib/brainzlab/nerve/client.rb +6 -4
- data/lib/brainzlab/pulse/client.rb +1 -1
- data/lib/brainzlab/pulse.rb +1 -5
- data/lib/brainzlab/rails/railtie.rb +3 -1
- data/lib/brainzlab/reflex/client.rb +1 -1
- data/lib/brainzlab/sentinel/client.rb +6 -4
- data/lib/brainzlab/synapse/client.rb +6 -4
- data/lib/brainzlab/testing/event_store.rb +3 -3
- data/lib/brainzlab/testing/matchers.rb +4 -4
- data/lib/brainzlab/testing.rb +3 -5
- data/lib/brainzlab/vault/client.rb +6 -4
- data/lib/brainzlab/version.rb +1 -1
- data/lib/brainzlab/vision/client.rb +3 -3
- data/lib/fluyenta-ruby.rb +1 -1
- metadata +1 -1
|
@@ -145,7 +145,7 @@ module BrainzLab
|
|
|
145
145
|
|
|
146
146
|
key = payload[:key]
|
|
147
147
|
service = payload[:service]
|
|
148
|
-
payload[:checksum]
|
|
148
|
+
checksum = payload[:checksum]
|
|
149
149
|
|
|
150
150
|
# Record breadcrumb
|
|
151
151
|
if BrainzLab.configuration.reflex_effectively_enabled?
|
|
@@ -294,7 +294,7 @@ module BrainzLab
|
|
|
294
294
|
# Log to Recall - bulk deletes are significant
|
|
295
295
|
if BrainzLab.configuration.recall_effectively_enabled?
|
|
296
296
|
BrainzLab::Recall.info(
|
|
297
|
-
|
|
297
|
+
"Storage bulk delete by prefix",
|
|
298
298
|
prefix: truncate_key(prefix),
|
|
299
299
|
service: service,
|
|
300
300
|
duration_ms: duration
|
|
@@ -357,7 +357,7 @@ module BrainzLab
|
|
|
357
357
|
# Log slow URL generations
|
|
358
358
|
if duration >= 50 && BrainzLab.configuration.recall_effectively_enabled?
|
|
359
359
|
BrainzLab::Recall.warn(
|
|
360
|
-
|
|
360
|
+
"Slow storage URL generation",
|
|
361
361
|
key: truncate_key(key),
|
|
362
362
|
service: service,
|
|
363
363
|
duration_ms: duration
|
|
@@ -411,7 +411,7 @@ module BrainzLab
|
|
|
411
411
|
key = payload[:key]
|
|
412
412
|
service = payload[:service]
|
|
413
413
|
content_type = payload[:content_type]
|
|
414
|
-
payload[:disposition]
|
|
414
|
+
disposition = payload[:disposition]
|
|
415
415
|
|
|
416
416
|
# Record breadcrumb
|
|
417
417
|
if BrainzLab.configuration.reflex_effectively_enabled?
|
|
@@ -109,7 +109,7 @@ module BrainzLab
|
|
|
109
109
|
hit_count: hit_count,
|
|
110
110
|
miss_count: key_count - hit_count,
|
|
111
111
|
duration_ms: duration,
|
|
112
|
-
hit_rate: key_count
|
|
112
|
+
hit_rate: key_count > 0 ? (hit_count.to_f / key_count * 100).round(1) : 0
|
|
113
113
|
}
|
|
114
114
|
)
|
|
115
115
|
end
|
|
@@ -476,7 +476,7 @@ module BrainzLab
|
|
|
476
476
|
# Log pattern deletes
|
|
477
477
|
if BrainzLab.configuration.recall_effectively_enabled?
|
|
478
478
|
BrainzLab::Recall.info(
|
|
479
|
-
|
|
479
|
+
"Cache pattern delete",
|
|
480
480
|
pattern: truncate_key(key),
|
|
481
481
|
duration_ms: duration
|
|
482
482
|
)
|
|
@@ -502,6 +502,7 @@ module BrainzLab
|
|
|
502
502
|
duration = event.duration.round(2)
|
|
503
503
|
|
|
504
504
|
size = payload[:size]
|
|
505
|
+
key = payload[:key]
|
|
505
506
|
|
|
506
507
|
# Record breadcrumb
|
|
507
508
|
if BrainzLab.configuration.reflex_effectively_enabled?
|
|
@@ -538,6 +539,7 @@ module BrainzLab
|
|
|
538
539
|
payload = event.payload
|
|
539
540
|
duration = event.duration.round(2)
|
|
540
541
|
|
|
542
|
+
key = payload[:key]
|
|
541
543
|
from = payload[:from]
|
|
542
544
|
to = payload[:to]
|
|
543
545
|
|
|
@@ -561,7 +563,7 @@ module BrainzLab
|
|
|
561
563
|
# Log prune operations
|
|
562
564
|
if BrainzLab.configuration.recall_effectively_enabled?
|
|
563
565
|
BrainzLab::Recall.info(
|
|
564
|
-
|
|
566
|
+
"Cache pruned",
|
|
565
567
|
from: from,
|
|
566
568
|
to: to,
|
|
567
569
|
duration_ms: duration
|
|
@@ -591,8 +593,8 @@ module BrainzLab
|
|
|
591
593
|
|
|
592
594
|
serializer = payload[:serializer]
|
|
593
595
|
fallback = payload[:fallback]
|
|
594
|
-
payload[:serialized]
|
|
595
|
-
payload[:deserialized]
|
|
596
|
+
serialized = payload[:serialized]
|
|
597
|
+
deserialized = payload[:deserialized]
|
|
596
598
|
|
|
597
599
|
# Record breadcrumb - this is a warning as it indicates a format mismatch
|
|
598
600
|
if BrainzLab.configuration.reflex_effectively_enabled?
|
|
@@ -611,7 +613,7 @@ module BrainzLab
|
|
|
611
613
|
# Log to Recall - this is significant for debugging serialization issues
|
|
612
614
|
if BrainzLab.configuration.recall_effectively_enabled?
|
|
613
615
|
BrainzLab::Recall.warn(
|
|
614
|
-
|
|
616
|
+
"Message serializer fallback used",
|
|
615
617
|
serializer: serializer.to_s,
|
|
616
618
|
fallback: fallback.to_s,
|
|
617
619
|
duration_ms: duration
|
|
@@ -203,9 +203,7 @@ module BrainzLab
|
|
|
203
203
|
end
|
|
204
204
|
|
|
205
205
|
def safe_dig(routing_args, key)
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
routing_args[key]
|
|
206
|
+
routing_args.respond_to?(:dig) ? routing_args.dig(key) : nil
|
|
209
207
|
rescue StandardError
|
|
210
208
|
nil
|
|
211
209
|
end
|
|
@@ -60,7 +60,7 @@ module BrainzLab
|
|
|
60
60
|
# Log to Recall for tracking
|
|
61
61
|
if BrainzLab.configuration.recall_effectively_enabled?
|
|
62
62
|
BrainzLab::Recall.warn(
|
|
63
|
-
|
|
63
|
+
"Rails deprecation warning",
|
|
64
64
|
message: truncate_message(message, 500),
|
|
65
65
|
gem_name: gem_name,
|
|
66
66
|
deprecation_horizon: deprecation_horizon,
|
|
@@ -4,8 +4,8 @@ module BrainzLab
|
|
|
4
4
|
module Instrumentation
|
|
5
5
|
class Railties
|
|
6
6
|
# Thresholds for slow initializers (in milliseconds)
|
|
7
|
-
SLOW_INITIALIZER_THRESHOLD = 100
|
|
8
|
-
VERY_SLOW_INITIALIZER_THRESHOLD = 500
|
|
7
|
+
SLOW_INITIALIZER_THRESHOLD = 100 # 100ms
|
|
8
|
+
VERY_SLOW_INITIALIZER_THRESHOLD = 500 # 500ms
|
|
9
9
|
|
|
10
10
|
class << self
|
|
11
11
|
def install!
|
|
@@ -212,9 +212,9 @@ module BrainzLab
|
|
|
212
212
|
BrainzLab.debug_log("[Nerve::Client] #{operation} failed: #{structured_error.message}")
|
|
213
213
|
|
|
214
214
|
# Call on_error callback if configured
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
if @config.on_error
|
|
216
|
+
@config.on_error.call(structured_error, { service: 'Nerve', operation: operation })
|
|
217
|
+
end
|
|
218
218
|
end
|
|
219
219
|
|
|
220
220
|
def handle_response_error(response, operation)
|
|
@@ -224,7 +224,9 @@ module BrainzLab
|
|
|
224
224
|
BrainzLab.debug_log("[Nerve::Client] #{operation} failed: #{structured_error.message}")
|
|
225
225
|
|
|
226
226
|
# Call on_error callback if configured
|
|
227
|
-
@config.on_error
|
|
227
|
+
if @config.on_error
|
|
228
|
+
@config.on_error.call(structured_error, { service: 'Nerve', operation: operation })
|
|
229
|
+
end
|
|
228
230
|
|
|
229
231
|
structured_error
|
|
230
232
|
end
|
data/lib/brainzlab/pulse.rb
CHANGED
|
@@ -119,11 +119,7 @@ module BrainzLab
|
|
|
119
119
|
|
|
120
120
|
# Parse timestamp or use current time
|
|
121
121
|
started_at = if timestamp
|
|
122
|
-
|
|
123
|
-
Time.parse(timestamp)
|
|
124
|
-
rescue StandardError
|
|
125
|
-
Time.now.utc
|
|
126
|
-
end
|
|
122
|
+
Time.parse(timestamp) rescue Time.now.utc
|
|
127
123
|
else
|
|
128
124
|
Time.now.utc
|
|
129
125
|
end
|
|
@@ -33,7 +33,9 @@ module BrainzLab
|
|
|
33
33
|
# Add request context middleware. Gated on `enabled` so the kill switch
|
|
34
34
|
# (BRAINZLAB_SDK_ENABLED=false) fully removes it — it previously loaded
|
|
35
35
|
# unconditionally, so disabling didn't stop its session interference.
|
|
36
|
-
|
|
36
|
+
if BrainzLab.configuration.enabled
|
|
37
|
+
app.middleware.insert_after ActionDispatch::RequestId, BrainzLab::Rails::Middleware
|
|
38
|
+
end
|
|
37
39
|
|
|
38
40
|
# Add DevTools middlewares if enabled
|
|
39
41
|
if BrainzLab.configuration.devtools_enabled
|
|
@@ -213,9 +213,9 @@ module BrainzLab
|
|
|
213
213
|
BrainzLab.debug_log("[Sentinel::Client] #{operation} failed: #{structured_error.message}")
|
|
214
214
|
|
|
215
215
|
# Call on_error callback if configured
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
if @config.on_error
|
|
217
|
+
@config.on_error.call(structured_error, { service: 'Sentinel', operation: operation })
|
|
218
|
+
end
|
|
219
219
|
end
|
|
220
220
|
|
|
221
221
|
def handle_response_error(response, operation)
|
|
@@ -225,7 +225,9 @@ module BrainzLab
|
|
|
225
225
|
BrainzLab.debug_log("[Sentinel::Client] #{operation} failed: #{structured_error.message}")
|
|
226
226
|
|
|
227
227
|
# Call on_error callback if configured
|
|
228
|
-
@config.on_error
|
|
228
|
+
if @config.on_error
|
|
229
|
+
@config.on_error.call(structured_error, { service: 'Sentinel', operation: operation })
|
|
230
|
+
end
|
|
229
231
|
|
|
230
232
|
structured_error
|
|
231
233
|
end
|
|
@@ -285,9 +285,9 @@ module BrainzLab
|
|
|
285
285
|
BrainzLab.debug_log("[Synapse::Client] #{operation} failed: #{structured_error.message}")
|
|
286
286
|
|
|
287
287
|
# Call on_error callback if configured
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
288
|
+
if @config.on_error
|
|
289
|
+
@config.on_error.call(structured_error, { service: 'Synapse', operation: operation })
|
|
290
|
+
end
|
|
291
291
|
end
|
|
292
292
|
|
|
293
293
|
def handle_response_error(response, operation)
|
|
@@ -297,7 +297,9 @@ module BrainzLab
|
|
|
297
297
|
BrainzLab.debug_log("[Synapse::Client] #{operation} failed: #{structured_error.message}")
|
|
298
298
|
|
|
299
299
|
# Call on_error callback if configured
|
|
300
|
-
@config.on_error
|
|
300
|
+
if @config.on_error
|
|
301
|
+
@config.on_error.call(structured_error, { service: 'Synapse', operation: operation })
|
|
302
|
+
end
|
|
301
303
|
|
|
302
304
|
structured_error
|
|
303
305
|
end
|
|
@@ -187,9 +187,9 @@ module BrainzLab
|
|
|
187
187
|
def error_captured?(error_class = nil, message: nil, context: nil)
|
|
188
188
|
@mutex.synchronize do
|
|
189
189
|
@errors.any? do |error|
|
|
190
|
-
if error_class
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
if error_class
|
|
191
|
+
next false unless error[:error_class] == error_class.to_s ||
|
|
192
|
+
(error_class.is_a?(Class) && error[:exception].is_a?(error_class))
|
|
193
193
|
end
|
|
194
194
|
|
|
195
195
|
if message
|
|
@@ -112,10 +112,10 @@ module BrainzLab
|
|
|
112
112
|
"expected event '#{@event_name}' to have been tracked, but no such event was found.\n" \
|
|
113
113
|
"Tracked events: #{BrainzLab::Testing.event_store.events.map { |e| e[:name] }.inspect}"
|
|
114
114
|
else
|
|
115
|
-
"expected event '#{@event_name}' to have been tracked with properties:\n
|
|
116
|
-
"#{@expected_properties.inspect}\n" \
|
|
117
|
-
"but was tracked with:\n
|
|
118
|
-
"#{actual_events.map { |e| e[:properties] }.inspect}"
|
|
115
|
+
"expected event '#{@event_name}' to have been tracked with properties:\n" \
|
|
116
|
+
" #{@expected_properties.inspect}\n" \
|
|
117
|
+
"but was tracked with:\n" \
|
|
118
|
+
" #{actual_events.map { |e| e[:properties] }.inspect}"
|
|
119
119
|
end
|
|
120
120
|
end
|
|
121
121
|
|
data/lib/brainzlab/testing.rb
CHANGED
|
@@ -198,18 +198,16 @@ module BrainzLab
|
|
|
198
198
|
end
|
|
199
199
|
|
|
200
200
|
# Stub distributed tracing methods
|
|
201
|
-
BrainzLab::Pulse.define_singleton_method(:inject) do |headers, **
|
|
201
|
+
BrainzLab::Pulse.define_singleton_method(:inject) do |headers, **opts|
|
|
202
202
|
headers['traceparent'] = '00-test-trace-id-12345-test-span-id-67890-01'
|
|
203
203
|
headers
|
|
204
204
|
end
|
|
205
205
|
|
|
206
206
|
BrainzLab::Pulse.define_singleton_method(:extract) do |headers|
|
|
207
|
-
return unless headers['traceparent']
|
|
208
|
-
|
|
209
207
|
BrainzLab::Pulse::Propagation::Context.new(
|
|
210
208
|
trace_id: 'test-trace-id-12345',
|
|
211
209
|
span_id: 'test-span-id-67890'
|
|
212
|
-
)
|
|
210
|
+
) if headers['traceparent']
|
|
213
211
|
end
|
|
214
212
|
|
|
215
213
|
BrainzLab::Pulse.define_singleton_method(:extract!) do |headers|
|
|
@@ -306,7 +304,7 @@ module BrainzLab
|
|
|
306
304
|
BrainzLab::Cortex.define_singleton_method(:read) { |*| nil }
|
|
307
305
|
BrainzLab::Cortex.define_singleton_method(:write) { |*| true }
|
|
308
306
|
BrainzLab::Cortex.define_singleton_method(:delete) { |*| true }
|
|
309
|
-
BrainzLab::Cortex.define_singleton_method(:fetch) { |
|
|
307
|
+
BrainzLab::Cortex.define_singleton_method(:fetch) { |key, **opts, &block| block&.call }
|
|
310
308
|
end
|
|
311
309
|
|
|
312
310
|
def stub_vault!
|
|
@@ -193,9 +193,9 @@ module BrainzLab
|
|
|
193
193
|
BrainzLab.debug_log("[Vault::Client] #{operation} failed: #{structured_error.message}")
|
|
194
194
|
|
|
195
195
|
# Call on_error callback if configured
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
if @config.on_error
|
|
197
|
+
@config.on_error.call(structured_error, { service: 'Vault', operation: operation })
|
|
198
|
+
end
|
|
199
199
|
end
|
|
200
200
|
|
|
201
201
|
def handle_response_error(response, operation)
|
|
@@ -205,7 +205,9 @@ module BrainzLab
|
|
|
205
205
|
BrainzLab.debug_log("[Vault::Client] #{operation} failed: #{structured_error.message}")
|
|
206
206
|
|
|
207
207
|
# Call on_error callback if configured
|
|
208
|
-
@config.on_error
|
|
208
|
+
if @config.on_error
|
|
209
|
+
@config.on_error.call(structured_error, { service: 'Vault', operation: operation })
|
|
210
|
+
end
|
|
209
211
|
|
|
210
212
|
structured_error
|
|
211
213
|
end
|
data/lib/brainzlab/version.rb
CHANGED
|
@@ -154,9 +154,9 @@ module BrainzLab
|
|
|
154
154
|
BrainzLab.debug_log("[Vision::Client] #{operation} failed: #{error.message}")
|
|
155
155
|
|
|
156
156
|
# Call on_error callback if configured
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
if @config.on_error
|
|
158
|
+
@config.on_error.call(error, { service: 'Vision', operation: operation })
|
|
159
|
+
end
|
|
160
160
|
end
|
|
161
161
|
|
|
162
162
|
def auth_key
|
data/lib/fluyenta-ruby.rb
CHANGED