exis_ray 0.11.0 → 1.0.0
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/AGENTS.md +238 -0
- data/CHANGELOG.md +32 -0
- data/CLAUDE.md +9 -184
- data/README.md +26 -22
- data/docs/config/configuracion.md +159 -0
- data/docs/interface/interface.md +129 -0
- data/docs/release/release.md +49 -0
- data/docs/test/testing.md +163 -0
- data/lib/exis_ray/configuration.rb +36 -20
- data/lib/exis_ray/json_formatter.rb +124 -91
- data/lib/exis_ray/log_sanitizer.rb +253 -0
- data/lib/exis_ray/log_subscriber.rb +3 -19
- data/lib/exis_ray/railtie.rb +3 -3
- data/lib/exis_ray/sanitizing_formatter.rb +65 -0
- data/lib/exis_ray/task_monitor.rb +3 -12
- data/lib/exis_ray/version.rb +1 -1
- data/lib/exis_ray.rb +18 -0
- data/skill/SKILL.md +10 -11
- data/skill/references/standard.md +2 -2
- data/skills.yml +6 -24
- data/spec/exis_ray/configuration_spec.rb +6 -18
- data/spec/exis_ray/install_log_formatter_spec.rb +35 -0
- data/spec/exis_ray/json_formatter_spec.rb +139 -26
- data/spec/exis_ray/log_sanitizer_spec.rb +293 -0
- data/spec/exis_ray/log_subscriber_spec.rb +1 -27
- data/spec/exis_ray/sanitizing_formatter_spec.rb +96 -0
- data/spec/exis_ray/task_monitor_spec.rb +0 -15
- metadata +14 -5
- data/.gemini/docs/TELEMETRY_GUIDELINES.md +0 -32
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Configuración — exis_ray
|
|
2
|
+
|
|
3
|
+
> meta: artefacto · RFC-012 (12-Factor App §III, shape v2.2) · generado arch-structure + arch-enrich · anclado a commit `7db39ca` (v0.11.0); las filas de filtrado y topes (§b, §f.7, §i, §j) actualizadas a mano leyendo el código en `21bb813` (exis_ray#23) · cobertura **inventario base completa · §f enriquecido 17/17 · §j mapeado 2/2**
|
|
4
|
+
|
|
5
|
+
## 1. Resumen
|
|
6
|
+
|
|
7
|
+
Gema de tracing/observabilidad. Configuración pública vía `ExisRay.configure do |config| ... end` (clase `ExisRay::Configuration`, 16 opciones: las de trazas con defaults compatibles AWS X-Ray, y 6 de filtrado y topes de los logs) + 1 env var de runtime (`HOSTNAME`). Sin scheduler propio; el `Railtie` inyecta middlewares, formatter de logs e instrumentación de Sidekiq/BugBunny/ActiveResource al host durante el boot.
|
|
8
|
+
|
|
9
|
+
## 2. Cuerpo
|
|
10
|
+
|
|
11
|
+
### §a Hecho verificable
|
|
12
|
+
|
|
13
|
+
| métrica | conteo |
|
|
14
|
+
|---|---|
|
|
15
|
+
| total vars/opciones | 17 |
|
|
16
|
+
| requeridas | 0 |
|
|
17
|
+
| con default | 17 |
|
|
18
|
+
| derivadas | 2 |
|
|
19
|
+
| secretas | 0 |
|
|
20
|
+
|
|
21
|
+
### §b Inventario base
|
|
22
|
+
|
|
23
|
+
| nombre | tipo | requerida | default | origen | consumidor (file:line) | secret? |
|
|
24
|
+
|---|---|---|---|---|---|---|
|
|
25
|
+
| `trace_header` | String | no | `"HTTP_X_AMZN_TRACE_ID"` | code-default | `configuration.rb:76` | no |
|
|
26
|
+
| `propagation_trace_header` | String | no | `"X-Amzn-Trace-Id"` | code-default | `configuration.rb:77` | no |
|
|
27
|
+
| `reporter_class` | String/Class/nil | no | `nil` | code-default | `configuration.rb:78` | no |
|
|
28
|
+
| `current_class` | String/Class/nil | no | `nil` | code-default | `configuration.rb:79` | no |
|
|
29
|
+
| `log_format` | Symbol | no | `:text` | code-default | `configuration.rb:80` | no |
|
|
30
|
+
| `log_subscriber_class` | String/nil | no | `nil` | code-default | `configuration.rb:81` | no |
|
|
31
|
+
| `service_version` | String/nil | no | `derived(Rails config.version ∥ config.x.version)` | derived | `configuration.rb:82,93-111` | no |
|
|
32
|
+
| `deployment_environment` | String/nil | no | `derived(Rails.env)` | derived | `configuration.rb:83,113-117` | no |
|
|
33
|
+
| `filtered_keys` | Array<String, Symbol>/nil | no | `nil` | code-default | `configuration.rb:117`, `log_sanitizer.rb` `#sensitive?` | no |
|
|
34
|
+
| `unfiltered_keys` | Array<String, Symbol>/nil | no | `nil` | code-default | `configuration.rb:118`, `log_sanitizer.rb` `#sensitive?` | no |
|
|
35
|
+
| `max_value_chars` | Integer | no | `500` | code-default | `configuration.rb:119`, `log_sanitizer.rb` `#truncate` | no |
|
|
36
|
+
| `max_array_items` | Integer | no | `100` | code-default | `configuration.rb:120`, `log_sanitizer.rb` `#walk_array` | no |
|
|
37
|
+
| `max_line_bytes` | Integer | no | `8192` | code-default | `configuration.rb:121`, `json_formatter.rb` `#limit_line`, `sanitizing_formatter.rb` `#limit` | no |
|
|
38
|
+
| `max_traverse_bytes` | Integer | no | `65536` | code-default | `configuration.rb:122`, `log_sanitizer.rb` `#walk_string` | no |
|
|
39
|
+
| `HOSTNAME` | String | no | `"local"` (fallback) | env | `task_monitor.rb:81` | no |
|
|
40
|
+
|
|
41
|
+
> Solo shape — sin valores reales (RFC-012 §3). `requerida=no` en las 10 opciones: el `initialize` siembra default a todas; `HOSTNAME` cae a `"local"` si ausente.
|
|
42
|
+
|
|
43
|
+
### §c Meta-templates
|
|
44
|
+
|
|
45
|
+
`n/a` — sin patrón de sufijo/prefijo repetido ≥3 (no hay service discovery estática `_HOST/_PORT/_PROTOCOL`).
|
|
46
|
+
|
|
47
|
+
### §d Derivaciones simples
|
|
48
|
+
|
|
49
|
+
| var derivada | fórmula | fuente |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| `service_version` | `Rails.application.config.version` → fallback `config.x.version` → `nil` | `configuration.rb:93-111` |
|
|
52
|
+
| `deployment_environment` | `Rails.env.to_s` | `configuration.rb:113-117` |
|
|
53
|
+
| `pod_id` (no-config) | `(ENV["HOSTNAME"] ∥ "local").split("-").last` | `task_monitor.rb:81` |
|
|
54
|
+
|
|
55
|
+
### §e Scheduling
|
|
56
|
+
|
|
57
|
+
`n/a` — la gema no define `sidekiq.yml`/`queue.yml`/`recurring.yml` ni queues/cron propios. **Instrumenta** el Sidekiq del host (middlewares) pero no agenda trabajo — ver §i.
|
|
58
|
+
|
|
59
|
+
### §i Inyecciones al host (Railtie)
|
|
60
|
+
|
|
61
|
+
| inyección | gatillo | efecto | file:line |
|
|
62
|
+
|---|---|---|---|
|
|
63
|
+
| `exis_ray.configure_middleware` | initializer | inserta `ExisRay::HttpMiddleware` after `ActionDispatch::RequestId` (fallback `use`) | `railtie.rb:14-23` |
|
|
64
|
+
| `exis_ray.configure_logging` | initializer (after `:load_config_initializers`) | en modo texto: `app.config.log_tags << proc { trace_id ∥ root_id }` | `railtie.rb:28-36` |
|
|
65
|
+
| validación de clases | `config.after_initialize` | `raise` si `current_class`/`reporter_class` no heredan de base | `railtie.rb:45-53` |
|
|
66
|
+
| formatter de logs | `config.after_initialize` | `ExisRay.install_log_formatter(Rails.logger)`: modo json → `ExisRay::JsonFormatter`; modo texto → el formatter que ya tenía, envuelto en `ExisRay::SanitizingFormatter` (tapa y limita sin cambiar el formato, ADR-131) | `railtie.rb:56`, `exis_ray.rb` `.install_log_formatter` |
|
|
67
|
+
| LogSubscriber HTTP | `config.after_initialize` (modo json) | `ExisRay::LogSubscriber.install!` (reemplaza Lograge/defaults Rails) | `railtie.rb:62` |
|
|
68
|
+
| instrumentación BugBunny | `config.after_initialize` (si `defined?(::BugBunny)`) | consumer middleware + `rpc_reply_headers` + `on_rpc_reply` | `railtie.rb:68-90` |
|
|
69
|
+
| instrumentación ActiveResource | `config.after_initialize` (si `defined?(ActiveResource::Base)`) | `prepend ExisRay::ActiveResourceInstrumentation` | `railtie.rb:93-99` |
|
|
70
|
+
| instrumentación Sidekiq | `config.after_initialize` (si `defined?(::Sidekiq)`) | client/server middleware + `ExisRay.install_log_formatter(::Sidekiq.logger)` (json o texto, igual que Rails) | `railtie.rb:102-123` |
|
|
71
|
+
|
|
72
|
+
### §j Inyección a gemas configuradas
|
|
73
|
+
|
|
74
|
+
| gema configurada | superficie tocada | file:line | mapeo opción local → gema | ancla |
|
|
75
|
+
|---|---|---|---|---|
|
|
76
|
+
| `::BugBunny` | `consumer_middlewares.use ConsumerTracingMiddleware`; `configuration.rpc_reply_headers`; `configuration.on_rpc_reply` | `railtie.rb:71-88` | `propagation_trace_header` → key del header en `rpc_reply_headers` (`railtie.rb:75`) y lectura en `on_rpc_reply` (`railtie.rb:79`). El middleware/consumer no mapea opción de valor. | **integración opcional** (guard `defined?(::BugBunny)`), **no es dependencia declarada** (ausente de gemspec/Gemfile.lock) → sin ancla cross-repo, no aplica `skills.yml` |
|
|
77
|
+
| `::Sidekiq` | `configure_client` / `configure_server` (middleware chains); `Sidekiq.logger.formatter` | `railtie.rb:106-121` | `log_format` → `ExisRay.install_log_formatter(::Sidekiq.logger)` (`railtie.rb:121`): `JsonFormatter` en json, `SanitizingFormatter` sobre el suyo en texto. Las chains de middleware no mapean opción de valor. | **integración opcional** (guard `defined?(::Sidekiq)`), no es dependencia declarada → sin `docs/config/` a linkear |
|
|
78
|
+
|
|
79
|
+
## f. Enriquecimiento semántico
|
|
80
|
+
|
|
81
|
+
> cobertura: 17/17 vars enriquecidas; ausencia ≠ "no aplica".
|
|
82
|
+
|
|
83
|
+
### f.1 Propagación de trace context (`*trace_header`)
|
|
84
|
+
|
|
85
|
+
| var | categoría | failure-mode | side-effect | scope-override | business-reason / definición |
|
|
86
|
+
|---|---|---|---|---|---|
|
|
87
|
+
| `trace_header` | integration | silent-default (cae al header AWS X-Ray si no se setea) | per-request (leído por request) | boot-only | key del header **Rack entrante** que `HttpMiddleware` lee para hidratar el Tracer (`http_middleware.rb:13`); cambiarla solo si el edge/LB usa otro header de traza |
|
|
88
|
+
| `propagation_trace_header` | integration | silent-default | per-request | boot-only | key del header **saliente** que inyectan Faraday/ActiveResource/BugBunny-publisher + RPC reply (`faraday_middleware.rb:20`, `active_resource_instrumentation.rb:31`, `bug_bunny/publisher_tracing.rb:33`, `railtie.rb:75,79`); debe coincidir con el `trace_header` (forma HTTP) del downstream o la cadena se corta |
|
|
89
|
+
|
|
90
|
+
### f.2 Wiring de clases del host (`*_class`)
|
|
91
|
+
|
|
92
|
+
| var | categoría | failure-mode | side-effect | scope-override | business-reason / definición |
|
|
93
|
+
|---|---|---|---|---|---|
|
|
94
|
+
| `current_class` | orchestration | boot-crash @ after-initialize si la clase no hereda de `ExisRay::Current` (`railtie.rb:45-47`); silent-default (`nil` → contexto de negocio no-op) si no existe | restart (prod: memoizado `@current_class_cache`, `exis_ray.rb:78`) · per-request (dev: re-resuelto para Zeitwerk reload, `exis_ray.rb:80`) | boot-only en prod · mutable-singleton en dev | clase del host que provee `user_id`/`isp_id`/`correlation_id`; se pasa como String para evitar `uninitialized constant` en boot |
|
|
95
|
+
| `reporter_class` | orchestration | boot-crash @ after-initialize si no hereda de `ExisRay::Reporter` (`railtie.rb:50-52`); silent-default (`nil` → no se reporta a Sentry) | restart · per-request (idem `current_class`, `exis_ray.rb:95-97`) | boot-only en prod · mutable-singleton en dev | clase del host que envía errores a Sentry con trace context; consumida por TaskMonitor/middlewares al rescatar |
|
|
96
|
+
| `log_subscriber_class` | observability | silent-default (`nil` → `ExisRay::LogSubscriber` base sin `extra_fields`) | restart (`install!` en after_initialize, `log_subscriber.rb:295`) | boot-only | subclase para inyectar `extra_fields` en el log de cierre HTTP; **solo aplica si `json_logs?`** (ver §g) |
|
|
97
|
+
|
|
98
|
+
### f.3 Estrategia de logging (`log_format`)
|
|
99
|
+
|
|
100
|
+
| var | categoría | failure-mode | side-effect | scope-override | business-reason / definición |
|
|
101
|
+
|---|---|---|---|---|---|
|
|
102
|
+
| `log_format` | observability | silent-default (`:text` → tags de Rails, sin JsonFormatter) | restart (decisión tomada en boot tras `load_config_initializers`, `railtie.rb:28-29`) | boot-only | conmuta **toda** la estrategia: `:json` instala JsonFormatter global + LogSubscriber + formatter de Sidekiq (`railtie.rb:56-65,121`); `:text` solo agrega `root_id` como `log_tag`. **Ramificador** (§g). |
|
|
103
|
+
|
|
104
|
+
### f.4 Metadata de recurso OTel
|
|
105
|
+
|
|
106
|
+
| var | categoría | failure-mode | side-effect | scope-override | business-reason / definición |
|
|
107
|
+
|---|---|---|---|---|---|
|
|
108
|
+
| `service_version` | observability | silent-default (`nil` → campo `service_version` omitido del log) | per-request (emitido por línea, `json_formatter.rb:89`) | boot-only (computado una vez de Rails config) | equivale a `service.version` de OTel |
|
|
109
|
+
| `deployment_environment` | observability | silent-default (`nil` → campo omitido) | per-request (`json_formatter.rb:94`) | boot-only (derivado de `Rails.env`) | equivale a `deployment.environment` de OTel |
|
|
110
|
+
|
|
111
|
+
### f.5 Feature-flags de migración OTel (transitorios)
|
|
112
|
+
|
|
113
|
+
No queda ninguno: `emit_legacy_exception_keys` y `emit_legacy_path_key` se borraron en 0.12.0, junto con las claves `error_class`, `error_message` y `path`.
|
|
114
|
+
|
|
115
|
+
### f.6 Identidad de pod (`HOSTNAME`)
|
|
116
|
+
|
|
117
|
+
| var | categoría | failure-mode | side-effect | scope-override | business-reason / definición |
|
|
118
|
+
|---|---|---|---|---|---|
|
|
119
|
+
| `HOSTNAME` | infra | silent-default (`"local"` si ausente) | per-task (leído al generar root en TaskMonitor, `task_monitor.rb:81`) | boot-only (env del contenedor) | sufijo del hostname (post último `-`) como `pod_id` en el `root_id` de tasks; en K8s/Docker lo inyecta el orquestador |
|
|
120
|
+
|
|
121
|
+
### f.7 Filtrado y topes de los logs (ADR-131)
|
|
122
|
+
|
|
123
|
+
Las lee `ExisRay::LogSanitizer`, que usan los dos formatters (json y texto). Se crea uno por línea, así que un cambio en runtime aplica a la línea siguiente.
|
|
124
|
+
|
|
125
|
+
| var | categoría | failure-mode | side-effect | scope-override | business-reason / definición |
|
|
126
|
+
|---|---|---|---|---|---|
|
|
127
|
+
| `filtered_keys` | security | silent-default (`nil` → sólo el default `LogSanitizer::DEFAULT_SENSITIVE`, por "contiene": `password`, `pass`, `passwd`, `secret`, `token`, `api[_-]key`, `auth`, `credential`, `private[_-]key`, `csrf`, `session[_-]id`) | per-line | mutable-singleton | claves que **este servicio** tapa además del default, por nombre exacto y sin distinguir mayúsculas. Tapa el valor entero (aunque sea un Hash o un Array), en Hashes y en texto (`clave=valor`, `"clave" => valor`, `a[clave]=valor`). BCM y BMS: `%w[data]` |
|
|
128
|
+
| `unfiltered_keys` | security | silent-default (`nil` → no se destapa nada) | per-line | mutable-singleton | claves que el default tapa y el servicio necesita ver (falsos positivos de "contiene", p. ej. `author`), por nombre exacto. **Nunca** destapa una clave de `filtered_keys`. Vale igual en texto: es la vía para que un servicio deje ver el password de PPPoE si lo loguea con clave `password` |
|
|
129
|
+
| `max_value_chars` | observability | silent-default | per-line | mutable-singleton | caracteres por valor string; lo que pasa se corta con `…[TRUNCATED size=N]` (N en **caracteres**). No aplica al mensaje entero ni a `LogSanitizer::DIAGNOSTIC_KEYS` |
|
|
130
|
+
| `max_array_items` | observability | silent-default | per-line | mutable-singleton | elementos por array; los que sobran se reemplazan por `"[TRUNCATED count=N]"` |
|
|
131
|
+
| `max_line_bytes` | observability | silent-default | per-line | mutable-singleton | bytes por línea. JSON: reemplaza primero los campos más grandes que no son de contexto ni de diagnóstico, después recorta el diagnóstico conservando el principio (orden de `DIAGNOSTIC_KEYS`), y si no entra deja el contexto con `truncated: true`; nunca rompe el JSON. Texto: corta en un borde UTF-8 válido. Marcador con N en **bytes**. Con un valor menor a 64, en texto la línea sale como `filter_error=NoMethodError` y en JSON queda sólo el contexto con `truncated: true` (medido con 32) |
|
|
132
|
+
| `max_traverse_bytes` | performance | silent-default | per-line | mutable-singleton | un string más grande no se recorre ni se parsea: se reemplaza entero por `"[TOO_LARGE size=N]"`, salvo el mensaje entero y el diagnóstico, que se recortan a ese tamaño por el principio y se tapan. Acota el costo de tapar por línea |
|
|
133
|
+
|
|
134
|
+
**Threading (§h):** los callbacks RPC de BugBunny (`on_rpc_reply`, `railtie.rb:77-88`) corren en el **thread del publisher** y resuelven `reporter_class`/`current_class` vía los helpers memoizados. `ExisRay::Tracer`/`Current` heredan `ActiveSupport::CurrentAttributes` (thread/fiber-local). Constraint: el valor de config es un singleton global; las clases resueltas se comparten entre threads — safe porque son class objects inmutables tras boot.
|
|
135
|
+
|
|
136
|
+
**Ramificadores intra-config (§g):**
|
|
137
|
+
|
|
138
|
+
- `log_format=:json` (vía `json_logs?`) ramifica la aplicabilidad de **`log_subscriber_class`** (inerte en `:text` — `install!` solo corre en modo json) y elige el formatter de Rails y de Sidekiq (`ExisRay.install_log_formatter`, `railtie.rb:56,121`): `JsonFormatter` en json, `SanitizingFormatter` sobre el que ya tenían en texto.
|
|
139
|
+
- `filtered_keys` le gana a `unfiltered_keys`: una clave en las dos listas se tapa.
|
|
140
|
+
|
|
141
|
+
## 3. Inferencias
|
|
142
|
+
|
|
143
|
+
| ítem | confidence | a verificar |
|
|
144
|
+
|---|---|---|
|
|
145
|
+
| `HOSTNAME` clasificada `requerida=no` | declared | fallback `"local"` explícito en `task_monitor.rb:81` — confirmado |
|
|
146
|
+
| `service_version`/`deployment_environment` como `derived` | declared | defaults computados en `initialize` vía `default_*` — confirmado |
|
|
147
|
+
| sin secretos | declared | ninguna opción matchea `*_KEY|*_SECRET|*_PASS|*_TOKEN` ni literal sensible — confirmado |
|
|
148
|
+
| `reporter_class`/`current_class` aceptan String o Class | declared | YARD `@return [String, Class, nil]`; el `safe_constantize` del Railtie asume String — verificar uso real |
|
|
149
|
+
| `::BugBunny`/`::Sidekiq` sin ancla cross-repo (§j) | declared | son **integraciones opcionales** (guard `defined?`), no dependencias declaradas (ausentes de gemspec/Gemfile.lock) — la gema inyecta hooks si el host las tiene. Por eso NO van en `skills.yml`: no hay relación de consumo que anclar |
|
|
150
|
+
| `scope-override` boot-only vs mutable-singleton de `*_class` (§f.2) | inferred | depende de `cache_classes?` (`exis_ray.rb:118-128`): prod memoiza (boot-only), dev re-resuelve por request (mutable). Verificar que el host no mute `configuration.*_class` post-boot |
|
|
151
|
+
|
|
152
|
+
## 4. Cobertura y fronteras
|
|
153
|
+
|
|
154
|
+
- **Inventario base completo** — las 17 vars/opciones del código están listadas (las 6 de filtrado y topes, contra `21bb813`).
|
|
155
|
+
- ⚠️ **Drift previo a exis_ray#23, sin corregir:** varias anclas `configuration.rb:NN` de las filas de v0.11.0 (§b) ya no apuntan a la línea del default (p. ej. `trace_header` está en `configuration.rb:107`, no en `:76`).
|
|
156
|
+
- **Enriquecimiento §f completo 17/17** — categoría · failure-mode · side-effect · scope-override · business-reason por opción, + threading (§h) y ramificadores (§g). Anclado al consumidor real (`file:line`); las inferencias quedan en §3 para verificación humana.
|
|
157
|
+
- **Mapeo §j → gema completo 2/2** — `propagation_trace_header`→BugBunny RPC headers; `log_format`→Sidekiq formatter. Ancla cross-repo de BugBunny pendiente (no declarada en `skills.yml`, ver §3).
|
|
158
|
+
- **Fuera de alcance:** `ENV["TENANT_ID"]` en `current.rb:22` es **ejemplo en comentario YARD** (no consumo real) → no se lista. Vars de Rails core (`SECRET_KEY_BASE`, `RAILS_ENV`, etc.) las aporta la app host, no esta gema.
|
|
159
|
+
- **`config.x.version`** (lectura de `service_version`) depende del host — la gema solo lee, no define.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Interfaz — exis_ray
|
|
2
|
+
|
|
3
|
+
> meta: artefacto · RFC-004 (RBS firmas como modelo conceptual) · generado arch-structure · anclado a commit `b7b96c7` (v0.11.0); filas de logs (`install_log_formatter`, `SanitizingFormatter`, §4) actualizadas a mano leyendo el código en `21bb813` (exis_ray#23) · cobertura **superficie pública consumer-facing completa**
|
|
4
|
+
|
|
5
|
+
## 1. Resumen
|
|
6
|
+
|
|
7
|
+
API Ruby pública de la gema: módulo `ExisRay` (config + resolución de clases host), 2 bases abstractas que el host subclasea (`Current`, `Reporter`), el contexto de trazabilidad (`Tracer`), el formatter/subscriber de logs, el monitor de tasks, y 7 middlewares de propagación (HTTP/Faraday/ActiveResource/Sidekiq×2/BugBunny×2). Las clases configurables (`Configuration`) se documentan en detalle en [`docs/config/configuracion.md`](../config/configuracion.md).
|
|
8
|
+
|
|
9
|
+
## 2. Superficie pública (símbolo · tipo · firma · nota)
|
|
10
|
+
|
|
11
|
+
### `ExisRay` (módulo raíz)
|
|
12
|
+
|
|
13
|
+
| símbolo | tipo | firma | nota |
|
|
14
|
+
|---|---|---|---|
|
|
15
|
+
| `ExisRay::VERSION` | const | `String` | `"0.11.0"` (`version.rb:5`) |
|
|
16
|
+
| `ExisRay::Error` | class | `< StandardError` | error base de la gema (`exis_ray.rb:36`) |
|
|
17
|
+
| `ExisRay.configure` | method | `() { (Configuration) -> void } -> void` | bloque de configuración (`exis_ray.rb:60`) |
|
|
18
|
+
| `ExisRay.configuration` | method | `() -> Configuration` | instancia singleton (`exis_ray.rb:46`) |
|
|
19
|
+
| `ExisRay.configuration=` | writer | `(Configuration) -> void` | reemplaza la config — uso en tests (`exis_ray.rb:40`) |
|
|
20
|
+
| `ExisRay.install_log_formatter` | method | `(Logger?) -> void` | pone el formatter según `log_format`: `JsonFormatter` en json, el que ya tenía envuelto en `SanitizingFormatter` en texto; `nil` no hace nada. Lo usa el Railtie para Rails y Sidekiq (`exis_ray.rb:72`) |
|
|
21
|
+
| `ExisRay.current_class` | method | `() -> Class?` | resuelve `config.current_class`; memoizado en prod, re-resuelto en dev (`exis_ray.rb:71`) |
|
|
22
|
+
| `ExisRay.reporter_class` | method | `() -> Class?` | resuelve `config.reporter_class` (`exis_ray.rb:88`) |
|
|
23
|
+
| `ExisRay.sync_correlation_id` | method | `() -> void` | copia `Tracer.correlation_id` → `Current.correlation_id` (`exis_ray.rb:105`) |
|
|
24
|
+
|
|
25
|
+
### `ExisRay::Configuration` (clase)
|
|
26
|
+
|
|
27
|
+
| símbolo | tipo | firma | nota |
|
|
28
|
+
|---|---|---|---|
|
|
29
|
+
| `Configuration#<attr>` | accessor (rw) | — | 10 opciones (`trace_header`, `log_format`, `current_class`, ...) — inventario y semántica en [`docs/config/`](../config/configuracion.md) |
|
|
30
|
+
| `Configuration#json_logs?` | method | `() -> bool` | `true` si `log_format == :json` (`configuration.rb:122`) |
|
|
31
|
+
|
|
32
|
+
### `ExisRay::Tracer` (`< ActiveSupport::CurrentAttributes`)
|
|
33
|
+
|
|
34
|
+
| símbolo | tipo | firma | nota |
|
|
35
|
+
|---|---|---|---|
|
|
36
|
+
| `Tracer.<attr>` | accessor (rw) | — | `trace_id · request_id · root_id · self_id · called_from · total_time_so_far · created_at · sidekiq_job · source · task` (`tracer.rb:15`) |
|
|
37
|
+
| `Tracer.hydrate` | method | `(trace_id:, source:) -> void` | inicializa el contexto desde header entrante (`tracer.rb:78`) |
|
|
38
|
+
| `Tracer.generate_trace_header` | method | `() -> String` | header para propagar al siguiente servicio (`tracer.rb:115`) |
|
|
39
|
+
| `Tracer.parse_trace_id` | method | `() -> void` | extrae `root_id`/`self_id`/`called_from`/`total_time_so_far` del `trace_id` (`tracer.rb:40`) |
|
|
40
|
+
| `Tracer.service_name` | method | `() -> String` | nombre del servicio (de `Rails.application`) (`tracer.rb:22`) |
|
|
41
|
+
| `Tracer.correlation_id` | method | `() -> String` | compuesto `service_name;root_id` (`tracer.rb:32`) |
|
|
42
|
+
| `Tracer.current_duration_s` | method | `() -> Float` | segundos desde `created_at` (monotónico) (`tracer.rb:89`) |
|
|
43
|
+
| `Tracer.current_duration_ms` | method | `() -> Integer` | milisegundos desde `created_at` (`tracer.rb:67`) |
|
|
44
|
+
| `Tracer.format_duration` | method | `(Float seconds) -> String` | formato humano (`"7.0ms"`, `"2 minutes 5 seconds"`) (`tracer.rb:102`) |
|
|
45
|
+
|
|
46
|
+
### `ExisRay::Current` (`< ActiveSupport::CurrentAttributes`, base abstracta — el host subclasea)
|
|
47
|
+
|
|
48
|
+
| símbolo | tipo | firma | nota |
|
|
49
|
+
|---|---|---|---|
|
|
50
|
+
| `Current.<attr>` | accessor (rw) | — | `user_id · isp_id · correlation_id` (`current.rb:9`) |
|
|
51
|
+
| `Current.user_id=` | setter | `(Integer?) -> void` | usa `!nil?` (acepta `0`) + sincroniza PaperTrail/ActiveResource (`current.rb:54`) |
|
|
52
|
+
| `Current.isp_id=` | setter | `(Integer?) -> void` | ídem (`current.rb:63`) |
|
|
53
|
+
| `Current.correlation_id=` | setter | `(String?) -> void` | propaga a Session/Reporter (`current.rb:71`) |
|
|
54
|
+
| `Current.user=` / `Current.user` | accessor | `(obj) -> void` / `() -> User?` | asigna `user_id` de `obj.id` / lazy-load memoizado (`current.rb:84,88`) |
|
|
55
|
+
| `Current.isp=` / `Current.isp` | accessor | `(obj) -> void` / `() -> Isp?` | ídem (`current.rb:95,99`) |
|
|
56
|
+
| `Current.user?` / `Current.isp?` | predicate | `() -> bool` | true si el id `!nil?` (`current.rb:106,110`) |
|
|
57
|
+
| `Current.correlation_id?` | predicate | `() -> bool` | true si `present?` (`current.rb:116`) |
|
|
58
|
+
| `Current.log_fields` | hook | `() -> Hash` | **override** para inyectar campos custom en cada log; default `{}` (`current.rb:31`) |
|
|
59
|
+
|
|
60
|
+
### `ExisRay::Reporter` (`< ActiveSupport::CurrentAttributes`, base abstracta — el host subclasea)
|
|
61
|
+
|
|
62
|
+
| símbolo | tipo | firma | nota |
|
|
63
|
+
|---|---|---|---|
|
|
64
|
+
| `Reporter.report` | method | `(String message, context: {}, tags: {}, fingerprint: [], transaction_name: nil) -> void` | reporta mensaje a Sentry (`reporter.rb:24`) |
|
|
65
|
+
| `Reporter.exception` | method | `(Exception excep, context: {}, tags: {}, fingerprint: [], transaction_name: nil) -> void` | reporta excepción (`reporter.rb:33`) |
|
|
66
|
+
| `Reporter.add_context` | method | `(Hash attrs) -> void` | acumula contexto (`reporter.rb:58`) |
|
|
67
|
+
| `Reporter.add_tags` | method | `(Hash attrs) -> void` | acumula tags (`reporter.rb:64`) |
|
|
68
|
+
| `Reporter.add_fingerprint` | method | `(value) -> void` | acumula fingerprint (`reporter.rb:52`) |
|
|
69
|
+
| `Reporter.build_custom_context` | hook | `() -> void` | **override** para contexto específico del servicio (`reporter.rb:70`) |
|
|
70
|
+
| `Reporter.sentry_user_context` | hook | `(current) -> Hash` | **override**; default `{ id: user_id }` (`reporter.rb:196`) |
|
|
71
|
+
| `Reporter.sentry_isp_context` | hook | `(current) -> Hash` | **override** (`reporter.rb:205`) |
|
|
72
|
+
|
|
73
|
+
### `ExisRay::JsonFormatter` (`< ::Logger::Formatter`)
|
|
74
|
+
|
|
75
|
+
| símbolo | tipo | firma | nota |
|
|
76
|
+
|---|---|---|---|
|
|
77
|
+
| `JsonFormatter#call` | method | `(severity, timestamp, progname, msg) -> String` | interfaz `Logger::Formatter`; emite JSON single-line con contexto inyectado, con lo sensible tapado y la línea dentro de `max_line_bytes` (ADR-131). Si tapar o escribir falla, emite el contexto con `filter_error`, nunca el mensaje (`json_formatter.rb:51`) |
|
|
78
|
+
|
|
79
|
+
### `ExisRay::SanitizingFormatter` (`< SimpleDelegator`)
|
|
80
|
+
|
|
81
|
+
| símbolo | tipo | firma | nota |
|
|
82
|
+
|---|---|---|---|
|
|
83
|
+
| `SanitizingFormatter.install` | method | `(Logger?) -> void` | envuelve el formatter de un logger (o de cada logger de un `BroadcastLogger`), una sola vez (`sanitizing_formatter.rb:18`) |
|
|
84
|
+
| `SanitizingFormatter#call` | method | `(severity, time, progname, msg) -> String` | modo texto: le pasa al formatter envuelto el mensaje tapado y limitado; el formato no cambia. Si tapar falla, el mensaje es `filter_error=<clase>` (`sanitizing_formatter.rb:30`) |
|
|
85
|
+
|
|
86
|
+
### `ExisRay::LogSubscriber` (`< ActiveSupport::LogSubscriber`)
|
|
87
|
+
|
|
88
|
+
| símbolo | tipo | firma | nota |
|
|
89
|
+
|---|---|---|---|
|
|
90
|
+
| `LogSubscriber.install!` | method | `() -> void` | suscribe y suprime los subscribers default de Rails (`log_subscriber.rb:68`) |
|
|
91
|
+
| `LogSubscriber.attached?` | method | `() -> bool` | si ya está instalado (`log_subscriber.rb:76`) |
|
|
92
|
+
| `LogSubscriber.extra_fields` | hook | `(event) -> Hash` | **override** para campos HTTP extra; default `{}` (`log_subscriber.rb:58`) |
|
|
93
|
+
| `LogSubscriber#process_action` | method | `(event) -> void` | interfaz subscriber; emite el log de cierre de request (`log_subscriber.rb:33`) |
|
|
94
|
+
|
|
95
|
+
### `ExisRay::TaskMonitor` (módulo)
|
|
96
|
+
|
|
97
|
+
| símbolo | tipo | firma | nota |
|
|
98
|
+
|---|---|---|---|
|
|
99
|
+
| `TaskMonitor.run` | method | `(String task_name) { () -> void } -> void` | genera `root_id`, loguea `task_started`/`task_finished`, re-lanza excepciones, resetea contexto (`task_monitor.rb:16`) |
|
|
100
|
+
|
|
101
|
+
### Middlewares de propagación
|
|
102
|
+
|
|
103
|
+
| símbolo | tipo | firma | nota |
|
|
104
|
+
|---|---|---|---|
|
|
105
|
+
| `ExisRay::HttpMiddleware` | class (Rack) | `#initialize(app)` · `#call(env) -> Array` | auto-insertado tras `ActionDispatch::RequestId` (`http_middleware.rb`) |
|
|
106
|
+
| `ExisRay::FaradayMiddleware` | class (`< Faraday::Middleware`) | `#call(env)` | **manual** en el stack Faraday (`faraday_middleware.rb`) |
|
|
107
|
+
| `ExisRay::ActiveResourceInstrumentation` | module (prepend) | `#headers -> Hash` | auto-prepend a `ActiveResource::Base` (`active_resource_instrumentation.rb`) |
|
|
108
|
+
| `ExisRay::Sidekiq::ClientMiddleware` | class | `#call(worker_class, job, queue, redis_pool = nil) { }` | auto-registrado (client) (`sidekiq/client_middleware.rb`) |
|
|
109
|
+
| `ExisRay::Sidekiq::ServerMiddleware` | class | `#call(worker, job, queue) { }` | auto-registrado (server) (`sidekiq/server_middleware.rb`) |
|
|
110
|
+
| `ExisRay::BugBunny::PublisherTracing` | class (`< ::BugBunny::Middleware::Base`) | `#on_request(env)` | **manual** en el cliente (`bug_bunny/publisher_tracing.rb`) |
|
|
111
|
+
| `ExisRay::BugBunny::ConsumerTracingMiddleware` | class (`< ::BugBunny::ConsumerMiddleware::Base`) | `#call(delivery_info, properties, body)` | auto-registrado (consumer) (`bug_bunny/consumer_tracing_middleware.rb`) |
|
|
112
|
+
|
|
113
|
+
## 3. Inferencias
|
|
114
|
+
|
|
115
|
+
| ítem | confidence | a verificar |
|
|
116
|
+
|---|---|---|
|
|
117
|
+
| `Tracer`/`Reporter`/`TaskMonitor` no declaran `private` | declared | métodos helper (`generate_new_root`, `clean_request_id`, `build_from_*`, `*_to_old/new_sentry`, `setup_tracer`, ...) quedan **reachable** Ruby-wise pero NO son contrato — ver §4 (Hyrum's Law) |
|
|
118
|
+
| accesores de `Current`/`Tracer`/`Reporter` como métodos de clase | declared | son `ActiveSupport::CurrentAttributes` → los `attribute :x` exponen `.x`/`.x=` a nivel de clase, thread/fiber-local |
|
|
119
|
+
| middlewares "manual" vs "auto" | declared | Faraday y BugBunny-publisher requieren registro manual; el resto los inyecta el Railtie (ver `docs/config` §i) |
|
|
120
|
+
|
|
121
|
+
## 4. Cobertura y fronteras
|
|
122
|
+
|
|
123
|
+
- **Superficie consumer-facing completa** para v0.11.0 — lo que un host app usa o subclasea.
|
|
124
|
+
- **Helpers públicos-Ruby pero NO contrato:** `Tracer.generate_new_root` / `.clean_request_id`; `Reporter.build_from_tracer` / `.build_from_current` / `.*_to_old_sentry` / `.*_to_new_sentry` / `.session_*`; `TaskMonitor.setup_tracer` / `.pod_identifier` / `.log_event` / `.format_*`; helpers privados de `Current` (`assign_session_request_id`, `sync_reporter_correlation_id`, `sanitize_header_value` — sí marcados `private`, `current.rb:120`). Reachable por falta de `private` (salvo Current), pero son detalle de implementación; cambiar su firma no es breaking de contrato.
|
|
125
|
+
- **Internos del formatter/subscriber:** los `inject_*`/`extract_*`/`parse_*` de `JsonFormatter` y `LogSubscriber` son privados de implementación — el contrato es `#call` / `#process_action` + los hooks de override.
|
|
126
|
+
- **`ExisRay::LogSanitizer`** (`log_sanitizer.rb`): la pieza que decide qué se tapa, usada por los dos formatters. `#call`, `#sensitive?`, `#sanitize_text` y `.truncate_bytes` son públicos-Ruby pero **no contrato**: qué se tapa lo configura el servicio (`filtered_keys` / `unfiltered_keys`, ver `docs/config` §f.7), no llamándolo.
|
|
127
|
+
- **Constantes:** `JsonFormatter::SEVERITY_NUMBER`, `::KV_DETECT_RE` y las de `LogSanitizer` (`DEFAULT_SENSITIVE`, `DIAGNOSTIC_KEYS`, `SENSITIVE_VALUE`, …) son detalle interno, no contrato. `JsonFormatter::SENSITIVE_KEYS` se eliminó en exis_ray#23 (grep en los clones de `services/` y `gems/`: 0 usos).
|
|
128
|
+
- **Configuración:** el shape de `Configuration` (defaults, tipos, failure-modes) vive en [`docs/config/configuracion.md`](../config/configuracion.md) — acá solo se lista la clase y `json_logs?`.
|
|
129
|
+
- **Comportamiento runtime** (secuencias de hidratación/emisión) → [`docs/behavior/behavior.md`](../behavior/behavior.md); **significado de términos** → [`docs/glossary/glossary.md`](../glossary/glossary.md).
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Release — exis_ray
|
|
2
|
+
|
|
3
|
+
> meta: artefacto release · RFC-014 · escrito a mano por el agente en el release 1.0.0 (2026-12-02), leyendo `.github/workflows/release.yml`, `.github/workflows/main.yml`, `exis_ray.gemspec`, `lib/exis_ray/version.rb` y `CHANGELOG.md` — **no** lo generó `arch-structure` · sin verificación humana todavía · cobertura: §a estructura completa; §b deploy/rollback/ambientes según el régimen de gema (igual que `bug_bunny` y `docker-swarm`)
|
|
4
|
+
|
|
5
|
+
## 1. Resumen
|
|
6
|
+
|
|
7
|
+
Gema Ruby publicada en RubyGems. Release por **tag `v*`**: el push del tag dispara el workflow `Publish to RubyGems`, que hace `gem build` + `gem push`. Una gema no despliega: publica. No hay `Dockerfile`, branches de ambiente ni staging.
|
|
8
|
+
|
|
9
|
+
## 2. Cuerpo
|
|
10
|
+
|
|
11
|
+
### §a Estructura (verificable del código)
|
|
12
|
+
|
|
13
|
+
| campo | valor | fuente |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| versión actual | `1.0.0` | `lib/exis_ray/version.rb` (`ExisRay::VERSION`) ← `exis_ray.gemspec` (`spec.version`) |
|
|
16
|
+
| esquema de versión | SemVer (`MAJOR.MINOR.PATCH`); desde 1.0 un minor no rompe | `CHANGELOG.md` |
|
|
17
|
+
| artefacto liberado | gema `exis_ray` a RubyGems | `exis_ray.gemspec` (`spec.name`), `.github/workflows/release.yml` |
|
|
18
|
+
| changelog | `CHANGELOG.md`, una entrada fechada por versión | `CHANGELOG.md` |
|
|
19
|
+
| licencia | MIT | `exis_ray.gemspec` (`spec.license`) |
|
|
20
|
+
| build-trigger | push de tag `v*` | `.github/workflows/release.yml` (`on.push.tags: ['v*']`) |
|
|
21
|
+
| patrón de trigger (RFC-014) | patrón 1 — publish per-repo-visible (tag → RubyGems) | `.github/workflows/release.yml` |
|
|
22
|
+
| runner de release | `ubuntu-latest`, Ruby `3.2` | `.github/workflows/release.yml` |
|
|
23
|
+
| pasos de publish | `gem build *.gemspec` + `gem push *.gem` | `.github/workflows/release.yml` |
|
|
24
|
+
| credencial de publish | `secrets.RUBYGEMS_API_KEY` | `.github/workflows/release.yml` |
|
|
25
|
+
| Ruby mínimo | `>= 2.6.0` | `exis_ray.gemspec` (`required_ruby_version`) |
|
|
26
|
+
| contenido empaquetado | todo lo trackeado por git salvo `bin/`, `Gemfile*`, `.gitignore`, `.github/`, `.rubocop.yml` y el gemspec: incluye `lib`, `skill` y `docs` (version-locked, RFC-008) | `exis_ray.gemspec` (`spec.files`) |
|
|
27
|
+
| CI (no gatea el release) | workflow `Ruby` (`main.yml`), Ruby `3.4.4`, `bundle exec rake`. Corre en `pull_request` y en push a **`master`** — la rama por defecto es `main`, así que **no corre en push a `main`** | `.github/workflows/main.yml` |
|
|
28
|
+
| dependencias runtime | `activesupport >= 6.0`, `railties >= 6.0` | `exis_ray.gemspec` |
|
|
29
|
+
|
|
30
|
+
### §b Deploy · rollback · ambientes
|
|
31
|
+
|
|
32
|
+
| dimensión | valor |
|
|
33
|
+
|---|---|
|
|
34
|
+
| deploy | disponibilidad en RubyGems tras el `gem push`; cada servicio la toma al subir su `Gemfile` |
|
|
35
|
+
| rollback | un patch nuevo con el arreglo. RubyGems no deja re-publicar el mismo número; `gem yank` sólo en casos graves (rompe a quien fijó esa versión) |
|
|
36
|
+
| ambientes | no aplica: un solo artefacto |
|
|
37
|
+
| dueño del release | Gabriel (mantenedor) |
|
|
38
|
+
|
|
39
|
+
## 3. Inferencias
|
|
40
|
+
|
|
41
|
+
| afirmación | confidence | a verificar |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| El tag publica aunque el CI no haya corrido | declared | `release.yml` no depende de `main.yml`; el gate es local (la skill `gem-release`) |
|
|
44
|
+
| El CI no corre en push a `main` | declared | `main.yml` escucha `branches: [master]`; la rama por defecto del repo es `main` |
|
|
45
|
+
|
|
46
|
+
## 4. Cobertura y fronteras
|
|
47
|
+
|
|
48
|
+
- El paso a paso del release lo ejecuta la skill `gem-release`; esto documenta el contrato.
|
|
49
|
+
- La configuración runtime vive en `docs/config/configuracion.md`; la suite, en `docs/test/testing.md`.
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Test — exis_ray
|
|
2
|
+
|
|
3
|
+
> meta: artefacto test · RFC-013 (shape v2.1, `accepted`) · generado
|
|
4
|
+
> manualmente (**piloto RFC-013** — suplemento de gema para validar §j/§k;
|
|
5
|
+
> predata el soporte de `test` en `arch-structure`, futura regeneración vía
|
|
6
|
+
> esa skill) · anclado a `spec/` · fecha 2026-06-01 · cobertura: completa para los
|
|
7
|
+
> componentes aislados; gap real en inyección del Railtie (sin dummy app) y
|
|
8
|
+
> matrix de versiones (CI mono-versión).
|
|
9
|
+
|
|
10
|
+
## 1. Resumen
|
|
11
|
+
|
|
12
|
+
Estrategia y cobertura de test de la gema (Railtie de observabilidad). Stack:
|
|
13
|
+
**RSpec**, 11 suites / **244** examples (conteo con `rspec --dry-run` por archivo, rama de exis_ray#24), **sin SimpleCov**. Cada componente se
|
|
14
|
+
testea **aislado con mocks de Rails** (`stub_const`), no contra una app real.
|
|
15
|
+
Filosofía **test-last + FDD**. Este artefacto es el **suplemento gema** del
|
|
16
|
+
piloto RFC-013: ejercita §j (inyección al host + matrix) y confirma que §k
|
|
17
|
+
(concurrencia) es **n/a** acá.
|
|
18
|
+
|
|
19
|
+
## 2. Cuerpo
|
|
20
|
+
|
|
21
|
+
### a. Hecho verificable
|
|
22
|
+
|
|
23
|
+
- **Suites:** 11 / **244** examples (todos unit aislados).
|
|
24
|
+
- **Modo:** `railtie`/`library` (no http/worker — es gema).
|
|
25
|
+
- **Factories:** 0 (Structs/doubles inline).
|
|
26
|
+
- **Regresiones post-incidente:** 2 (#9, #12) — **con** comentario de origen
|
|
27
|
+
(§h, convención ya practicada).
|
|
28
|
+
- **% coverage:** `n/a (sin tooling)`.
|
|
29
|
+
- **Inyecciones al host testeadas:** 0 de ~7 (§j) — sin dummy app. Lo que sí se testea desde exis_ray#23 es la
|
|
30
|
+
**decisión** de qué formatter poner (`ExisRay.install_log_formatter`, que el Railtie llama para Rails y Sidekiq),
|
|
31
|
+
no que el Railtie la llame.
|
|
32
|
+
- **Propiedad:** 1 (`json_formatter_spec.rb`, semilla fija, 200 mensajes al azar: JSON válido, UTF-8, ≤ 8192 bytes).
|
|
33
|
+
- **Matrix:** declarado Ruby ≥2.6 / Rails ≥6; testeado CI **solo 3.4.4** (§j).
|
|
34
|
+
- **Tests de concurrencia:** 0 (§k n/a).
|
|
35
|
+
|
|
36
|
+
### b. Estrategia / pirámide
|
|
37
|
+
|
|
38
|
+
Todo **unit aislado**: cada clase (`Tracer`, `HttpMiddleware`, `JsonFormatter`,
|
|
39
|
+
`LogSubscriber`, `Configuration`, `Current`, `Reporter`, `TaskMonitor`) se
|
|
40
|
+
testea sola, mockeando `Rails`/`Logger`/`ActionDispatch`. Sin nivel
|
|
41
|
+
integration/system (no hay app real). Mapeo: la gema no mapea a capas de
|
|
42
|
+
servicio — los componentes son su propia superficie (RFC-004 interfaz).
|
|
43
|
+
Momento: **test-last**.
|
|
44
|
+
|
|
45
|
+
### c. Inventario de suites
|
|
46
|
+
|
|
47
|
+
| Suite | Nivel | Modo | Nº specs |
|
|
48
|
+
|---|---|---|---|
|
|
49
|
+
| `spec/exis_ray/json_formatter_spec.rb` | unit | library | 64 |
|
|
50
|
+
| `spec/exis_ray/log_sanitizer_spec.rb` | unit | library | 46 |
|
|
51
|
+
| `spec/exis_ray/log_subscriber_spec.rb` | unit | railtie | 29 |
|
|
52
|
+
| `spec/exis_ray/tracer_spec.rb` | unit | library | 27 |
|
|
53
|
+
| `spec/exis_ray/configuration_spec.rb` | unit | library | 27 |
|
|
54
|
+
| `spec/exis_ray/current_spec.rb` | unit | library | 16 |
|
|
55
|
+
| `spec/exis_ray/reporter_spec.rb` | unit | library | 8 |
|
|
56
|
+
| `spec/exis_ray/task_monitor_spec.rb` | unit | library | 8 |
|
|
57
|
+
| `spec/exis_ray/http_middleware_spec.rb` | unit | railtie | 7 |
|
|
58
|
+
| `spec/exis_ray/sanitizing_formatter_spec.rb` | unit | library | 9 |
|
|
59
|
+
| `spec/exis_ray/install_log_formatter_spec.rb` | unit | railtie | 3 |
|
|
60
|
+
|
|
61
|
+
Invocación: `bundle exec rake` (RSpec + RuboCop), ~1.2s.
|
|
62
|
+
|
|
63
|
+
### d. Cobertura declarada
|
|
64
|
+
|
|
65
|
+
| Flujo crítico | Cubierto? | Spec | Fuente del gap |
|
|
66
|
+
|---|---|---|---|
|
|
67
|
+
| Trace propagation (parse X-Ray headers, root_id) | sí | `spec/exis_ray/tracer_spec.rb`, `http_middleware_spec.rb` | — |
|
|
68
|
+
| JSON log formatting + OTel + filtrado sensible | sí | `spec/exis_ray/json_formatter_spec.rb`, `log_sanitizer_spec.rb` | — |
|
|
69
|
+
| Filtrado y topes en modo texto (ADR-131) | sí | `spec/exis_ray/sanitizing_formatter_spec.rb`, `install_log_formatter_spec.rb` | — |
|
|
70
|
+
| LogSubscriber (HTTP status → log level) | sí | `spec/exis_ray/log_subscriber_spec.rb` | — |
|
|
71
|
+
| **Inyección del Railtie en app real** | **no** | — (sin `spec/dummy/`) | inferido — componentes testeados aislados; la inyección (`lib/exis_ray/railtie.rb`) no se ejercita (§j) |
|
|
72
|
+
|
|
73
|
+
`% coverage: n/a`. Gap nominal: la **inyección** (lo que distingue a una gema
|
|
74
|
+
Railtie) no tiene test — solo la lógica de cada componente por separado.
|
|
75
|
+
|
|
76
|
+
### e. Fixtures / factories / test data
|
|
77
|
+
|
|
78
|
+
Sin FactoryBot, sin fixtures, sin PII. Datos sintéticos inline: Structs
|
|
79
|
+
(`build_event`, `build_route` en `log_subscriber_spec.rb`), `stub_const` de
|
|
80
|
+
`Rails`/`Tracer`/`Logger`. n/a la columna entidad (gema sin capa de datos).
|
|
81
|
+
|
|
82
|
+
### f. Topología de integration/system tests
|
|
83
|
+
|
|
84
|
+
**n/a** — no se levanta nada real (sin DB/broker/app). Todo mockeado:
|
|
85
|
+
`Rails`, `Rails.application`, `Logger`, `ActionDispatch::*` vía `stub_const`/
|
|
86
|
+
`instance_double`. Estado requerido para correr: **ninguno** (solo
|
|
87
|
+
`activesupport`). No es el sub-caso "gema-envuelve-infra" (exis_ray no envuelve
|
|
88
|
+
infra externa; instrumenta el host).
|
|
89
|
+
|
|
90
|
+
### g. Contract tests (cross RFC-018)
|
|
91
|
+
|
|
92
|
+
**n/a** — la gema no **consume** servicios (no tiene `docs/consumed/`). Nota: sí
|
|
93
|
+
**inyecta** hooks a otras gemas (`BugBunny.consumer_middlewares`, Sidekiq
|
|
94
|
+
client/server middleware, `ActiveResource::Base.prepend` —
|
|
95
|
+
`lib/exis_ray/railtie.rb:71,96,116`), pero **ninguno tiene test** (cae en §j,
|
|
96
|
+
no en §g — es inyección, no consumo).
|
|
97
|
+
|
|
98
|
+
### h. Tests de no-regresión / nacidos de incidentes
|
|
99
|
+
|
|
100
|
+
| Test | Incidente | Qué reproduce |
|
|
101
|
+
|---|---|---|
|
|
102
|
+
| `spec/exis_ray/json_formatter_spec.rb:410` `describe "...(issue #9)"` | issue #9 | inyección de contexto de tracer; root_id nil pero request_id presente (Gap C) |
|
|
103
|
+
| `spec/exis_ray/json_formatter_spec.rb:466` `describe "...(issue #12)"` | issue #12 | dedup de claves Symbol/String (no duplicar en JSON) |
|
|
104
|
+
|
|
105
|
+
- **Convención §h ya practicada** ✅ — exis_ray ancla el incidente en el
|
|
106
|
+
`describe`. Valida que la convención v2.1 es factible y de bajo costo. (Forma
|
|
107
|
+
observada: `(issue #N)` en el describe; la norma sugiere `# Regresión: #N` en
|
|
108
|
+
comentario — ambas cumplen el objetivo de link recuperable sin `git blame`.)
|
|
109
|
+
|
|
110
|
+
### i. Ejecución, gates y flaky
|
|
111
|
+
|
|
112
|
+
- **Ejecución:** `bundle exec rake` (RSpec + RuboCop), ~1.2s. Sin gates de
|
|
113
|
+
suite (no hay integration que excluir).
|
|
114
|
+
- **Flaky:** 0 (176 pasan consistentes, sin `sleep`/`Thread`).
|
|
115
|
+
- **CI:** `.github/workflows/main.yml` — corre la suite, pero ver §j (matrix).
|
|
116
|
+
|
|
117
|
+
### j. Inyección al host + matrix de versiones
|
|
118
|
+
|
|
119
|
+
**Sección de alto valor para esta gema** (motivó §j en v2.1).
|
|
120
|
+
|
|
121
|
+
**Inyección al host** — `lib/exis_ray/railtie.rb` inyecta ~7 cosas; **ninguna
|
|
122
|
+
testeada en app real** (no hay `spec/dummy/`):
|
|
123
|
+
|
|
124
|
+
| Inyección | file:line | Testeada? |
|
|
125
|
+
|---|---|---|
|
|
126
|
+
| `HttpMiddleware` (`insert_after ActionDispatch::RequestId`) | `railtie.rb:17` | **sin-test** de inyección (lógica del middleware sí, aislada — `mock-rails`) |
|
|
127
|
+
| `config.log_tags` (request_id proc) | `railtie.rb:31` | sin-test |
|
|
128
|
+
| `Rails.logger.formatter = JsonFormatter.new` | `railtie.rb:57` | sin-test (formatter sí, aislado) |
|
|
129
|
+
| `LogSubscriber` (subscribe a ActionController) | `railtie.rb:61` | sin-test (subscriber sí, aislado con `mock-rails`) |
|
|
130
|
+
| `BugBunny.consumer_middlewares.use` | `railtie.rb:71` | **sin-test** |
|
|
131
|
+
| `ActiveResource::Base.prepend` instrumentation | `railtie.rb:96` | **sin-test** |
|
|
132
|
+
| Sidekiq client/server middleware | `railtie.rb:107,116` | **sin-test** |
|
|
133
|
+
|
|
134
|
+
Gap: lo que **define** a la gema (inyectar al host) es lo único sin test.
|
|
135
|
+
Cruza [`docs/config/configuracion.md`](../config/configuracion.md) §i (mismo
|
|
136
|
+
inventario de inyecciones del Railtie, lado config). Un `spec/dummy/` cerraría
|
|
137
|
+
el gap.
|
|
138
|
+
|
|
139
|
+
**Matrix de versiones:**
|
|
140
|
+
|
|
141
|
+
| | Valor |
|
|
142
|
+
|---|---|
|
|
143
|
+
| Declarado (gemspec) | Ruby `>= 2.6.0` · activesupport/railties `>= 6.0` (`exis_ray.gemspec:15,38`) |
|
|
144
|
+
| Testeado (CI) | **solo Ruby 3.4.4** (`.github/workflows/main.yml:17`) — sin Appraisal, sin matrix de Rails |
|
|
145
|
+
| Gap | rango Ruby 2.6–3.3 y Rails 6–7 **declarado pero no ejercitado** |
|
|
146
|
+
|
|
147
|
+
### k. Tests de concurrencia / async
|
|
148
|
+
|
|
149
|
+
**n/a** — exis_ray no tiene threads ni callbacks en reader-thread. Confirma que
|
|
150
|
+
§k es **específica de gemas que gestionan concurrencia** (`bug_bunny`), no
|
|
151
|
+
universal. (Input para §5 de la RFC: §k aplicó a 1 de 4 repos validados →
|
|
152
|
+
evaluar si va como sección top-level o sub-bloque condicional.)
|
|
153
|
+
|
|
154
|
+
## 3. Inferencias
|
|
155
|
+
|
|
156
|
+
- "Inyección sin test" se infiere de la ausencia de `spec/dummy/` + presencia
|
|
157
|
+
de hooks en `railtie.rb`. No medido (sin coverage).
|
|
158
|
+
|
|
159
|
+
## 4. Cobertura y fronteras
|
|
160
|
+
|
|
161
|
+
- Cobertura completa de los **componentes aislados**; gap en la **integración
|
|
162
|
+
Railtie↔Rails real** y en la **matrix de versiones**. Ambos son los hallazgos
|
|
163
|
+
que §j hace visibles — el valor del artefacto para una gema.
|
|
@@ -52,24 +52,36 @@ module ExisRay
|
|
|
52
52
|
# @example 'production'
|
|
53
53
|
attr_accessor :deployment_environment
|
|
54
54
|
|
|
55
|
-
# @!attribute [rw]
|
|
56
|
-
# @return [
|
|
57
|
-
#
|
|
58
|
-
#
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
#
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
#
|
|
65
|
-
# @
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
#
|
|
69
|
-
#
|
|
70
|
-
#
|
|
71
|
-
|
|
72
|
-
|
|
55
|
+
# @!attribute [rw] filtered_keys
|
|
56
|
+
# @return [Array<String, Symbol>, nil] Claves que se tapan en el log, por nombre exacto y sin distinguir
|
|
57
|
+
# mayúsculas. Se suman al default ({ExisRay::LogSanitizer::DEFAULT_SENSITIVE}) (ADR-131).
|
|
58
|
+
# @example %w[data]
|
|
59
|
+
attr_accessor :filtered_keys
|
|
60
|
+
|
|
61
|
+
# @!attribute [rw] unfiltered_keys
|
|
62
|
+
# @return [Array<String, Symbol>, nil] Claves que el default tapa y este servicio necesita ver (falsos
|
|
63
|
+
# positivos de "contiene", p. ej. `author`), por nombre exacto y sin distinguir mayúsculas. No destapa una
|
|
64
|
+
# clave de {#filtered_keys} (ADR-131).
|
|
65
|
+
# @example %w[author max_tokens]
|
|
66
|
+
attr_accessor :unfiltered_keys
|
|
67
|
+
|
|
68
|
+
# @!attribute [rw] max_value_chars
|
|
69
|
+
# @return [Integer] Caracteres por valor string antes de recortarlo. No aplica al diagnóstico
|
|
70
|
+
# ({ExisRay::LogSanitizer::DIAGNOSTIC_KEYS}). Default 500.
|
|
71
|
+
attr_accessor :max_value_chars
|
|
72
|
+
|
|
73
|
+
# @!attribute [rw] max_array_items
|
|
74
|
+
# @return [Integer] Elementos por array antes de recortarlo. Default 100.
|
|
75
|
+
attr_accessor :max_array_items
|
|
76
|
+
|
|
77
|
+
# @!attribute [rw] max_line_bytes
|
|
78
|
+
# @return [Integer] Bytes por línea de log. Default 8192.
|
|
79
|
+
attr_accessor :max_line_bytes
|
|
80
|
+
|
|
81
|
+
# @!attribute [rw] max_traverse_bytes
|
|
82
|
+
# @return [Integer] Un string más grande que esto no se recorre ni se parsea: se reemplaza entero.
|
|
83
|
+
# Default 65536.
|
|
84
|
+
attr_accessor :max_traverse_bytes
|
|
73
85
|
|
|
74
86
|
# Inicializa la configuración con valores por defecto compatibles con AWS X-Ray.
|
|
75
87
|
def initialize
|
|
@@ -81,8 +93,12 @@ module ExisRay
|
|
|
81
93
|
@log_subscriber_class = nil
|
|
82
94
|
@service_version = default_service_version
|
|
83
95
|
@deployment_environment = default_deployment_environment
|
|
84
|
-
@
|
|
85
|
-
@
|
|
96
|
+
@filtered_keys = nil
|
|
97
|
+
@unfiltered_keys = nil
|
|
98
|
+
@max_value_chars = 500
|
|
99
|
+
@max_array_items = 100
|
|
100
|
+
@max_line_bytes = 8192
|
|
101
|
+
@max_traverse_bytes = 65_536
|
|
86
102
|
end
|
|
87
103
|
|
|
88
104
|
# Lee la versión del servicio desde la configuración de Rails.
|