brainzlab 0.1.35 → 0.1.37

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/lib/brainzlab/beacon/client.rb +6 -4
  4. data/lib/brainzlab/configuration.rb +272 -301
  5. data/lib/brainzlab/cortex/client.rb +6 -4
  6. data/lib/brainzlab/debug.rb +6 -6
  7. data/lib/brainzlab/dendrite/client.rb +6 -4
  8. data/lib/brainzlab/development/logger.rb +2 -2
  9. data/lib/brainzlab/development/store.rb +4 -2
  10. data/lib/brainzlab/devtools/middleware/error_page.rb +1 -1
  11. data/lib/brainzlab/errors.rb +12 -5
  12. data/lib/brainzlab/flux/client.rb +1 -1
  13. data/lib/brainzlab/instrumentation/action_cable.rb +4 -4
  14. data/lib/brainzlab/instrumentation/action_controller.rb +12 -12
  15. data/lib/brainzlab/instrumentation/action_dispatch.rb +1 -1
  16. data/lib/brainzlab/instrumentation/action_mailbox.rb +13 -7
  17. data/lib/brainzlab/instrumentation/action_view.rb +33 -29
  18. data/lib/brainzlab/instrumentation/active_job.rb +10 -6
  19. data/lib/brainzlab/instrumentation/active_record.rb +24 -21
  20. data/lib/brainzlab/instrumentation/active_storage.rb +4 -4
  21. data/lib/brainzlab/instrumentation/active_support_cache.rb +8 -6
  22. data/lib/brainzlab/instrumentation/grape.rb +1 -3
  23. data/lib/brainzlab/instrumentation/rails_deprecation.rb +1 -1
  24. data/lib/brainzlab/instrumentation/railties.rb +2 -2
  25. data/lib/brainzlab/nerve/client.rb +6 -4
  26. data/lib/brainzlab/pulse/client.rb +58 -2
  27. data/lib/brainzlab/pulse/metric_buffer.rb +128 -0
  28. data/lib/brainzlab/pulse.rb +5 -7
  29. data/lib/brainzlab/rails/railtie.rb +3 -1
  30. data/lib/brainzlab/reflex/client.rb +1 -1
  31. data/lib/brainzlab/sentinel/client.rb +6 -4
  32. data/lib/brainzlab/synapse/client.rb +6 -4
  33. data/lib/brainzlab/testing/event_store.rb +3 -3
  34. data/lib/brainzlab/testing/matchers.rb +4 -4
  35. data/lib/brainzlab/testing.rb +3 -5
  36. data/lib/brainzlab/vault/client.rb +6 -4
  37. data/lib/brainzlab/version.rb +1 -1
  38. data/lib/brainzlab/vision/client.rb +3 -3
  39. data/lib/fluyenta-ruby.rb +1 -1
  40. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf1207ec18676d63267312a25c4bcbe2519a1ddc70ceb5bb34ac58f7a83e29d2
4
- data.tar.gz: d8ea421af25cae73f94d4741eed9a404c6297477088eaf3df9b4a000675824da
3
+ metadata.gz: 1a5e45616c86bfb16c81bf506b428a4aca149f71ea9b6888c92329d2738876c2
4
+ data.tar.gz: 335891991652de956d08b83d9d7c64d683059832da2998cbd7a017561a4ec8ff
5
5
  SHA512:
