exis_ray 0.5.3 → 0.5.4

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: d8bf4b504bfe6112b50328a358879a63b5ff19832e4724711a4650a110c94aaf
4
- data.tar.gz: fd3332690b0ff0b3ca95ccf4dddbddcb99322fd01481f9da4e11a12d3f0bf801
3
+ metadata.gz: 13877001eee2022a6c6de0d2709ef5080b0cc2e43459d5e81ea99d9f28f9b216
4
+ data.tar.gz: c6b551a316813a3671ae980a0fc8061b32fc1b585bc39b49a5c761a73c3af145
5
5
  SHA512:
6
- metadata.gz: 639eb1ab36f013dbf034dd7be88e5c13ab77779ed6a130d0f28cb75ace6baf36b0bb7b387f7ec77cb9a37236cb5ac703daa9bfa7116160aeee59ccc18e43b9be
7
- data.tar.gz: '0882e98c833ebc8774e47f2ddca1d33ce73fd9b7d8a5427b9851eafcab4323c41b0253d512e2ec9b0fd2391120f6390eeb1be2995d924a3674e155cda7c36dcb'
6
+ metadata.gz: e41a2bc99ab67896aac64e6eb8becca74fd03217807fa16e24ed434477109b053f9d9580b206a2c4f4123fefa6beca5f580b934e22c468175d20fa808179a7eb
7
+ data.tar.gz: 80bc6a49ea2b9ed2e4b45aa3f4e501752edb2d5873a8871cce6ba3b4e1bf4f925fb793a3ba5ab1a0f9c717d4ee63c9411bc1d738ab7d9a742ed48585071664fd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [0.5.4] - 2026-03-24
2
+
3
+ ### Changed
4
+ - **Human-readable durations:** `duration_human` now uses a smarter format: sub-second values show as `"7.2ms"`, values under 60s show as `"1.25s"`, and longer durations use `ActiveSupport::Duration` prose (e.g., `"2 minutes 5 seconds"`).
5
+ - **Shared duration helper:** Extracted `ExisRay::Tracer.format_duration` to consolidate duration formatting used by both `LogSubscriber` and `TaskMonitor`.
6
+
1
7
  ## [0.5.3] - 2026-03-24
2
8
 
3
9
  ### Changed
data/README.md CHANGED
@@ -286,6 +286,25 @@ If you don't need extra fields, skip this step — `ExisRay::LogSubscriber` is u
286
286
  * **`ExisRay::LogSubscriber`**: Replaces Lograge for HTTP request logging. Subscribes to `process_action.action_controller` and suppresses Rails' default multi-line log subscribers. Compatible with Rails 6, 7, and 8. Subclass it and override `self.extra_fields(event)` to inject custom fields.
287
287
  * **`ExisRay::TaskMonitor`**: The entry point for non-HTTP processes.
288
288
 
289
+ ## Known Behaviors
290
+
291
+ ### Third-party gem warnings in `body`
292
+
293
+ ExisRay captures all log output — including warnings emitted by third-party gems — and routes free-text lines to the `body` field. Some gems may include user-identifying data in their warnings.
294
+
295
+ **Example:** The [Bullet](https://github.com/flyerhzm/bullet) N+1 query detector emits warnings like:
296
+
297
+ ```
298
+ user: gabriel
299
+ GET /clients?page=1
300
+ USE eager loading detected
301
+ Client => [:gps_point]
302
+ ```
303
+
304
+ This text lands verbatim in `body`. ExisRay does not filter or redact `body` content, as it cannot know what third-party gems will include.
305
+
306
+ **Recommendation:** If you use Bullet or similar gems in production, configure them to use a separate notification channel (e.g., Slack, Honeybadger) instead of `Rails.logger`, to avoid leaking usernames or other PII into your structured logs.
307
+
289
308
  ## License
290
309
 
291
310
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -84,7 +84,7 @@ module ExisRay
84
84
  action: payload[:action],
85
85
  status: status,
86
86
  duration_s: duration_s,
87
- duration_human: ActiveSupport::Duration.build(duration_s).inspect,
87
+ duration_human: ExisRay::Tracer.format_duration(duration_s),
88
88
  view_runtime_s: view_s,
89
89
  db_runtime_s: db_s
90
90
  }
@@ -35,12 +35,12 @@ module ExisRay
35
35
  execute_with_optional_tags { yield }
36
36
 
37
37
  duration_s = ExisRay::Tracer.current_duration_s
38
- human_time = ActiveSupport::Duration.build(duration_s).inspect
38
+ human_time = ExisRay::Tracer.format_duration(duration_s)
39
39
 
40
40
  log_event(:info, "component=exis_ray event=task_finished task=#{task_name} status=success duration_s=#{duration_s} duration_human=\"#{human_time}\"")
41
41
  rescue StandardError => e
42
42
  duration_s = ExisRay::Tracer.current_duration_s
43
- human_time = ActiveSupport::Duration.build(duration_s).inspect
43
+ human_time = ExisRay::Tracer.format_duration(duration_s)
44
44
 
45
45
  log_event(:error, "component=exis_ray event=task_finished task=#{task_name} status=failed duration_s=#{duration_s} duration_human=\"#{human_time}\" error_class=#{e.class} error_message=#{e.message.inspect}")
46
46
  raise e
@@ -70,6 +70,23 @@ module ExisRay
70
70
  (Process.clock_gettime(Process::CLOCK_MONOTONIC) - created_at).round(4)
71
71
  end
72
72
 
73
+ # Formatea una duración en segundos a un string legible por humanos.
74
+ # - Menos de 1s → "7.2ms"
75
+ # - Entre 1-60s → "1.25s"
76
+ # - 60s o más → "2 minutes 5 seconds" (via ActiveSupport::Duration)
77
+ #
78
+ # @param seconds [Float] Duración en segundos.
79
+ # @return [String]
80
+ def self.format_duration(seconds)
81
+ if seconds < 1.0
82
+ "#{(seconds * 1000).round(1)}ms"
83
+ elsif seconds < 60.0
84
+ "#{seconds.round(3)}s"
85
+ else
86
+ ActiveSupport::Duration.build(seconds.round).inspect
87
+ end
88
+ end
89
+
73
90
  # Construye el header de trazabilidad para enviar al siguiente servicio.
74
91
  #
75
92
  # @return [String] Header formateado: "Root=...;Self=...;CalledFrom=...;TotalTimeSoFar=...ms"
@@ -2,5 +2,5 @@
2
2
 
3
3
  module ExisRay
4
4
  # Versión actual de la gema.
5
- VERSION = "0.5.3"
5
+ VERSION = "0.5.4"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exis_ray
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Edera