brainzlab 0.1.34 → 0.1.35
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/lib/brainzlab/beacon/client.rb +4 -6
- data/lib/brainzlab/configuration.rb +301 -272
- data/lib/brainzlab/cortex/client.rb +4 -6
- data/lib/brainzlab/debug.rb +6 -6
- data/lib/brainzlab/dendrite/client.rb +4 -6
- data/lib/brainzlab/development/logger.rb +2 -2
- data/lib/brainzlab/development/store.rb +2 -4
- data/lib/brainzlab/devtools/middleware/error_page.rb +1 -1
- data/lib/brainzlab/errors.rb +5 -12
- 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 +7 -13
- data/lib/brainzlab/instrumentation/action_view.rb +29 -33
- data/lib/brainzlab/instrumentation/active_job.rb +6 -10
- data/lib/brainzlab/instrumentation/active_record.rb +21 -24
- data/lib/brainzlab/instrumentation/active_storage.rb +4 -4
- data/lib/brainzlab/instrumentation/active_support_cache.rb +6 -8
- data/lib/brainzlab/instrumentation/aws.rb +10 -7
- data/lib/brainzlab/instrumentation/grape.rb +3 -1
- data/lib/brainzlab/instrumentation/rails_deprecation.rb +1 -1
- data/lib/brainzlab/instrumentation/railties.rb +2 -2
- data/lib/brainzlab/nerve/client.rb +4 -6
- data/lib/brainzlab/pulse/client.rb +1 -1
- data/lib/brainzlab/pulse.rb +5 -1
- data/lib/brainzlab/rails/railtie.rb +1 -3
- data/lib/brainzlab/reflex/client.rb +1 -1
- data/lib/brainzlab/sentinel/client.rb +4 -6
- data/lib/brainzlab/synapse/client.rb +4 -6
- data/lib/brainzlab/testing/event_store.rb +3 -3
- data/lib/brainzlab/testing/matchers.rb +4 -4
- data/lib/brainzlab/testing.rb +5 -3
- data/lib/brainzlab/vault/client.rb +4 -6
- 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
|
-
|
|
148
|
+
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
|
-
|
|
414
|
+
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.positive? ? (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,7 +502,6 @@ module BrainzLab
|
|
|
502
502
|
duration = event.duration.round(2)
|
|
503
503
|
|
|
504
504
|
size = payload[:size]
|
|
505
|
-
key = payload[:key]
|
|
506
505
|
|
|
507
506
|
# Record breadcrumb
|
|
508
507
|
if BrainzLab.configuration.reflex_effectively_enabled?
|
|
@@ -539,7 +538,6 @@ module BrainzLab
|
|
|
539
538
|
payload = event.payload
|
|
540
539
|
duration = event.duration.round(2)
|
|
541
540
|
|
|
542
|
-
key = payload[:key]
|
|
543
541
|
from = payload[:from]
|
|
544
542
|
to = payload[:to]
|
|
545
543
|
|
|
@@ -563,7 +561,7 @@ module BrainzLab
|
|
|
563
561
|
# Log prune operations
|
|
564
562
|
if BrainzLab.configuration.recall_effectively_enabled?
|
|
565
563
|
BrainzLab::Recall.info(
|
|
566
|
-
|
|
564
|
+
'Cache pruned',
|
|
567
565
|
from: from,
|
|
568
566
|
to: to,
|
|
569
567
|
duration_ms: duration
|
|
@@ -593,8 +591,8 @@ module BrainzLab
|
|
|
593
591
|
|
|
594
592
|
serializer = payload[:serializer]
|
|
595
593
|
fallback = payload[:fallback]
|
|
596
|
-
|
|
597
|
-
|
|
594
|
+
payload[:serialized]
|
|
595
|
+
payload[:deserialized]
|
|
598
596
|
|
|
599
597
|
# Record breadcrumb - this is a warning as it indicates a format mismatch
|
|
600
598
|
if BrainzLab.configuration.reflex_effectively_enabled?
|
|
@@ -613,7 +611,7 @@ module BrainzLab
|
|
|
613
611
|
# Log to Recall - this is significant for debugging serialization issues
|
|
614
612
|
if BrainzLab.configuration.recall_effectively_enabled?
|
|
615
613
|
BrainzLab::Recall.warn(
|
|
616
|
-
|
|
614
|
+
'Message serializer fallback used',
|
|
617
615
|
serializer: serializer.to_s,
|
|
618
616
|
fallback: fallback.to_s,
|
|
619
617
|
duration_ms: duration
|
|
@@ -15,13 +15,16 @@ module BrainzLab
|
|
|
15
15
|
private
|
|
16
16
|
|
|
17
17
|
def install_plugin!
|
|
18
|
-
# AWS
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
#
|
|
18
|
+
# Registered through Seahorse only. Every AWS client inherits from
|
|
19
|
+
# Seahorse::Client::Base, so this one hook covers S3, SQS and the rest,
|
|
20
|
+
# on every version of the SDK.
|
|
21
|
+
#
|
|
22
|
+
# There used to be a second registration through Aws.config[:plugins].
|
|
23
|
+
# That option only exists on newer aws-sdk-core; on older ones it does
|
|
24
|
+
# not degrade, it makes *every* client fail to construct with
|
|
25
|
+
# "invalid configuration option :plugins" — so an app pinned to an
|
|
26
|
+
# older SDK could not talk to S3 at all. It bought nothing either way,
|
|
27
|
+
# since the handler below is the same handler.
|
|
25
28
|
return unless defined?(::Seahorse::Client::Base)
|
|
26
29
|
|
|
27
30
|
install_seahorse_handler!
|
|
@@ -203,7 +203,9 @@ module BrainzLab
|
|
|
203
203
|
end
|
|
204
204
|
|
|
205
205
|
def safe_dig(routing_args, key)
|
|
206
|
-
routing_args.respond_to?(:dig)
|
|
206
|
+
return nil unless routing_args.respond_to?(:dig)
|
|
207
|
+
|
|
208
|
+
routing_args[key]
|
|
207
209
|
rescue StandardError
|
|
208
210
|
nil
|
|
209
211
|
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
|
+
return unless @config.on_error
|
|
216
|
+
|
|
217
|
+
@config.on_error.call(structured_error, { service: 'Nerve', operation: operation })
|
|
218
218
|
end
|
|
219
219
|
|
|
220
220
|
def handle_response_error(response, operation)
|
|
@@ -224,9 +224,7 @@ 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
|
-
|
|
228
|
-
@config.on_error.call(structured_error, { service: 'Nerve', operation: operation })
|
|
229
|
-
end
|
|
227
|
+
@config.on_error&.call(structured_error, { service: 'Nerve', operation: operation })
|
|
230
228
|
|
|
231
229
|
structured_error
|
|
232
230
|
end
|
data/lib/brainzlab/pulse.rb
CHANGED
|
@@ -119,7 +119,11 @@ module BrainzLab
|
|
|
119
119
|
|
|
120
120
|
# Parse timestamp or use current time
|
|
121
121
|
started_at = if timestamp
|
|
122
|
-
|
|
122
|
+
begin
|
|
123
|
+
Time.parse(timestamp)
|
|
124
|
+
rescue StandardError
|
|
125
|
+
Time.now.utc
|
|
126
|
+
end
|
|
123
127
|
else
|
|
124
128
|
Time.now.utc
|
|
125
129
|
end
|
|
@@ -33,9 +33,7 @@ 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
|
-
if BrainzLab.configuration.enabled
|
|
37
|
-
app.middleware.insert_after ActionDispatch::RequestId, BrainzLab::Rails::Middleware
|
|
38
|
-
end
|
|
36
|
+
app.middleware.insert_after ActionDispatch::RequestId, BrainzLab::Rails::Middleware if BrainzLab.configuration.enabled
|
|
39
37
|
|
|
40
38
|
# Add DevTools middlewares if enabled
|
|
41
39
|
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
|
+
return unless @config.on_error
|
|
217
|
+
|
|
218
|
+
@config.on_error.call(structured_error, { service: 'Sentinel', operation: operation })
|
|
219
219
|
end
|
|
220
220
|
|
|
221
221
|
def handle_response_error(response, operation)
|
|
@@ -225,9 +225,7 @@ 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
|
-
|
|
229
|
-
@config.on_error.call(structured_error, { service: 'Sentinel', operation: operation })
|
|
230
|
-
end
|
|
228
|
+
@config.on_error&.call(structured_error, { service: 'Sentinel', operation: operation })
|
|
231
229
|
|
|
232
230
|
structured_error
|
|
233
231
|
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
|
+
return unless @config.on_error
|
|
289
|
+
|
|
290
|
+
@config.on_error.call(structured_error, { service: 'Synapse', operation: operation })
|
|
291
291
|
end
|
|
292
292
|
|
|
293
293
|
def handle_response_error(response, operation)
|
|
@@ -297,9 +297,7 @@ 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
|
-
|
|
301
|
-
@config.on_error.call(structured_error, { service: 'Synapse', operation: operation })
|
|
302
|
-
end
|
|
300
|
+
@config.on_error&.call(structured_error, { service: 'Synapse', operation: operation })
|
|
303
301
|
|
|
304
302
|
structured_error
|
|
305
303
|
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 && !(error[:error_class] == error_class.to_s ||
|
|
191
|
+
(error_class.is_a?(Class) && error[:exception].is_a?(error_class)))
|
|
192
|
+
next false
|
|
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
|
-
"
|
|
117
|
-
"but was tracked with:\n" \
|
|
118
|
-
"
|
|
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,16 +198,18 @@ 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
|
+
|
|
207
209
|
BrainzLab::Pulse::Propagation::Context.new(
|
|
208
210
|
trace_id: 'test-trace-id-12345',
|
|
209
211
|
span_id: 'test-span-id-67890'
|
|
210
|
-
)
|
|
212
|
+
)
|
|
211
213
|
end
|
|
212
214
|
|
|
213
215
|
BrainzLab::Pulse.define_singleton_method(:extract!) do |headers|
|
|
@@ -304,7 +306,7 @@ module BrainzLab
|
|
|
304
306
|
BrainzLab::Cortex.define_singleton_method(:read) { |*| nil }
|
|
305
307
|
BrainzLab::Cortex.define_singleton_method(:write) { |*| true }
|
|
306
308
|
BrainzLab::Cortex.define_singleton_method(:delete) { |*| true }
|
|
307
|
-
BrainzLab::Cortex.define_singleton_method(:fetch) { |
|
|
309
|
+
BrainzLab::Cortex.define_singleton_method(:fetch) { |_key, **_opts, &block| block&.call }
|
|
308
310
|
end
|
|
309
311
|
|
|
310
312
|
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
|
+
return unless @config.on_error
|
|
197
|
+
|
|
198
|
+
@config.on_error.call(structured_error, { service: 'Vault', operation: operation })
|
|
199
199
|
end
|
|
200
200
|
|
|
201
201
|
def handle_response_error(response, operation)
|
|
@@ -205,9 +205,7 @@ 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
|
-
|
|
209
|
-
@config.on_error.call(structured_error, { service: 'Vault', operation: operation })
|
|
210
|
-
end
|
|
208
|
+
@config.on_error&.call(structured_error, { service: 'Vault', operation: operation })
|
|
211
209
|
|
|
212
210
|
structured_error
|
|
213
211
|
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
|
+
return unless @config.on_error
|
|
158
|
+
|
|
159
|
+
@config.on_error.call(error, { service: 'Vision', operation: operation })
|
|
160
160
|
end
|
|
161
161
|
|
|
162
162
|
def auth_key
|
data/lib/fluyenta-ruby.rb
CHANGED