brainzlab 0.1.23 → 0.1.24

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bba9f09002a8dcd486cb1b110567274f2d558c471eed12657996fbb0589cbba0
4
- data.tar.gz: 60a5d0b80300d8ccf3aa6aa48bd615514fd222246be796f3ba7e2c9260578050
3
+ metadata.gz: 6ab7b5c063e4371cad8decac72f4f0508c3ad4da1fedd8041a97c2f6601ee601
4
+ data.tar.gz: c3af39c85de1dee2a20cc4586809c5e7634fe8aa85f4145716b56e342119e48b
5
5
  SHA512:
6
- metadata.gz: 2d4d0694747b4b08413636cb030465ad5babdd79388d8751f6fe6482229eea1dee0ca891711eb82a56641f745018b09c04cdfdcd87843ac1271c40f0b54bd2e8
7
- data.tar.gz: cfd9ba154ac07f66eca51f22a4666a5c5a97db6c28265b725b7fcb1bbbd90a9064203957b0a26a39164201b963d55da8dbe7f23f45a9357cd89eccbe1cbce202
6
+ metadata.gz: 5581a93b79f51388c3d0ea6c5a1681418618bafbabfdb6e688210e7ae07cdf5d1a047fb414434c5f5171b95363734197555b5be6a2b6ad4c7f75cdf5740ce61f
7
+ data.tar.gz: 3a71004cb62f9a74fb3fdd5979da80757ffd06b30461bfb970217fb972c01c92904db9949bf52a7b48e4d5b5c20f2f745e63b908b4d49ea5c84ce3bebcc0e553
@@ -164,7 +164,25 @@ module BrainzLab
164
164
  :slow_query_log_level,
165
165
  :very_slow_query_log_level,
166
166
  :n_plus_one_threshold,
167
- :n_plus_one_log_level
167
+ :n_plus_one_log_level,
168
+ :slow_request_threshold,
169
+ :very_slow_request_threshold,
170
+ :slow_cache_threshold,
171
+ :very_slow_cache_threshold,
172
+ :slow_render_threshold,
173
+ :very_slow_render_threshold,
174
+ :slow_storage_threshold,
175
+ :very_slow_storage_threshold,
176
+ :slow_cable_threshold,
177
+ :very_slow_cable_threshold,
178
+ :slow_initializer_threshold,
179
+ :very_slow_initializer_threshold,
180
+ :slow_middleware_threshold,
181
+ :very_slow_middleware_threshold,
182
+ :slow_mailbox_threshold,
183
+ :very_slow_mailbox_threshold,
184
+ :slow_job_threshold,
185
+ :very_slow_job_threshold
168
186
 
169
187
  # Services that should not track themselves to avoid circular dependencies
