chronos-ruby 0.9.0.pre.4 → 1.1.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/CHANGELOG.md +36 -0
- data/README.md +108 -197
- data/contracts/apm-batch-v1.schema.json +51 -1
- data/docs/adr/ADR-007-feature-detection.md +25 -0
- data/docs/adr/ADR-008-context-store.md +25 -0
- data/docs/adr/ADR-009-sampling.md +25 -0
- data/docs/adr/ADR-010-opentelemetry-interoperability.md +25 -0
- data/docs/adr/ADR-015-bounded-apm-aggregation.md +3 -3
- data/docs/adr/ADR-018-pre-1.0-hardening.md +6 -2
- data/docs/adr/ADR-019-bounded-query-diagnostics.md +44 -0
- data/docs/architecture.md +5 -2
- data/docs/compatibility.md +30 -23
- data/docs/configuration.md +21 -0
- data/docs/data-collected.md +9 -3
- data/docs/deprecation-policy.md +1 -1
- data/docs/examples/plain-ruby.md +6 -0
- data/docs/migration-from-airbrake.md +1 -1
- data/docs/modules/apm-aggregation.md +18 -5
- data/docs/modules/breadcrumbs.md +23 -0
- data/docs/modules/context.md +21 -0
- data/docs/modules/deploys.md +23 -0
- data/docs/modules/job-monitoring.md +22 -0
- data/docs/modules/request-monitoring.md +20 -0
- data/docs/modules/runtime-metrics.md +22 -0
- data/docs/modules/sampling.md +22 -0
- data/docs/modules/sidekiq-legacy.md +1 -1
- data/docs/modules/sql-monitoring.md +76 -0
- data/docs/modules/telemetry-events.md +1 -1
- data/docs/performance.md +30 -3
- data/docs/privacy-lgpd.md +6 -3
- data/docs/protocol-v1.md +2 -2
- data/docs/release-1.0-readiness.md +17 -15
- data/docs/release-1.1-readiness.md +51 -0
- data/docs/security-review.md +7 -3
- data/docs/troubleshooting.md +6 -0
- data/lib/chronos/agent.rb +12 -2
- data/lib/chronos/application/apm_aggregator.rb +179 -29
- data/lib/chronos/configuration/apm_validation.rb +51 -1
- data/lib/chronos/configuration.rb +17 -1
- data/lib/chronos/core/metric_aggregate.rb +69 -7
- data/lib/chronos/core/sql_query_analyzer.rb +309 -0
- data/lib/chronos/ports/query_inspector.rb +23 -0
- data/lib/chronos/rails/active_record_query_inspector.rb +235 -0
- data/lib/chronos/rails/notifications_subscriber.rb +163 -2
- data/lib/chronos/rails.rb +1 -0
- data/lib/chronos/version.rb +1 -1
- data/lib/chronos.rb +2 -0
- metadata +21 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0127def72275a2d4c08314040c04e34a9606fed13982d84b06c465dee7be4cf6
|
|
4
|
+
data.tar.gz: 99f272314517e6a525223ce86964b70fcdfce717eb0e434b9c77e275031913b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 93b37af1a5b51284a6c6de1c19e12de18ac23b04bfa4a04f33b7fce5cb611ec6f940d4ec2508c8a2b8d72f91e9a2a9a812a3b48d72f60dfefd642fb7cf3fe138
|
|
7
|
+
data.tar.gz: 4c653acb6d7aa90d534a7d496568fca64fb9ba9bce9039c6ca68fad71c1b5aef3f4e5de541a3f3d0f6064f08653359bcc2afc30e3a2d82c910942f0c1e103d4a
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,42 @@ All notable changes are documented here. The project follows Semantic Versioning
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [1.1.0] - 2026-08-05
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- bounded normalized SELECT analysis with access columns, index candidates, existing-index comparison, optional table statistics, and allowlisted non-executing query plans;
|
|
12
|
+
- structured query diagnostics and severity counts for errors, warnings, information, and suggestions, including actionable N+1 and index guidance;
|
|
13
|
+
- approximate p50/p95/p99 metrics, complete outer-transaction timing, expanded adapter error families, and trace/fingerprint loss counters;
|
|
14
|
+
- explicit low-risk defaults and bounded opt-in configuration for database index/statistics/plan inspection.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- aggregate drains preserve active trace trackers until request completion or idle TTL instead of discarding incomplete correlation;
|
|
19
|
+
- possible N+1 now requires a non-cached SELECT, and query analysis sent to consumers prefers inspected evidence over an earlier static-only observation.
|
|
20
|
+
|
|
21
|
+
### Security
|
|
22
|
+
|
|
23
|
+
- query inspection never uses `EXPLAIN ANALYZE`, never executes DDL, omits raw SQL/binds/predicates/messages, and retains only bounded schema and planner fields.
|
|
24
|
+
|
|
25
|
+
## [1.0.0] - 2026-07-29
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- stable legacy release gates for Ruby 2.2.10 through 2.6.10, Rails 4.2/5.2, Sidekiq 4/5, documentation, repeatable comparison, and fake-endpoint load validation;
|
|
30
|
+
- the remaining mandatory module documents and ADRs for feature detection, context storage, sampling, and future OpenTelemetry interoperability.
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- promoted the reviewed public API and protocol v1 implementation from `0.9.0.pre.4` to `1.0.0`;
|
|
35
|
+
- release publishing now accepts `v1.*` tags and cannot publish until every legacy compatibility and release-readiness job succeeds;
|
|
36
|
+
- compatibility status is now `Supported` only for the exact runtime/framework combinations covered by green release gates.
|
|
37
|
+
|
|
38
|
+
### Security
|
|
39
|
+
|
|
40
|
+
- stable artifacts continue to use RubyGems Trusted Publishing, SHA-256 checksums, SPDX SBOMs, strict payload privacy contracts, and dependency auditing;
|
|
41
|
+
- package signing remains deferred until a trusted signing-key lifecycle is available.
|
|
42
|
+
|
|
7
43
|
## [0.9.0.pre.4] - 2026-07-22
|
|
8
44
|
|
|
9
45
|
### Added
|
data/README.md
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
1
|
# Chronos Ruby
|
|
2
2
|
|
|
3
|
-
Chronos Ruby
|
|
3
|
+
Chronos Ruby 1.1.0 é o agente independente de framework para enviar exceções e telemetria limitada de aplicações Ruby ao Chronos. Esta é a linha estável legado, compatível com o protocolo v1 e voltada a Ruby 2.2.10–2.6.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## O que a gem coleta
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
A versão 1.1 pode coletar:
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
- timestamp,
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
9
|
+
- classe, mensagem, backtrace estruturado e causas encadeadas da exceção;
|
|
10
|
+
- timestamp, severidade, tags e fingerprint opcional;
|
|
11
|
+
- contexto, parâmetros, sessão e usuário fornecidos pela aplicação;
|
|
12
|
+
- versão, engine e plataforma Ruby, PID, thread opaca e hostname;
|
|
13
|
+
- ambiente, serviço, versão da aplicação, release, revision, deploy ID, região e instância;
|
|
14
|
+
- método, rota normalizada, status, duração e breakdown de requests Rack/Rails;
|
|
15
|
+
- SQL normalizado sem literais/binds e sinais heurísticos de desempenho;
|
|
16
|
+
- jobs Sidekiq/Active Job, cache, HTTP externo explicitamente instrumentado e dependências carregadas;
|
|
17
|
+
- breadcrumbs limitados fornecidos pela aplicação ou por integrações.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Veja a tabela completa em [Dados coletados](docs/data-collected.md).
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## O que não é coletado por padrão
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
A gem não varre variáveis de ambiente, sistema de arquivos ou lockfiles e não coleta bodies HTTP, cookies, headers de autorização, conteúdo de e-mail, SQL bruto, binds, valores de cache ou código-fonte. A inspeção de plano, desativada por padrão, usa o SQL original somente na conexão local para `EXPLAIN` sem `ANALYZE` e o descarta. O inventário de dependências contém somente nomes e versões já carregados, uma vez por agente. A aplicação continua responsável por minimização e base legal dos dados enviados.
|
|
24
24
|
|
|
25
|
-
##
|
|
25
|
+
## Versões Ruby e Rails suportadas
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
A versão 1.1.0 suporta Ruby puro e Rack em Ruby 2.2.10, 2.3.8, 2.4.10, 2.5.9 e 2.6.10. As combinações Rails validadas são Rails 4.2 com Ruby 2.2.10/2.3.8 e Rails 5.2 com Ruby 2.5.9/2.6.10. Sidekiq 4.2.10 com Ruby 2.2.10 e Sidekiq 5.2.10 com Ruby 2.5.9 também possuem gates dedicados. Ruby 2.7/Rails 6 não é declarado nesta release porque ainda não possui aplicação e matriz completas.
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
Rubies e frameworks antigos estão fora do suporte de segurança de seus mantenedores. A Chronos oferece compatibilidade técnica, não manutenção de segurança do runtime. Veja [Compatibilidade](docs/compatibility.md).
|
|
30
30
|
|
|
31
|
-
##
|
|
31
|
+
## Instalação em Ruby puro
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
Obrigatório: adicione a versão estável ao `Gemfile`.
|
|
34
34
|
|
|
35
35
|
```ruby
|
|
36
|
-
gem "chronos-ruby", "
|
|
36
|
+
gem "chronos-ruby", "~> 1.1.0"
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Em runtimes antigos, use Bundler compatível:
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
gem install bundler -v 1.17.3
|
|
43
43
|
bundle _1.17.3_ install
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
Sem Bundler:
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
|
-
gem install chronos-ruby
|
|
49
|
+
gem install chronos-ruby -v 1.1.0
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
## Rails
|
|
52
|
+
## Instalação em Rails
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
Obrigatório: carregue a integração Rails explicitamente para manter Rails/ActiveSupport fora de aplicações Ruby puras.
|
|
55
55
|
|
|
56
56
|
```ruby
|
|
57
|
-
gem "chronos-ruby", "
|
|
57
|
+
gem "chronos-ruby", "~> 1.1.0", :require => "chronos/rails"
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
Gere o initializer:
|
|
61
61
|
|
|
62
62
|
```bash
|
|
63
63
|
rails generate chronos:install
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
A Versão 0.5 introduziu Railtie, middleware e subscribers idempotentes por APIs públicas e feature detection. A coleta automática fica desativada em test e console por padrão. Veja [Rails legado](docs/modules/rails-legacy.md).
|
|
67
67
|
|
|
68
|
-
##
|
|
68
|
+
## Configuração mínima
|
|
69
69
|
|
|
70
|
-
`project_id`, `project_key
|
|
70
|
+
Obrigatório quando o agente está habilitado: `project_id`, `project_key` e `host` HTTPS. Recomendado: definir ambiente e serviço explicitamente.
|
|
71
71
|
|
|
72
72
|
```ruby
|
|
73
73
|
require "chronos"
|
|
@@ -82,43 +82,28 @@ Chronos.configure do |config|
|
|
|
82
82
|
end
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
## Verify the Chronos integration
|
|
88
|
-
|
|
89
|
-
After configuring the application, Rails projects can verify credentials and end-to-end ingestion with:
|
|
85
|
+
TLS é verificado por padrão. HTTP exige `ssl_verify = false` explicitamente e deve ser limitado a endpoints locais de teste. Depois de configurar, valide credenciais e ingestão:
|
|
90
86
|
|
|
91
87
|
```bash
|
|
92
88
|
bundle exec rake chronos:verify_integration
|
|
93
89
|
```
|
|
94
90
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Plain Ruby Rakefiles can install the same task explicitly after loading their configuration:
|
|
91
|
+
O task envia uma exceção sintética identificada e só retorna código `0` após uma resposta v1 correlacionada. Em Ruby puro, instale o task com `require "chronos/rake_tasks"` e `Chronos::RakeTasks.install`; por código, use `Chronos.verify_integration`. Veja [Verificação da integração](docs/modules/integration-verification.md).
|
|
98
92
|
|
|
99
|
-
|
|
100
|
-
require "chronos"
|
|
101
|
-
# Chronos.configure { |config| ... }
|
|
102
|
-
require "chronos/rake_tasks"
|
|
103
|
-
Chronos::RakeTasks.install
|
|
104
|
-
```
|
|
93
|
+
## Captura automática
|
|
105
94
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
## Automatic capture
|
|
109
|
-
|
|
110
|
-
Rack applications can capture unhandled exceptions automatically and preserve the application error semantics:
|
|
95
|
+
Opcional em Rack: instale o middleware. Ele notifica exceções não tratadas, preserva a mesma exceção para a aplicação e não consome bodies.
|
|
111
96
|
|
|
112
97
|
```ruby
|
|
113
98
|
use Chronos::Integrations::Rack::Middleware,
|
|
114
99
|
:include_user_agent => false
|
|
115
100
|
```
|
|
116
101
|
|
|
117
|
-
|
|
102
|
+
Em Rails, o Railtie instala middleware e subscribers uma única vez. Veja [Monitoramento de requests](docs/modules/request-monitoring.md).
|
|
118
103
|
|
|
119
|
-
##
|
|
104
|
+
## Captura manual
|
|
120
105
|
|
|
121
|
-
|
|
106
|
+
Recomendado no fluxo da aplicação: captura assíncrona.
|
|
122
107
|
|
|
123
108
|
```ruby
|
|
124
109
|
begin
|
|
@@ -129,27 +114,27 @@ rescue StandardError => error
|
|
|
129
114
|
end
|
|
130
115
|
```
|
|
131
116
|
|
|
132
|
-
|
|
117
|
+
Opcional para scripts e shutdown controlado: captura síncrona.
|
|
133
118
|
|
|
134
119
|
```ruby
|
|
135
120
|
delivered = Chronos.notify_sync(RuntimeError.new("import failed"))
|
|
136
121
|
```
|
|
137
122
|
|
|
138
|
-
|
|
123
|
+
Falhas internas retornam `false` e não escapam para o fluxo principal.
|
|
139
124
|
|
|
140
|
-
##
|
|
125
|
+
## Contexto de usuário
|
|
141
126
|
|
|
142
|
-
|
|
127
|
+
Contexto de usuário é opt-in. Envie somente campos necessários e autorizados:
|
|
143
128
|
|
|
144
129
|
```ruby
|
|
145
130
|
Chronos.notify(error, :user => {"id" => "customer-42", "role" => "operator"})
|
|
146
131
|
```
|
|
147
132
|
|
|
148
|
-
|
|
133
|
+
O valor é limitado e sanitizado, mas a minimização continua sendo responsabilidade da aplicação. Veja [Contexto de execução](docs/modules/context.md).
|
|
149
134
|
|
|
150
135
|
## Breadcrumbs
|
|
151
136
|
|
|
152
|
-
Breadcrumbs
|
|
137
|
+
Breadcrumbs formam um buffer circular delimitado no escopo atual:
|
|
153
138
|
|
|
154
139
|
```ruby
|
|
155
140
|
Chronos.add_breadcrumb(
|
|
@@ -159,35 +144,25 @@ Chronos.add_breadcrumb(
|
|
|
159
144
|
)
|
|
160
145
|
```
|
|
161
146
|
|
|
162
|
-
|
|
147
|
+
A gem não transforma logs, SQL ou bodies em breadcrumbs brutos. Veja [Breadcrumbs](docs/modules/breadcrumbs.md).
|
|
163
148
|
|
|
164
|
-
##
|
|
149
|
+
## Filtros e LGPD
|
|
165
150
|
|
|
166
|
-
|
|
151
|
+
A gem bloqueia chaves sensíveis e detecta Bearer tokens, JWTs, e-mails, CPF, CNPJ e candidatos válidos a cartão. IPv4 é anonimizado por padrão. Opcionalmente, amplie a blocklist, aplique hash irreversível ou filtros próprios:
|
|
167
152
|
|
|
168
153
|
```ruby
|
|
169
154
|
Chronos.configure do |config|
|
|
170
|
-
# required options omitted
|
|
171
155
|
config.blocklist_keys += [:medical_record, /bank_account/i]
|
|
172
156
|
config.hash_keys += [:customer_id]
|
|
173
157
|
config.filters << proc { |key, value| key.to_s == "internal_reference" ? "[REMOVED]" : value }
|
|
174
158
|
end
|
|
175
159
|
```
|
|
176
160
|
|
|
177
|
-
|
|
161
|
+
Sanitização ocorre antes de fila, retry e backlog. Veja [Privacidade e LGPD](docs/privacy-lgpd.md).
|
|
178
162
|
|
|
179
163
|
## Ignore rules
|
|
180
164
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
```ruby
|
|
184
|
-
Chronos.configure do |config|
|
|
185
|
-
# required options omitted
|
|
186
|
-
config.ignored_environments = ["development", "test"]
|
|
187
|
-
end
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
Version `0.9.0.pre.2` adds bounded local rules after configuration:
|
|
165
|
+
Ambientes inteiros podem ser ignorados na configuração. A versão `0.9.0.pre.2` introduziu regras locais limitadas, preservadas na API estável:
|
|
191
166
|
|
|
192
167
|
```ruby
|
|
193
168
|
Chronos.ignore_if do |notice|
|
|
@@ -195,17 +170,14 @@ Chronos.ignore_if do |notice|
|
|
|
195
170
|
end
|
|
196
171
|
```
|
|
197
172
|
|
|
198
|
-
|
|
173
|
+
A regra recebe um notice normalizado e imutável, e somente `true` descarta. Falhas do callback são contidas. Veja [Ignore rules](docs/modules/ignore-rules.md).
|
|
199
174
|
|
|
200
|
-
##
|
|
175
|
+
## Monitoramento de performance
|
|
201
176
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
SQL comments and literal values are removed before a bounded normalized query and SHA-256 fingerprint are produced. Binds are never read. Slow, repeated, possible N+1, long-transaction, connection-error, and deadlock signals are heuristic and require server-side confirmation. Group count, active trace count, fingerprints per trace, histogram buckets, and batch size all have fixed limits. See [Essential APM aggregation](docs/modules/apm-aggregation.md).
|
|
177
|
+
A Versão 0.7 introduziu agregação local de requests, queries e jobs em `metric_batch`; a Versão 0.8 adicionou HTTP externo. Grupos possuem contagem, erro, duração, histograma, percentis aproximados, severidades, diagnósticos, status e breakdown limitados.
|
|
205
178
|
|
|
206
179
|
```ruby
|
|
207
180
|
Chronos.configure do |config|
|
|
208
|
-
# required connection settings omitted
|
|
209
181
|
config.apm_enabled = true
|
|
210
182
|
config.apm_max_groups = 200
|
|
211
183
|
config.apm_flush_count = 100
|
|
@@ -213,45 +185,37 @@ Chronos.configure do |config|
|
|
|
213
185
|
config.apm_max_queries_per_request = 100
|
|
214
186
|
config.apm_slow_query_threshold_ms = 500.0
|
|
215
187
|
config.apm_n_plus_one_threshold = 5
|
|
188
|
+
config.apm_trace_ttl_seconds = 60.0
|
|
189
|
+
config.apm_query_analysis_enabled = true
|
|
190
|
+
config.apm_query_analysis_max_queries = 100
|
|
191
|
+
|
|
192
|
+
# Opt-in: cada fingerprint elegível pode consultar catálogo/estatística/plano.
|
|
193
|
+
config.apm_query_inspection_enabled = false
|
|
194
|
+
config.apm_query_statistics_enabled = false
|
|
195
|
+
config.apm_query_plan_enabled = false
|
|
196
|
+
config.apm_query_inspection_min_duration_ms = 500.0
|
|
197
|
+
config.apm_query_inspection_max_queries = 20
|
|
198
|
+
config.apm_transaction_tracking_enabled = true
|
|
199
|
+
config.apm_transaction_max_connections = 100
|
|
216
200
|
end
|
|
217
201
|
```
|
|
218
202
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
Version `0.6.0.pre.1` adds optional Sidekiq 4/5 middleware:
|
|
222
|
-
|
|
223
|
-
```ruby
|
|
224
|
-
gem "sidekiq", "~> 5.0"
|
|
225
|
-
gem "chronos-ruby", "0.9.0.pre.4", :require => "chronos/sidekiq"
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
The client middleware propagates only trace/request identifiers in a versioned Sidekiq-envelope field and never changes worker arguments. The server records class, queue, JID, retry count, duration, calculable queue latency, bounded arguments/tags, status, and error class. Values pass through the shared sanitizer before delivery. Failed jobs are notified once and the original exception is re-raised. See [Sidekiq 4/5 legacy integration](docs/modules/sidekiq-legacy.md).
|
|
203
|
+
Por padrão, SQL bruto e binds não são lidos pelo pipeline de análise. A inspeção opt-in usa o SQL original apenas localmente para solicitar `EXPLAIN` sem `ANALYZE`; nunca o inclui no evento. A análise estática produz candidatos, não ordens de criação de índice. Erros usam severidade `error`; lentidão e risco usam `warning`; padrões observados usam `info`; correções propostas usam `suggestion`. Veja [APM](docs/modules/apm-aggregation.md), [Requests](docs/modules/request-monitoring.md) e [SQL](docs/modules/sql-monitoring.md).
|
|
229
204
|
|
|
230
|
-
|
|
205
|
+
## Sidekiq e Active Job
|
|
231
206
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
Version 0.8 instruments only explicitly selected `Net::HTTP` connection objects, avoiding a global monkey patch:
|
|
207
|
+
A versão `0.6.0.pre.1` introduziu middleware Sidekiq 4/5; a API estável mantém o require explícito:
|
|
235
208
|
|
|
236
209
|
```ruby
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
config.external_http_enabled = true
|
|
240
|
-
config.external_http_trace_headers = true
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
http = Net::HTTP.new("payments.example.com", 443)
|
|
244
|
-
http.use_ssl = true
|
|
245
|
-
Chronos.instrument_net_http(http)
|
|
210
|
+
gem "sidekiq", "~> 5.0"
|
|
211
|
+
gem "chronos-ruby", "~> 1.1.0", :require => "chronos/sidekiq"
|
|
246
212
|
```
|
|
247
213
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
Rails cache telemetry omits raw keys by default. Set `cache_key_mode = :sha256` to emit a project-scoped hash; `:none` is the default. Dependency reporting is enabled by default, reads at most 100 already loaded gem specs, and emits one independent `dependencies` event per agent. Set `dependency_reporting = false` to disable it. See [External HTTP](docs/modules/external-http.md), [Cache observability](docs/modules/cache-observability.md), and [Dependency inventory](docs/modules/dependencies.md).
|
|
214
|
+
O envelope de contexto não altera argumentos públicos e contém somente IDs limitados de trace/request. Active Job usa um campo serializado com namespace (`chronos_context`) e hooks públicos. Erros aninhados são deduplicados e reerguidos. Veja [Sidekiq legado](docs/modules/sidekiq-legacy.md), [Active Job](docs/modules/active-job.md) e [Jobs](docs/modules/job-monitoring.md).
|
|
251
215
|
|
|
252
216
|
## Deploy tracking
|
|
253
217
|
|
|
254
|
-
|
|
218
|
+
A Versão 0.9 introduziu deploy síncrono e correlação fixa em todos os eventos:
|
|
255
219
|
|
|
256
220
|
```ruby
|
|
257
221
|
Chronos.notify_deploy(
|
|
@@ -263,55 +227,35 @@ Chronos.notify_deploy(
|
|
|
263
227
|
)
|
|
264
228
|
```
|
|
265
229
|
|
|
266
|
-
Configure
|
|
230
|
+
Configure release/revision/deploy na inicialização de cada novo processo. A gem não lê Git ou variáveis automaticamente. Capistrano é opcional; Kamal e GitHub Actions usam exemplos em `examples/deploy/`. Veja [Deploys](docs/modules/deploys.md).
|
|
267
231
|
|
|
268
|
-
|
|
232
|
+
## Fila assíncrona
|
|
269
233
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
The queue has a fixed capacity and drops the newest event when full. Worker threads are created lazily after the first accepted event. The default capacity is 100 events with one worker.
|
|
234
|
+
A fila tem capacidade fixa, descarta o evento mais novo quando cheia e cria workers somente após a primeira captura aceita.
|
|
273
235
|
|
|
274
236
|
```mermaid
|
|
275
237
|
flowchart LR
|
|
276
|
-
E[
|
|
277
|
-
N --> P[
|
|
278
|
-
P --> S[
|
|
279
|
-
S --> D[
|
|
280
|
-
D --> Q[
|
|
281
|
-
Q --> W[
|
|
282
|
-
W -->
|
|
283
|
-
|
|
284
|
-
R --> B[Bounded memory backlog]
|
|
238
|
+
E[Exceção ou telemetria] --> N[Normalização]
|
|
239
|
+
N --> P[Sanitização]
|
|
240
|
+
P --> S[Serialização limitada]
|
|
241
|
+
S --> D[Pipeline de entrega]
|
|
242
|
+
D --> Q[Fila limitada]
|
|
243
|
+
Q --> W[Workers fixos]
|
|
244
|
+
W --> H[Net::HTTP]
|
|
245
|
+
W --> B[Backlog em memória]
|
|
285
246
|
```
|
|
286
247
|
|
|
287
|
-
Use `Chronos.flush(timeout)`
|
|
288
|
-
|
|
289
|
-
## Retry and backlog
|
|
290
|
-
|
|
291
|
-
The resilience layer introduced in version 0.3 retries network errors, HTTP `408`, `429`, and `5xx` responses with exponential backoff, bounded jitter, and a finite attempt count. Other `4xx` responses are permanent and are not retried. A circuit breaker pauses requests after repeated failures, preventing retry storms.
|
|
292
|
-
|
|
293
|
-
After retries are exhausted, the already sanitized `SerializedEvent` may enter a fixed-capacity memory backlog. The backlog drops new items when full, is lost when the process exits, and never writes to disk. A later successful half-open probe drains backlog items as new events arrive.
|
|
294
|
-
|
|
295
|
-
The SaaS may return a JSON policy in the bounded `X-Chronos-Remote-Configuration` response header. Only sampling rate, enabled event types, a lower payload limit, exact ignored fingerprints, send interval, and kill switch are accepted. Remote values cannot change the host, project credentials, TLS, local maximums, code, or regular expressions. See [Retry and backlog](docs/modules/retry-backlog.md) and [Remote configuration](docs/modules/remote-configuration.md).
|
|
248
|
+
Use `Chronos.flush(timeout)` antes de encerrar e `Chronos.close(timeout)` no shutdown. Workers são recriados após fork. Veja [Fila assíncrona](docs/modules/async-queue.md).
|
|
296
249
|
|
|
297
|
-
##
|
|
250
|
+
## Retry e backlog
|
|
298
251
|
|
|
299
|
-
|
|
252
|
+
Retry cobre erros de rede, HTTP `408`, `429` e `5xx`, com backoff exponencial, jitter e tentativas limitadas. Outros `4xx` são permanentes. Circuit breaker reduz tempestades de retry.
|
|
300
253
|
|
|
301
|
-
|
|
302
|
-
- `Chronos::Application` coordinates capture;
|
|
303
|
-
- `Chronos::Application::DeliveryPipeline` owns bounded retry and remote policy;
|
|
304
|
-
- `Chronos::Ports` defines delivery behavior;
|
|
305
|
-
- `Chronos::Adapters` implements Net::HTTP delivery and thread-local context;
|
|
306
|
-
- `Chronos::Integrations::Rack` implements optional automatic Rack capture;
|
|
307
|
-
- `Chronos::Rails` implements the optional Railtie, installer, generator, and public-notification adapters;
|
|
308
|
-
- `Chronos::Internal` owns bounded queueing, workers, and defensive logging.
|
|
254
|
+
O backlog guarda somente eventos já sanitizados/serializados, possui capacidade fixa, vive em memória e é perdido no encerramento. Configuração remota aceita apenas sampling, tipos habilitados, limite menor de payload, fingerprints exatas, intervalo e kill switch; nunca altera host, credenciais, TLS ou executa código. Veja [Retry e backlog](docs/modules/retry-backlog.md), [Sampling](docs/modules/sampling.md) e [Configuração remota](docs/modules/remote-configuration.md).
|
|
309
255
|
|
|
310
|
-
|
|
256
|
+
## Configuração por ambiente
|
|
311
257
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
Configuration values are explicit; the gem never scans the process environment. Read only the variables your application chooses:
|
|
258
|
+
A gem não varre o ambiente. Leia somente variáveis escolhidas pela aplicação:
|
|
315
259
|
|
|
316
260
|
```ruby
|
|
317
261
|
Chronos.configure do |config|
|
|
@@ -322,102 +266,69 @@ Chronos.configure do |config|
|
|
|
322
266
|
config.enabled = ENV["CHRONOS_ENABLED"] != "false"
|
|
323
267
|
config.queue_size = 100
|
|
324
268
|
config.workers = 1
|
|
325
|
-
config.timeout = 5.0
|
|
326
|
-
config.open_timeout = 2.0
|
|
327
269
|
config.max_retries = 3
|
|
328
|
-
config.retry_base_interval = 0.5
|
|
329
|
-
config.retry_max_interval = 30.0
|
|
330
|
-
config.retry_jitter = 0.25
|
|
331
270
|
config.backlog_size = 100
|
|
332
|
-
config.circuit_failure_threshold = 5
|
|
333
|
-
config.circuit_reset_timeout = 30.0
|
|
334
271
|
config.remote_configuration = true
|
|
335
|
-
config.context_store = :thread_local
|
|
336
|
-
config.breadcrumb_capacity = 20
|
|
337
|
-
config.breadcrumb_max_bytes = 2048
|
|
338
272
|
config.apm_enabled = true
|
|
339
|
-
config.apm_max_groups = 200
|
|
340
|
-
config.apm_flush_count = 100
|
|
341
273
|
config.external_http_enabled = false
|
|
342
274
|
config.cache_key_mode = :none
|
|
343
275
|
config.dependency_reporting = true
|
|
344
276
|
config.app_version = ENV["APP_VERSION"]
|
|
345
277
|
config.revision = ENV["GIT_SHA"]
|
|
346
278
|
config.deploy_id = ENV["DEPLOY_ID"]
|
|
347
|
-
config.region = ENV["REGION"]
|
|
348
|
-
config.instance_id = ENV["INSTANCE_ID"]
|
|
349
279
|
end
|
|
350
280
|
```
|
|
351
281
|
|
|
352
|
-
|
|
282
|
+
Todas as opções, defaults e limites estão em [Configuração](docs/configuration.md).
|
|
353
283
|
|
|
354
284
|
## Troubleshooting
|
|
355
285
|
|
|
356
|
-
|
|
286
|
+
Erros de configuração são levantados durante `Chronos.configure`; falhas de captura/entrega são contidas e podem ir ao logger seguro. Confirme TLS, credenciais, timeouts e retorno de `flush`. Consulte [Troubleshooting](docs/troubleshooting.md).
|
|
357
287
|
|
|
358
288
|
## Benchmark
|
|
359
289
|
|
|
360
|
-
|
|
290
|
+
O gate estável executa comparação Rack repetível e carga contra endpoint fake:
|
|
361
291
|
|
|
362
292
|
```bash
|
|
363
|
-
bundle _1.17.3_ exec ruby benchmarks/
|
|
364
|
-
bundle _1.17.3_ exec ruby benchmarks/
|
|
365
|
-
bundle _1.17.3_ exec ruby benchmarks/filtering.rb
|
|
366
|
-
bundle _1.17.3_ exec ruby benchmarks/queue.rb
|
|
367
|
-
bundle _1.17.3_ exec ruby benchmarks/retry_backlog.rb
|
|
368
|
-
bundle _1.17.3_ exec ruby benchmarks/request_overhead.rb
|
|
369
|
-
bundle _1.17.3_ exec ruby benchmarks/rails_notifications.rb
|
|
370
|
-
bundle _1.17.3_ exec ruby benchmarks/sidekiq_middleware.rb
|
|
371
|
-
bundle _1.17.3_ exec ruby benchmarks/apm_aggregation.rb
|
|
372
|
-
bundle _1.17.3_ exec ruby benchmarks/external_http.rb
|
|
373
|
-
bundle _1.17.3_ exec ruby benchmarks/correlation.rb
|
|
293
|
+
ITERATIONS=50000 WARMUP=5000 SAMPLES=7 bundle _1.17.3_ exec ruby benchmarks/comparative.rb
|
|
294
|
+
ITERATIONS=500 bundle _1.17.3_ exec ruby benchmarks/fake_endpoint_load.rb
|
|
374
295
|
```
|
|
375
296
|
|
|
376
|
-
|
|
297
|
+
Resultados dependem de runtime e hardware. Não há alegação genérica de superioridade; registre CPU, SO, Ruby, commit, warmup, amostras, mediana e dispersão. Outros benchmarks ficam em `benchmarks/` e estão descritos em [Performance](docs/performance.md).
|
|
377
298
|
|
|
378
|
-
##
|
|
299
|
+
## Migração do Airbrake
|
|
379
300
|
|
|
380
|
-
|
|
301
|
+
Migre por etapas e mantenha os dois agentes juntos somente durante a validação, evitando duplicidade prolongada. Callbacks e notices não são API-compatíveis e devem ser traduzidos/testados explicitamente. Consulte o [guia de migração do Airbrake](docs/migration-from-airbrake.md).
|
|
381
302
|
|
|
382
|
-
##
|
|
303
|
+
## Desenvolvimento local
|
|
383
304
|
|
|
384
|
-
|
|
305
|
+
Instale Bundler 1.17.3 e as dependências:
|
|
385
306
|
|
|
386
307
|
```bash
|
|
387
308
|
gem install bundler -v 1.17.3
|
|
388
309
|
bin/setup
|
|
389
310
|
```
|
|
390
311
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
```bash
|
|
394
|
-
bin/console
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
Install the current source locally:
|
|
398
|
-
|
|
399
|
-
```bash
|
|
400
|
-
bundle _1.17.3_ exec rake install
|
|
401
|
-
```
|
|
312
|
+
Use `bin/console` para inspeção e `bundle _1.17.3_ exec rake install` para instalar a fonte localmente. A arquitetura hexagonal está descrita em [Arquitetura](docs/architecture.md).
|
|
402
313
|
|
|
403
|
-
##
|
|
314
|
+
## Testes
|
|
404
315
|
|
|
405
|
-
|
|
316
|
+
Execute suíte e lint no runtime atual:
|
|
406
317
|
|
|
407
318
|
```bash
|
|
408
319
|
bundle _1.17.3_ exec rake
|
|
409
320
|
```
|
|
410
321
|
|
|
411
|
-
|
|
322
|
+
A matriz CI cobre Ruby 2.2.10–2.6.10, aplicações Rails 4.2/5.2 e Sidekiq 4/5. O workflow de release repete toda a matriz, documentação, benchmark comparativo e carga antes de publicar.
|
|
412
323
|
|
|
413
|
-
##
|
|
324
|
+
## Contribuição
|
|
414
325
|
|
|
415
|
-
|
|
326
|
+
Abra uma issue antes de adicionar API pública ou dependência. Classes públicas precisam de YARD, testes, documentação de módulo e evidência de compatibilidade. Veja [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
416
327
|
|
|
417
|
-
##
|
|
328
|
+
## Segurança
|
|
418
329
|
|
|
419
|
-
|
|
330
|
+
Nunca inclua credenciais no contexto. Releases usam Trusted Publishing, checksum SHA-256 e SBOM; dependências passam por auditoria. Reporte vulnerabilidades pelo canal privado de [SECURITY.md](SECURITY.md).
|
|
420
331
|
|
|
421
|
-
##
|
|
332
|
+
## Licença
|
|
422
333
|
|
|
423
|
-
Chronos Ruby
|
|
334
|
+
Chronos Ruby é distribuída sob a licença MIT. Veja [LICENSE.txt](LICENSE.txt).
|