6
- metadata.gz: 2bee3ad0497520af5744ccd898360f389ac30bf599382d4af14f871d2b1f30659a5879a8ad5a6dfcfd1bf008445e0262a1d2fa5887d00146128099cda99410b3
7
- data.tar.gz: 0760d616e2b3a32c2c408098d5a69d4a68d3d3ab52f3dbde121d2994c4498bb5c26cbc24fd6d569a3f41d6614cceca3075a9f06df1bbdea1bd5f9da399da2861
6
+ metadata.gz: c6a12e0de0e1fe1d878152ebb5edd15359afaf0b93940da6823b001e4e77b7d31350d5d81f70eb562df5ab72f949c52c534b04af1b9543434f4dd16f9f46a139
7
+ data.tar.gz: f9b97f86513fa87255ed0c0cd3887fe3faab8185f1c0686d345d72f85b1e016fd78b555929516d095e287c03ecb3e3861fd6a5554c72c58980aab24c67ee092c
data/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.1.37] - Unreleased
6
+
7
+ ### Changed
8
+
9
+ - **Pulse metrics are now batched.** `Pulse.counter`, `gauge`, `histogram` and `record_metric` used to make one `POST /api/v1/metrics` per point, and during instrumentation spawned one thread per point (cache instrumentation emits two points per cache operation). They now accumulate in `Pulse::MetricBuffer` and go out through `POST /api/v1/metrics/batch` from a single background thread: when `pulse_buffer_size` points are pending or every `pulse_flush_interval` seconds (defaults 50 and 5). No HTTP happens on the calling thread and each process has at most one batch in flight. Setting `pulse_buffer_size = 1` keeps the old one-by-one behaviour.
10
+ - The backlog is capped at 20 batches (oldest points dropped) so a Pulse outage cannot grow host memory. Pending points are flushed at process exit, for at most 5 seconds. The buffer is fork-safe: each worker gets its own, and a child never resends what it inherited.
11
+ - Points that would get a whole batch rejected (`value` not a number or string; NaN, Infinity or invalid bytes that `JSON.generate` refuses) are dropped on their own.
12
+
13
+ ### Note
14
+
15
+ `Pulse.record_metric` no longer returns the HTTP response when batching is on, and a point can now wait up to `pulse_flush_interval` seconds before leaving the process. A process that ends with `exit!` skips `at_exit` and loses what is pending.
16
+
17
+ ## [0.1.36] - 2026-10-29
18
+
19
+ ### Fixed
20
+
21
+ - **Flux client now falls back to `secret_key`.** `Flux::Client#api_key` only read `flux_ingest_key || flux_api_key`, while `Configuration#flux_valid?` also accepted `secret_key`. Apps configured with only `BRAINZLAB_SECRET_KEY` (no `FLUX_API_KEY` / `FLUX_INGEST_KEY`) therefore sent `Authorization: Bearer ` with an empty token, and Flux rejected every batch with 401. The client now uses `Configuration#flux_auth_key` (`flux_ingest_key || flux_api_key || secret_key`), matching how Pulse resolves its key. Measured in production on 2026-10-29: every `solid_queue.job.duration_ms` batch from services on 0.1.32/0.1.33 without a Flux-specific key was rejected.
22
+
5
23
  ## [0.1.31] - 2026-06-18
6
24
 
7
25
  ### Fixed
@@ -204,9 +204,9 @@ module BrainzLab
204
204
  BrainzLab.debug_log("[Beacon::Client] #{operation} failed: #{structured_error.message}")
205
205
 
206
206
  # Call on_error callback if configured
207
- return unless @config.on_error
208
-
209
- @config.on_error.call(structured_error, { service: 'Beacon', operation: operation })
207
+ if @config.on_error
208
+ @config.on_error.call(structured_error, { service: 'Beacon', operation: operation })
209
+ end
210
210
  end
211
211
 
212
212
  def handle_response_error(response, operation)
@@ -216,7 +216,9 @@ module BrainzLab
216
216
  BrainzLab.debug_log("[Beacon::Client] #{operation} failed: #{structured_error.message}")
217
217
 
218
218
  # Call on_error callback if configured
219
- @config.on_error&.call(structured_error, { service: 'Beacon', operation: operation })
219
+ if @config.on_error
220
+ @config.on_error.call(structured_error, { service: 'Beacon', operation: operation })
221
+ end
220
222
 
221
223
  structured_error
222
224
  end