170
188
  SELF_TRACKING_SERVICES = {
@@ -378,6 +396,30 @@ module BrainzLab
378
396
  @n_plus_one_threshold = (ENV['BRAINZLAB_N_PLUS_ONE_THRESHOLD'] || 10).to_i # was hardcoded 5
379
397
  @n_plus_one_log_level = (ENV['BRAINZLAB_N_PLUS_ONE_LOG_LEVEL'] || 'debug').to_sym # was :warning
380
398
 
399
+ # Per-instrumentation slow / very-slow thresholds (ms) — all env-tunable so a
400
+ # single low default can't flood Recall or wrongly escalate normal latency to
401
+ # :error. Defaults preserve prior behaviour EXCEPT cache, which is raised off
402
+ # DB-backed Solid Cache's normal write latency (~50ms paid a DB round-trip and
403
+ # tripped the old VERY_SLOW=50 → thousands of false :error logs/hour).
404
+ @slow_request_threshold = (ENV['BRAINZLAB_SLOW_REQUEST_THRESHOLD'] || 500).to_i
405
+ @very_slow_request_threshold = (ENV['BRAINZLAB_VERY_SLOW_REQUEST_THRESHOLD'] || 2000).to_i
406
+ @slow_cache_threshold = (ENV['BRAINZLAB_SLOW_CACHE_THRESHOLD'] || 100).to_i # was 10
407
+ @very_slow_cache_threshold = (ENV['BRAINZLAB_VERY_SLOW_CACHE_THRESHOLD'] || 500).to_i # was 50 → flooded :error
408
+ @slow_render_threshold = (ENV['BRAINZLAB_SLOW_RENDER_THRESHOLD'] || 50).to_i
409
+ @very_slow_render_threshold = (ENV['BRAINZLAB_VERY_SLOW_RENDER_THRESHOLD'] || 200).to_i
410
+ @slow_storage_threshold = (ENV['BRAINZLAB_SLOW_STORAGE_THRESHOLD'] || 500).to_i
411
+ @very_slow_storage_threshold = (ENV['BRAINZLAB_VERY_SLOW_STORAGE_THRESHOLD'] || 2000).to_i
412
+ @slow_cable_threshold = (ENV['BRAINZLAB_SLOW_CABLE_THRESHOLD'] || 100).to_i
413
+ @very_slow_cable_threshold = (ENV['BRAINZLAB_VERY_SLOW_CABLE_THRESHOLD'] || 500).to_i
414
+ @slow_initializer_threshold = (ENV['BRAINZLAB_SLOW_INITIALIZER_THRESHOLD'] || 100).to_i
415
+ @very_slow_initializer_threshold = (ENV['BRAINZLAB_VERY_SLOW_INITIALIZER_THRESHOLD'] || 500).to_i
416
+ @slow_middleware_threshold = (ENV['BRAINZLAB_SLOW_MIDDLEWARE_THRESHOLD'] || 50).to_i
417
+ @very_slow_middleware_threshold = (ENV['BRAINZLAB_VERY_SLOW_MIDDLEWARE_THRESHOLD'] || 200).to_i
418
+ @slow_mailbox_threshold = (ENV['BRAINZLAB_SLOW_MAILBOX_THRESHOLD'] || 1000).to_i
419
+ @very_slow_mailbox_threshold = (ENV['BRAINZLAB_VERY_SLOW_MAILBOX_THRESHOLD'] || 5000).to_i
420
+ @slow_job_threshold = (ENV['BRAINZLAB_SLOW_JOB_THRESHOLD'] || 5000).to_i
421
+ @very_slow_job_threshold = (ENV['BRAINZLAB_VERY_SLOW_JOB_THRESHOLD'] || 30_000).to_i
422
+
381
423
  # Log formatter settings
382
424
  @log_formatter_enabled = true
383
425
  @log_formatter_colors = nil # auto-detect TTY
@@ -48,8 +48,8 @@ module BrainzLab
48
48
 
49
49
  # Determine level based on duration
50
50
  level = case duration
51
- when 0...SLOW_ACTION_THRESHOLD then :info
52
- when SLOW_ACTION_THRESHOLD...VERY_SLOW_ACTION_THRESHOLD then :warning
51
+ when 0...BrainzLab.configuration.slow_cable_threshold then :info
52
+ when BrainzLab.configuration.slow_cable_threshold...BrainzLab.configuration.very_slow_cable_threshold then :warning
53
53
  else :error
54
54
  end
55
55
 
@@ -71,7 +71,7 @@ module BrainzLab
71
71
  record_action_span(event, channel_class, action, duration, data)
72
72
 
73
73
  # Log slow actions
74
- log_slow_action(channel_class, action, duration) if duration >= SLOW_ACTION_THRESHOLD
74
+ log_slow_action(channel_class, action, duration) if duration >= BrainzLab.configuration.slow_cable_threshold
75
75
  rescue StandardError => e
76
76
  BrainzLab.debug_log("ActionCable perform_action instrumentation failed: #{e.message}")
77
77
  end
@@ -334,7 +334,7 @@ module BrainzLab
334
334
  def log_slow_action(channel_class, action, duration)
335
335
  return unless BrainzLab.configuration.recall_effectively_enabled?
336
336
 
337
- level = duration >= VERY_SLOW_ACTION_THRESHOLD ? :error : :warn
337
+ level = duration >= BrainzLab.configuration.very_slow_cable_threshold ? :error : :warn
338
338
 
339
339
  BrainzLab::Recall.send(
340
340
  level,
@@ -342,7 +342,7 @@ module BrainzLab
342
342
  channel: channel_class,
343
343
  action: action,
344
344
  duration_ms: duration,
345
- threshold_exceeded: duration >= VERY_SLOW_ACTION_THRESHOLD ? 'critical' : 'warning'
345
+ threshold_exceeded: duration >= BrainzLab.configuration.very_slow_cable_threshold ? 'critical' : 'warning'
346
346
  )
347
347
  end
348
348
  end
@@ -116,7 +116,7 @@ module BrainzLab
116
116
  record_request_trace(event, payload, duration)
117
117
 
118
118
  # Log slow requests to Recall
119
- log_slow_request(payload, duration) if duration >= SLOW_REQUEST_THRESHOLD
119
+ log_slow_request(payload, duration) if duration >= BrainzLab.configuration.slow_request_threshold
120
120
  rescue StandardError => e
121
121
  BrainzLab.debug_log("ActionController process_action instrumentation failed: #{e.message}")
122
122
  end
@@ -136,8 +136,8 @@ module BrainzLab
136
136
  end
137
137
 
138
138
  # Adjust for slow requests
139
- level = :warning if level == :info && duration >= SLOW_REQUEST_THRESHOLD
140
- level = :error if duration >= VERY_SLOW_REQUEST_THRESHOLD
139
+ level = :warning if level == :info && duration >= BrainzLab.configuration.slow_request_threshold
140
+ level = :error if duration >= BrainzLab.configuration.very_slow_request_threshold
141
141
 
142
142
  BrainzLab::Reflex.add_breadcrumb(
143
143
  "#{method} #{controller}##{action} -> #{status} (#{duration}ms)",
@@ -189,7 +189,7 @@ module BrainzLab
189
189
  def log_slow_request(payload, duration)
190
190
  return unless BrainzLab.configuration.recall_effectively_enabled?
191
191
 
192
- level = duration >= VERY_SLOW_REQUEST_THRESHOLD ? :error : :warn
192
+ level = duration >= BrainzLab.configuration.very_slow_request_threshold ? :error : :warn
193
193
 
194
194
  BrainzLab::Recall.send(
195
195
  level,
@@ -203,7 +203,7 @@ module BrainzLab
203
203
  duration_ms: duration,
204
204
  view_ms: payload[:view_runtime]&.round(2),
205
205
  db_ms: payload[:db_runtime]&.round(2),
206
- threshold_exceeded: duration >= VERY_SLOW_REQUEST_THRESHOLD ? 'critical' : 'warning'
206
+ threshold_exceeded: duration >= BrainzLab.configuration.very_slow_request_threshold ? 'critical' : 'warning'
207
207
  )
208
208
  end
209
209
 
@@ -48,8 +48,8 @@ module BrainzLab
48
48
 
49
49
  # Determine level based on duration
50
50
  level = case duration
51
- when 0...SLOW_MIDDLEWARE_THRESHOLD then :info
52
- when SLOW_MIDDLEWARE_THRESHOLD...VERY_SLOW_MIDDLEWARE_THRESHOLD then :warning
51
+ when 0...BrainzLab.configuration.slow_middleware_threshold then :info
52
+ when BrainzLab.configuration.slow_middleware_threshold...BrainzLab.configuration.very_slow_middleware_threshold then :warning
53
53
  else :error
54
54
  end
55
55
 
@@ -70,8 +70,8 @@ module BrainzLab
70
70
  record_middleware_span(event, middleware, duration)
71
71
 
72
72
  # Log slow middleware
73
- if duration >= SLOW_MIDDLEWARE_THRESHOLD && BrainzLab.configuration.recall_effectively_enabled?
74
- log_level = duration >= VERY_SLOW_MIDDLEWARE_THRESHOLD ? :error : :warn
73
+ if duration >= BrainzLab.configuration.slow_middleware_threshold && BrainzLab.configuration.recall_effectively_enabled?
74
+ log_level = duration >= BrainzLab.configuration.very_slow_middleware_threshold ? :error : :warn
75
75
  BrainzLab::Recall.send(
76
76
  log_level,
77
77
  "Slow middleware: #{middleware} (#{duration}ms)",
@@ -54,8 +54,8 @@ module BrainzLab
54
54
 
55
55
  # Determine level based on duration
56
56
  level = case duration
57
- when 0...SLOW_PROCESSING_THRESHOLD then :info
58
- when SLOW_PROCESSING_THRESHOLD...VERY_SLOW_PROCESSING_THRESHOLD then :warning
57
+ when 0...BrainzLab.configuration.slow_mailbox_threshold then :info
58
+ when BrainzLab.configuration.slow_mailbox_threshold...BrainzLab.configuration.very_slow_mailbox_threshold then :warning
59
59
  else :error
60
60
  end
61
61
 
@@ -134,8 +134,8 @@ module BrainzLab
134
134
  subject: truncate(subject, 200),
135
135
  duration_ms: duration
136
136
  )
137
- elsif duration >= SLOW_PROCESSING_THRESHOLD
138
- level = duration >= VERY_SLOW_PROCESSING_THRESHOLD ? :error : :warn
137
+ elsif duration >= BrainzLab.configuration.slow_mailbox_threshold
138
+ level = duration >= BrainzLab.configuration.very_slow_mailbox_threshold ? :error : :warn
139
139
  BrainzLab::Recall.send(
140
140
  level,
141
141
  "Slow mailbox processing: #{mailbox_class} (#{duration}ms)",
@@ -143,7 +143,7 @@ module BrainzLab
143
143
  email_id: email_id,
144
144
  status: status,
145
145
  duration_ms: duration,
146
- threshold_exceeded: duration >= VERY_SLOW_PROCESSING_THRESHOLD ? 'critical' : 'warning'
146
+ threshold_exceeded: duration >= BrainzLab.configuration.very_slow_mailbox_threshold ? 'critical' : 'warning'
147
147
  )
148
148
  end
149
149
  end
@@ -57,7 +57,7 @@ module BrainzLab
57
57
  record_render_span(event, 'template', template_name, duration, layout: layout)
58
58
 
59
59
  # Log slow renders to Recall
60
- log_slow_render('template', template_name, duration) if duration >= SLOW_RENDER_THRESHOLD
60
+ log_slow_render('template', template_name, duration) if duration >= BrainzLab.configuration.slow_render_threshold
61
61
  rescue StandardError => e
62
62
  BrainzLab.debug_log("ActionView render_template instrumentation failed: #{e.message}")
63
63
  end
@@ -89,7 +89,7 @@ module BrainzLab
89
89
  record_render_span(event, 'partial', template_name, duration, cached: payload[:cache_hit])
90
90
 
91
91
  # Log slow renders to Recall
92
- log_slow_render('partial', template_name, duration) if duration >= SLOW_RENDER_THRESHOLD
92
+ log_slow_render('partial', template_name, duration) if duration >= BrainzLab.configuration.slow_render_threshold
93
93
  rescue StandardError => e
94
94
  BrainzLab.debug_log("ActionView render_partial instrumentation failed: #{e.message}")
95
95
  end
@@ -115,7 +115,7 @@ module BrainzLab
115
115
  template_name = extract_template_name(identifier)
116
116
 
117
117
  # Add breadcrumb for significant collections
118
- if count >= COLLECTION_TRACKING_THRESHOLD || duration >= SLOW_RENDER_THRESHOLD
118
+ if count >= COLLECTION_TRACKING_THRESHOLD || duration >= BrainzLab.configuration.slow_render_threshold
119
119
  record_collection_breadcrumb(template_name, duration, count, cache_hits)
120
120
  end
121
121
 
@@ -123,7 +123,7 @@ module BrainzLab
123
123
  record_collection_span(event, template_name, duration, count, cache_hits)
124
124
 
125
125
  # Log slow collection renders to Recall
126
- if duration >= SLOW_RENDER_THRESHOLD
126
+ if duration >= BrainzLab.configuration.slow_render_threshold
127
127
  log_slow_collection_render(template_name, duration, count, cache_hits)
128
128
  end
129
129
 
@@ -185,8 +185,8 @@ module BrainzLab
185
185
  return unless BrainzLab.configuration.reflex_effectively_enabled?
186
186
 
187
187
  level = case duration
188
- when 0...SLOW_RENDER_THRESHOLD then :info
189
- when SLOW_RENDER_THRESHOLD...VERY_SLOW_RENDER_THRESHOLD then :warning
188
+ when 0...BrainzLab.configuration.slow_render_threshold then :info
189
+ when BrainzLab.configuration.slow_render_threshold...BrainzLab.configuration.very_slow_render_threshold then :warning
190
190
  else :error
191
191
  end
192
192
 
@@ -239,8 +239,8 @@ module BrainzLab
239
239
  return unless BrainzLab.configuration.reflex_effectively_enabled?
240
240
 
241
241
  level = case duration
242
- when 0...SLOW_RENDER_THRESHOLD then :info
243
- when SLOW_RENDER_THRESHOLD...VERY_SLOW_RENDER_THRESHOLD then :warning
242
+ when 0...BrainzLab.configuration.slow_render_threshold then :info
243
+ when BrainzLab.configuration.slow_render_threshold...BrainzLab.configuration.very_slow_render_threshold then :warning
244
244
  else :error
245
245
  end
246
246
 
@@ -292,7 +292,7 @@ module BrainzLab
292
292
  def log_slow_render(type, template_name, duration)
293
293
  return unless BrainzLab.configuration.recall_effectively_enabled?
294
294
 
295
- level = duration >= VERY_SLOW_RENDER_THRESHOLD ? :error : :warn
295
+ level = duration >= BrainzLab.configuration.very_slow_render_threshold ? :error : :warn
296
296
 
297
297
  BrainzLab::Recall.send(
298
298
  level,
@@ -300,14 +300,14 @@ module BrainzLab
300
300
  template: template_name,
301
301
  type: type,
302
302
  duration_ms: duration,
303
- threshold_exceeded: duration >= VERY_SLOW_RENDER_THRESHOLD ? 'critical' : 'warning'
303
+ threshold_exceeded: duration >= BrainzLab.configuration.very_slow_render_threshold ? 'critical' : 'warning'
304
304
  )
305
305
  end
306
306
 
307
307
  def log_slow_collection_render(template_name, duration, count, cache_hits)
308
308
  return unless BrainzLab.configuration.recall_effectively_enabled?
309
309
 
310
- level = duration >= VERY_SLOW_RENDER_THRESHOLD ? :error : :warn
310
+ level = duration >= BrainzLab.configuration.very_slow_render_threshold ? :error : :warn
311
311
 
312
312
  BrainzLab::Recall.send(
313
313
  level,
@@ -318,7 +318,7 @@ module BrainzLab
318
318
  cache_hits: cache_hits,
319
319
  duration_ms: duration,
320
320
  avg_per_item_ms: count > 0 ? (duration / count).round(2) : nil,
321
- threshold_exceeded: duration >= VERY_SLOW_RENDER_THRESHOLD ? 'critical' : 'warning'
321
+ threshold_exceeded: duration >= BrainzLab.configuration.very_slow_render_threshold ? 'critical' : 'warning'
322
322
  )
323
323
  end
324
324
 
@@ -300,7 +300,7 @@ module BrainzLab
300
300
  # Determine level based on outcome and duration
301
301
  level = if exception
302
302
  :error
303
- elsif duration >= SLOW_JOB_THRESHOLD
303
+ elsif duration >= BrainzLab.configuration.slow_job_threshold
304
304
  :warning
305
305
  else
306
306
  :info
@@ -549,8 +549,8 @@ module BrainzLab
549
549
  error_class: exception.class.name,
550
550
  error_message: exception.message
551
551
  )
552
- elsif duration >= SLOW_JOB_THRESHOLD
553
- level = duration >= VERY_SLOW_JOB_THRESHOLD ? :error : :warn
552
+ elsif duration >= BrainzLab.configuration.slow_job_threshold
553
+ level = duration >= BrainzLab.configuration.very_slow_job_threshold ? :error : :warn
554
554
  BrainzLab::Recall.send(
555
555
  level,
556
556
  "Slow job: #{job_class} (#{duration}ms)",
@@ -559,7 +559,7 @@ module BrainzLab
559
559
  queue: queue,
560
560
  duration_ms: duration,
561
561
  queue_wait_ms: queue_wait_ms,
562
- threshold_exceeded: duration >= VERY_SLOW_JOB_THRESHOLD ? 'critical' : 'warning'
562
+ threshold_exceeded: duration >= BrainzLab.configuration.very_slow_job_threshold ? 'critical' : 'warning'
563
563
  )
564
564
  end
565
565
  end
@@ -61,7 +61,7 @@ module BrainzLab
61
61
  record_storage_span(event, 'preview', key, duration)
62
62
 
63
63
  # Log slow operations
64
- log_slow_operation('preview', key, duration) if duration >= SLOW_OPERATION_THRESHOLD
64
+ log_slow_operation('preview', key, duration) if duration >= BrainzLab.configuration.slow_storage_threshold
65
65
  rescue StandardError => e
66
66
  BrainzLab.debug_log("ActiveStorage preview instrumentation failed: #{e.message}")
67
67
  end
@@ -89,7 +89,7 @@ module BrainzLab
89
89
  record_storage_span(event, 'transform', key, duration)
90
90
 
91
91
  # Log slow operations
92
- log_slow_operation('transform', key, duration) if duration >= SLOW_OPERATION_THRESHOLD
92
+ log_slow_operation('transform', key, duration) if duration >= BrainzLab.configuration.slow_storage_threshold
93
93
  rescue StandardError => e
94
94
  BrainzLab.debug_log("ActiveStorage transform instrumentation failed: #{e.message}")
95
95
  end
@@ -115,7 +115,7 @@ module BrainzLab
115
115
  BrainzLab::Reflex.add_breadcrumb(
116
116
  "Storage analyze: #{analyzer} (#{duration}ms)",
117
117
  category: 'storage.analyze',
118
- level: duration >= SLOW_OPERATION_THRESHOLD ? :warning : :info,
118
+ level: duration >= BrainzLab.configuration.slow_storage_threshold ? :warning : :info,
119
119
  data: {
120
120
  analyzer: analyzer,
121
121
  duration_ms: duration
@@ -150,8 +150,8 @@ module BrainzLab
150
150
  # Record breadcrumb
151
151
  if BrainzLab.configuration.reflex_effectively_enabled?
152
152
  level = case duration
153
- when 0...SLOW_OPERATION_THRESHOLD then :info
154
- when SLOW_OPERATION_THRESHOLD...VERY_SLOW_OPERATION_THRESHOLD then :warning
153
+ when 0...BrainzLab.configuration.slow_storage_threshold then :info
154
+ when BrainzLab.configuration.slow_storage_threshold...BrainzLab.configuration.very_slow_storage_threshold then :warning
155
155
  else :error
156
156
  end
157
157
 
@@ -171,7 +171,7 @@ module BrainzLab
171
171
  record_service_span(event, 'upload', key, duration, service: service)
172
172
 
173
173
  # Log slow uploads
174
- log_slow_operation('upload', key, duration, service: service) if duration >= SLOW_OPERATION_THRESHOLD
174
+ log_slow_operation('upload', key, duration, service: service) if duration >= BrainzLab.configuration.slow_storage_threshold
175
175
  rescue StandardError => e
176
176
  BrainzLab.debug_log("ActiveStorage service_upload instrumentation failed: #{e.message}")
177
177
  end
@@ -200,7 +200,7 @@ module BrainzLab
200
200
  record_service_span(event, 'download', key, duration, service: service)
201
201
 
202
202
  # Log slow downloads
203
- log_slow_operation('download', key, duration, service: service) if duration >= SLOW_OPERATION_THRESHOLD
203
+ log_slow_operation('download', key, duration, service: service) if duration >= BrainzLab.configuration.slow_storage_threshold
204
204
  rescue StandardError => e
205
205
  BrainzLab.debug_log("ActiveStorage service_download instrumentation failed: #{e.message}")
206
206
  end
@@ -442,8 +442,8 @@ module BrainzLab
442
442
  return unless BrainzLab.configuration.reflex_effectively_enabled?
443
443
 
444
444
  level = case duration
445
- when 0...SLOW_OPERATION_THRESHOLD then :info
446
- when SLOW_OPERATION_THRESHOLD...VERY_SLOW_OPERATION_THRESHOLD then :warning
445
+ when 0...BrainzLab.configuration.slow_storage_threshold then :info
446
+ when BrainzLab.configuration.slow_storage_threshold...BrainzLab.configuration.very_slow_storage_threshold then :warning
447
447
  else :error
448
448
  end
449
449
 
@@ -509,7 +509,7 @@ module BrainzLab
509
509
  def log_slow_operation(operation, key, duration, service: nil)
510
510
  return unless BrainzLab.configuration.recall_effectively_enabled?
511
511
 
512
- level = duration >= VERY_SLOW_OPERATION_THRESHOLD ? :error : :warn
512
+ level = duration >= BrainzLab.configuration.very_slow_storage_threshold ? :error : :warn
513
513
 
514
514
  BrainzLab::Recall.send(
515
515
  level,
@@ -518,7 +518,7 @@ module BrainzLab
518
518
  key: truncate_key(key),
519
519
  service: service,
520
520
  duration_ms: duration,
521
- threshold_exceeded: duration >= VERY_SLOW_OPERATION_THRESHOLD ? 'critical' : 'warning'
521
+ threshold_exceeded: duration >= BrainzLab.configuration.very_slow_storage_threshold ? 'critical' : 'warning'
522
522
  )
523
523
  end
524
524
 
@@ -103,7 +103,7 @@ module BrainzLab
103
103
  BrainzLab::Reflex.add_breadcrumb(
104
104
  "Cache read_multi: #{hit_count}/#{key_count} hits (#{duration}ms)",
105
105
  category: 'cache.read_multi',
106
- level: duration >= SLOW_CACHE_THRESHOLD ? :warning : :info,
106
+ level: duration >= BrainzLab.configuration.slow_cache_threshold ? :warning : :info,
107
107
  data: {
108
108
  key_count: key_count,
109
109
  hit_count: hit_count,
@@ -146,7 +146,7 @@ module BrainzLab
146
146
  record_cache_span(event, 'write', key, duration)
147
147
 
148
148
  # Log slow writes
149
- log_slow_cache_operation('write', key, duration) if duration >= SLOW_CACHE_THRESHOLD
149
+ log_slow_cache_operation('write', key, duration) if duration >= BrainzLab.configuration.slow_cache_threshold
150
150
  rescue StandardError => e
151
151
  BrainzLab.debug_log("ActiveSupport::Cache write instrumentation failed: #{e.message}")
152
152
  end
@@ -175,7 +175,7 @@ module BrainzLab
175
175
  BrainzLab::Reflex.add_breadcrumb(
176
176
  "Cache write_multi: #{key_count} keys (#{duration}ms)",
177
177
  category: 'cache.write_multi',
178
- level: duration >= SLOW_CACHE_THRESHOLD ? :warning : :info,
178
+ level: duration >= BrainzLab.configuration.slow_cache_threshold ? :warning : :info,
179
179
  data: {
180
180
  key_count: key_count,
181
181
  duration_ms: duration
@@ -294,8 +294,8 @@ module BrainzLab
294
294
  # Record breadcrumb - this is a cache miss that triggered computation
295
295
  if BrainzLab.configuration.reflex_effectively_enabled?
296
296
  level = case duration
297
- when 0...SLOW_CACHE_THRESHOLD then :info
298
- when SLOW_CACHE_THRESHOLD...VERY_SLOW_CACHE_THRESHOLD then :warning
297
+ when 0...BrainzLab.configuration.slow_cache_threshold then :info
298
+ when BrainzLab.configuration.slow_cache_threshold...BrainzLab.configuration.very_slow_cache_threshold then :warning
299
299
  else :error
300
300
  end
301
301
 
@@ -318,7 +318,7 @@ module BrainzLab
318
318
  track_cache_metrics('fetch', false, duration)
319
319
 
320
320
  # Log slow cache generations
321
- log_slow_cache_operation('generate', key, duration) if duration >= SLOW_CACHE_THRESHOLD
321
+ log_slow_cache_operation('generate', key, duration) if duration >= BrainzLab.configuration.slow_cache_threshold
322
322
  rescue StandardError => e
323
323
  BrainzLab.debug_log("ActiveSupport::Cache generate instrumentation failed: #{e.message}")
324
324
  end
@@ -629,7 +629,7 @@ module BrainzLab
629
629
  def record_cache_breadcrumb(operation, key, duration, hit: nil)
630
630
  return unless BrainzLab.configuration.reflex_effectively_enabled?
631
631
 
632
- level = duration >= SLOW_CACHE_THRESHOLD ? :warning : :info
632
+ level = duration >= BrainzLab.configuration.slow_cache_threshold ? :warning : :info
633
633
 
634
634
  message = if hit.nil?
635
635
  "Cache #{operation}: #{truncate_key(key)} (#{duration}ms)"
@@ -699,7 +699,7 @@ module BrainzLab
699
699
  def log_slow_cache_operation(operation, key, duration)
700
700
  return unless BrainzLab.configuration.recall_effectively_enabled?
701
701
 
702
- level = duration >= VERY_SLOW_CACHE_THRESHOLD ? :error : :warn
702
+ level = duration >= BrainzLab.configuration.very_slow_cache_threshold ? :error : :warn
703
703
 
704
704
  BrainzLab::Recall.send(
705
705
  level,
@@ -707,7 +707,7 @@ module BrainzLab
707
707
  operation: operation,
708
708
  key: truncate_key(key),
709
709
  duration_ms: duration,
710
- threshold_exceeded: duration >= VERY_SLOW_CACHE_THRESHOLD ? 'critical' : 'warning'
710
+ threshold_exceeded: duration >= BrainzLab.configuration.very_slow_cache_threshold ? 'critical' : 'warning'
711
711
  )
712
712
  end
713
713
 
@@ -46,8 +46,8 @@ module BrainzLab
46
46
 
47
47
  # Determine level based on duration
48
48
  level = case duration
49
- when 0...SLOW_INITIALIZER_THRESHOLD then :info
50
- when SLOW_INITIALIZER_THRESHOLD...VERY_SLOW_INITIALIZER_THRESHOLD then :warning
49
+ when 0...BrainzLab.configuration.slow_initializer_threshold then :info
50
+ when BrainzLab.configuration.slow_initializer_threshold...BrainzLab.configuration.very_slow_initializer_threshold then :warning
51
51
  else :error
52
52
  end
53
53
 
@@ -69,7 +69,7 @@ module BrainzLab
69
69
  record_initializer_span(event, initializer_name, initializer, duration)
70
70
 
71
71
  # Log slow initializers
72
- log_slow_initializer(initializer_name, initializer, duration) if duration >= SLOW_INITIALIZER_THRESHOLD
72
+ log_slow_initializer(initializer_name, initializer, duration) if duration >= BrainzLab.configuration.slow_initializer_threshold
73
73
  rescue StandardError => e
74
74
  BrainzLab.debug_log("Railties load_config_initializer instrumentation failed: #{e.message}")
75
75
  end
@@ -106,7 +106,7 @@ module BrainzLab
106
106
  def log_slow_initializer(name, path, duration)
107
107
  return unless BrainzLab.configuration.recall_effectively_enabled?
108
108
 
109
- level = duration >= VERY_SLOW_INITIALIZER_THRESHOLD ? :error : :warn
109
+ level = duration >= BrainzLab.configuration.very_slow_initializer_threshold ? :error : :warn
110
110
 
111
111
  BrainzLab::Recall.send(
112
112
  level,
@@ -114,7 +114,7 @@ module BrainzLab
114
114
  initializer: name,
115
115
  path: path,
116
116
  duration_ms: duration,
117
- threshold_exceeded: duration >= VERY_SLOW_INITIALIZER_THRESHOLD ? 'critical' : 'warning'
117
+ threshold_exceeded: duration >= BrainzLab.configuration.very_slow_initializer_threshold ? 'critical' : 'warning'
118
118
  )
119
119
  end
120
120
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BrainzLab
4
- VERSION = '0.1.23'
4
+ VERSION = '0.1.24'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brainzlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.23
4
+ version: 0.1.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - BrainzLab