exis_ray 0.4.0 → 0.4.1

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: c5162f50fce688356ff17e9adff2464f6bc7ba9c83ee2e3a1f662dc4568fb6d3
4
- data.tar.gz: b2559412f57a487971edbf42cd0b24e18bbbe9fe33890096e8e6769647895e49
3
+ metadata.gz: bb94b36fd16b408d5359621e78a03c722c89dab7c087322b67c975db743ad24e
4
+ data.tar.gz: ef093be07091568e6bad52d26de306dd82f91fc8e8f554d4eb04a7ca8c3b1581
5
5
  SHA512:
6
- metadata.gz: 9efba79f9584005d1beb8c1d749dc4efb54959aa47433a671b611cbc15ce93bb4f081f390047b736039a1fad1d621cc2d5661fb82c3f340c2f57a7bddc461f19
7
- data.tar.gz: a2878c45410719109283a4a2b44201bc0b45fbe5a7ee2c70ba020a5b255392ab42af18fa52995f75e98dc4e32ae0727c718429b590daa3af797202e1488db897
6
+ metadata.gz: ce25522741b66f66318fa6d5223c0db754f1fe8f7eb1067a867f219988a1bc4ae78ef55c61e0895d553df955f129165af211a52dd41c86d6e3f6fe7066f7d7b2
7
+ data.tar.gz: 7ab403c8790dae80419260834d18787faa060bb2528d10974a4ef255bd6a0ea79c9aa837040015360db531b6114c8d99b4412c592d6749a0cba298ce24d072bc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.4.1] - 2026-03-23
2
+
3
+ ### Changed
4
+ - **Data-Driven Internal Logging:** Refactored internal library logs (boot, instrumentation, task status) from plain text messages to structured Key-Value (KV) strings.
5
+ - This leverages the `JsonFormatter`'s KV parser to elevate fields like `component`, `event`, and `status` to the JSON root, eliminating the need for unstructured `message` fields in infrastructure logs.
6
+ - Simplified `TaskMonitor#log_event` and `Railtie.log_boot` to emit raw KV strings directly to the logger.
7
+ - **Improved local debugging:** The `Reporter` now uses `exception.full_message` in non-production environments to provide a more readable backtrace in the development console.
8
+
1
9
  ## [0.4.0] - 2026-03-23
2
10
 
3
11
  ### Breaking Changes
@@ -41,18 +41,14 @@ module ExisRay
41
41
  require "exis_ray/log_subscriber"
42
42
  ExisRay::LogSubscriber.install!
43
43
 
44
- Rails.logger.info({ message: "[ExisRay] JSON Logging unificado activado." })
44
+ log_boot("component=exis_ray event=json_logging_enabled")
45
45
  end
46
46
 
47
47
  # --- Instrumentación de ActiveResource ---
48
48
  if defined?(ActiveResource::Base)
49
49
  require "exis_ray/active_resource_instrumentation"
50
50
  ActiveResource::Base.send(:prepend, ExisRay::ActiveResourceInstrumentation)
51
-
52
- log_message(
53
- text: "[ExisRay] ActiveResource instrumentado.",
54
- json: { message: "[ExisRay] ActiveResource instrumentado." }
55
- )
51
+ log_boot("component=exis_ray event=active_resource_instrumented")
56
52
  end
57
53
 
58
54
  # --- Instrumentación de Sidekiq ---
@@ -75,27 +71,21 @@ module ExisRay
75
71
  end
76
72
  end
77
73
 
78
- # Sidekiq maneja su propio logger. Lo forzamos a usar nuestra estructura JSON.
79
74
  if ExisRay.configuration.json_logs? && ::Sidekiq.logger
80
75
  ::Sidekiq.logger.formatter = ExisRay::JsonFormatter.new
81
- Rails.logger.info({ message: "[ExisRay] Sidekiq Middleware y JsonFormatter integrados." })
82
- else
83
- Rails.logger.info "[ExisRay] Sidekiq Middleware integrado."
84
76
  end
77
+ log_boot("component=exis_ray event=sidekiq_instrumented")
85
78
  end
86
79
  end
87
80
 
88
- # Helper interno para imprimir logs de inicialización respetando el formato elegido.
81
+ # Emite un log de boot en DEBUG con formato key=value.
82
+ # En modo texto es legible directamente. En modo JSON el JsonFormatter
83
+ # lo parsea y eleva cada campo al nivel raíz del JSON automáticamente.
89
84
  #
90
- # @param text [String] El mensaje para el formato texto.
91
- # @param json [Hash] El payload para el formato JSON.
85
+ # @param message [String] String en formato key=value.
92
86
  # @return [void]
93
- def self.log_message(text:, json:)
94
- if ExisRay.configuration.json_logs?
95
- Rails.logger.info(json)
96
- else
97
- Rails.logger.info(text)
98
- end
87
+ def self.log_boot(message)
88
+ Rails.logger.debug(message)
99
89
  end
100
90
  end
101
91
  end
@@ -32,7 +32,7 @@ module ExisRay
32
32
  prepare_scope(context, tags, fingerprint, transaction_name)
33
33
  add_tags(exception: excep.class.to_s)
34
34
 
35
- Rails.logger.error(excep) unless Rails.env.production?
35
+ Rails.logger.error(excep.full_message) unless Rails.env.production?
36
36
 
37
37
  if report_to_new_sentry?
38
38
  exception_to_new_sentry(excep)
@@ -29,14 +29,14 @@ module ExisRay
29
29
  curr.correlation_id = ExisRay::Tracer.correlation_id
30
30
  end
31
31
 
32
- log_event(:info, "Iniciando tarea: #{task_name}", task: task_name, status: "started")
32
+ log_event(:info, "component=exis_ray event=task_started task=#{task_name} status=started")
33
33
 
34
34
  # Bloque de ejecución con o sin tags dependiendo de la configuración
35
35
  execute_with_optional_tags { yield }
36
36
 
37
- log_event(:info, "Finalizada con éxito.", task: task_name, status: "success")
37
+ log_event(:info, "component=exis_ray event=task_finished task=#{task_name} status=success")
38
38
  rescue StandardError => e
39
- log_event(:error, "Falló la tarea #{task_name}: #{e.message}", task: task_name, status: "failed", error: e.message)
39
+ log_event(:error, "component=exis_ray event=task_failed task=#{task_name} status=failed error=#{e.message.inspect}")
40
40
  raise e
41
41
  ensure
42
42
  # Limpieza centralizada obligatoria para evitar filtraciones de memoria o contexto
@@ -89,12 +89,8 @@ module ExisRay
89
89
  # @param message [String] Mensaje en texto plano para el modo clásico.
90
90
  # @param payload [Hash] Datos estructurados para el modo JSON.
91
91
  # @return [void]
92
- def self.log_event(level, message, **payload)
93
- if ExisRay.configuration.json_logs?
94
- Rails.logger.send(level, payload.merge(message: "[ExisRay] #{message}"))
95
- else
96
- Rails.logger.send(level, "[ExisRay] #{message}")
97
- end
92
+ def self.log_event(level, message)
93
+ Rails.logger.send(level, message)
98
94
  rescue StandardError
99
95
  # El logger nunca debe interrumpir el flujo principal de la tarea.
100
96
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module ExisRay
4
4
  # Versión actual de la gema.
5
- VERSION = "0.4.0"
5
+ VERSION = "0.4.1"
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.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Edera