flare 0.5.0 → 0.5.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 +4 -4
- data/README.md +12 -0
- data/lib/flare/cli/setup_command.rb +3 -0
- data/lib/flare/configuration.rb +8 -0
- data/lib/flare/metric_span_processor.rb +25 -2
- data/lib/flare/version.rb +1 -1
- data/lib/flare.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d9a717e37a1b09780b8430531cb36d7ed8881562522e69e9f7a770710f41ada6
|
|
4
|
+
data.tar.gz: a5becacc7ae0e85bd7b29e50f650ffc0c2105c425a190befad58098b85b83bc4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 02c2ffb1e25b8b447173ed8e1eba61c80051e91420ffccfa0f002f45e62cf8af832bb35b1776ff9026da6e665eca27992e13f418936d57faa02b36edc85b4292
|
|
7
|
+
data.tar.gz: 5579cf57806f815da0c5dd97a45a3397aaa7bd603a695353cd89772704767fea34bbcab4c21a3db75eb292797df56e8bc0272e8fba6aef84c9945f75ba37e383
|
data/README.md
CHANGED
|
@@ -135,6 +135,9 @@ Flare.configure do |config|
|
|
|
135
135
|
request.path.start_with?("/health")
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
# Exceptions that don't count as errors in metrics (see below)
|
|
139
|
+
config.ignore_errors << "MyApp::RetryLaterError"
|
|
140
|
+
|
|
138
141
|
# Subscribe to custom notification prefixes (default: ["app."])
|
|
139
142
|
config.subscribe_patterns << "mycompany."
|
|
140
143
|
|
|
@@ -145,6 +148,15 @@ Flare.configure do |config|
|
|
|
145
148
|
end
|
|
146
149
|
```
|
|
147
150
|
|
|
151
|
+
### Errors that aren't failures
|
|
152
|
+
|
|
153
|
+
Some exceptions are control flow. A GoodJob job with `perform_limit` or `perform_throttle` raises `GoodJob::ActiveJobExtensions::Concurrency::ConcurrencyExceededError` (or its subclass `ThrottleExceededError`) to wait its turn, then retries. Flare counts a span that ends with an exception in `config.ignore_errors`, or a subclass of one, as a success: it still counts toward throughput and duration, just not the error rate. Traces still record the exception. Append your own class names, or assign a new list to replace the default:
|
|
154
|
+
|
|
155
|
+
```ruby
|
|
156
|
+
config.ignore_errors << "MyApp::RetryLaterError"
|
|
157
|
+
config.ignore_errors = [] # count every exception as an error
|
|
158
|
+
```
|
|
159
|
+
|
|
148
160
|
## Custom Instrumentation
|
|
149
161
|
|
|
150
162
|
Flare automatically captures Rails internals, but you can also instrument your own code. Use `ActiveSupport::Notifications.instrument` with an `app.` prefix:
|
|
@@ -49,6 +49,9 @@ module Flare
|
|
|
49
49
|
# request.path.start_with?("/health")
|
|
50
50
|
# }
|
|
51
51
|
|
|
52
|
+
# Exceptions (and subclasses) that don't count as errors in metrics.
|
|
53
|
+
# config.ignore_errors << "MyApp::RetryLaterError"
|
|
54
|
+
|
|
52
55
|
# ── Metrics (remote monitoring) ────────────────────────────────────
|
|
53
56
|
# Metrics aggregate span data into counts, durations, and error rates.
|
|
54
57
|
# Enabled by default in development and production (disabled in test).
|
data/lib/flare/configuration.rb
CHANGED
|
@@ -9,6 +9,7 @@ module Flare
|
|
|
9
9
|
attr_accessor :retention_hours
|
|
10
10
|
attr_accessor :max_spans
|
|
11
11
|
attr_accessor :ignore_request
|
|
12
|
+
attr_accessor :ignore_errors
|
|
12
13
|
attr_writer :database_path
|
|
13
14
|
|
|
14
15
|
# Spans: detailed trace data stored in SQLite (default: development only)
|
|
@@ -35,6 +36,12 @@ module Flare
|
|
|
35
36
|
|
|
36
37
|
attr_accessor :subscribe_patterns
|
|
37
38
|
|
|
39
|
+
# Exceptions that jobs raise to wait or retry rather than to fail. A span
|
|
40
|
+
# that ends with one of these (or a subclass) counts as a success.
|
|
41
|
+
DEFAULT_IGNORE_ERRORS = %w[
|
|
42
|
+
GoodJob::ActiveJobExtensions::Concurrency::ConcurrencyExceededError
|
|
43
|
+
].freeze
|
|
44
|
+
|
|
38
45
|
# HTTP metrics path tracking configuration.
|
|
39
46
|
# Controls which outgoing HTTP paths are tracked with detail vs collapsed to "*".
|
|
40
47
|
attr_reader :http_metrics_config
|
|
@@ -49,6 +56,7 @@ module Flare
|
|
|
49
56
|
@max_spans = 10_000
|
|
50
57
|
@database_path = nil
|
|
51
58
|
@ignore_request = ->(request) { false }
|
|
59
|
+
@ignore_errors = DEFAULT_IGNORE_ERRORS.dup
|
|
52
60
|
@subscribe_patterns = DEFAULT_SUBSCRIBE_PATTERNS.dup
|
|
53
61
|
@debug = ENV["FLARE_DEBUG"] == "1"
|
|
54
62
|
@revision = ENV["FLARE_REVISION"]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "active_support/inflector/methods"
|
|
3
4
|
require_relative "metric_key"
|
|
4
5
|
require_relative "http_metrics_config"
|
|
5
6
|
require_relative "sql_mask"
|
|
@@ -30,9 +31,12 @@ module Flare
|
|
|
30
31
|
"solid_cache" => "solid_cache"
|
|
31
32
|
}.freeze
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
ACTIVE_JOB_ERROR_STATUS = /\AUnexpected ActiveJob Error (\S+)\z/
|
|
35
|
+
|
|
36
|
+
def initialize(storage:, http_metrics_config: nil, ignore_errors: nil)
|
|
34
37
|
@storage = storage
|
|
35
38
|
@http_metrics_config = http_metrics_config || HttpMetricsConfig::DEFAULT
|
|
39
|
+
@ignore_errors = ignore_errors || []
|
|
36
40
|
@pid = $$
|
|
37
41
|
end
|
|
38
42
|
|
|
@@ -301,7 +305,26 @@ module Flare
|
|
|
301
305
|
end
|
|
302
306
|
|
|
303
307
|
def span_error?(span)
|
|
304
|
-
span.status&.code
|
|
308
|
+
return false if span.status&.code != OpenTelemetry::Trace::Status::ERROR
|
|
309
|
+
return true if @ignore_errors.empty?
|
|
310
|
+
|
|
311
|
+
type = exception_type(span)
|
|
312
|
+
type.nil? || !ignored_exception_type?(type)
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
# A job's retried exception is recorded on its enqueue_retry child span,
|
|
316
|
+
# so the process span only names it in the status description.
|
|
317
|
+
def exception_type(span)
|
|
318
|
+
event = span.events&.reverse_each&.find { |e| e.name == "exception" }
|
|
319
|
+
event&.attributes&.[]("exception.type") ||
|
|
320
|
+
span.status.description.to_s[ACTIVE_JOB_ERROR_STATUS, 1]
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# Subclasses of an ignored class match when the class is loaded.
|
|
324
|
+
def ignored_exception_type?(type)
|
|
325
|
+
klass = ActiveSupport::Inflector.safe_constantize(type)
|
|
326
|
+
names = klass.is_a?(Class) ? klass.ancestors.map(&:name) : [type]
|
|
327
|
+
names.any? { |name| @ignore_errors.include?(name) }
|
|
305
328
|
end
|
|
306
329
|
|
|
307
330
|
def extract_job_system(span)
|
data/lib/flare/version.rb
CHANGED
data/lib/flare.rb
CHANGED
|
@@ -339,7 +339,8 @@ module Flare
|
|
|
339
339
|
@metric_storage ||= MetricStorage.new
|
|
340
340
|
metric_processor = MetricSpanProcessor.new(
|
|
341
341
|
storage: @metric_storage,
|
|
342
|
-
http_metrics_config: configuration.http_metrics_config
|
|
342
|
+
http_metrics_config: configuration.http_metrics_config,
|
|
343
|
+
ignore_errors: configuration.ignore_errors
|
|
343
344
|
)
|
|
344
345
|
OpenTelemetry.tracer_provider.add_span_processor(metric_processor)
|
|
345
346
|
|