sidekiq_prometheus 1.8.3 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9a7474fb0e37d8c0aa3849bc4c5df6ff3b8a173a3545fcf5027dc29f8d1c4eb
4
- data.tar.gz: 6cb664182b40af876f6e58c532c235d3169ca3cb154f9aa785faaec384c3e9db
3
+ metadata.gz: 654002b3b3138eef5307c4e4c3cab5a6d8ca45cc283c49341d3c1760f4d3ef67
4
+ data.tar.gz: 5abf477f0a4a8baa64e82d22527477614d57f48c8bf26c4d637a7c24bbb5cc70
5
5
  SHA512:
6
- metadata.gz: 467ce07f7b4a5b79dcb16f61d8da97076c32ed5e5bb7b892d19a9a1d397214bb254188cacdb615fa3495d7485ddad38d38ea3e6078bae6ffaf4928a513a79deb
7
- data.tar.gz: 3b47b8a80fa6569456b166374e9395db173c243e86fc63e36a25292f0d463c0a0501cd29374d51d490e5add972412b5901f77a077937436f5e1b7cfbb64a83b2
6
+ metadata.gz: 0544dc888a169886f532b2aa08ef8ab3c8c34ec1dea5a72bb9a75618aecfaaf4d1de81f6ae44cd61cc2621189ad69489a082f4af877cf63e7139ca3eb124a8dc
7
+ data.tar.gz: 7eb8689d5514e3585a6ee722a5f21d6f964a56146750d922fa578164a72ffbb36415c47befb10f7f7c61cc82ada60c7a4200b55370cf74ceae72270f4b423d98
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  CHANGELOG
2
2
 
3
+ <a name="v1.8.3"></a>
4
+ ## [v1.8.3](https://github.com/fastly/sidekiq-prometheus/compare/v1.8.2...v1.8.3) (2023-01-30)
5
+
6
+ ## What's Changed
7
+ * Track leader state so that can unregister when demoted by @leklund in https://github.com/fastly/sidekiq-prometheus/pull/36
8
+
9
+ **Full Changelog**: https://github.com/fastly/sidekiq-prometheus/compare/v1.8.2...v1.8.3
10
+
3
11
  <a name="v1.8.2"></a>
4
12
  ## [v1.8.2](https://github.com/fastly/sidekiq-prometheus/compare/v1.8.1...v1.8.2) (2022-11-29)
5
13
 
data/README.md CHANGED
@@ -79,6 +79,7 @@ end
79
79
  * `custom_labels`: Hash of metrics and labels that can be applied to specific metrics. The metric name must be a registered metric. `Hash{Symbol (metric name) => Array<Symbol> (label names)}`
80
80
  * `gc_metrics_enabled`: Boolean that determines whether to record object allocation metrics per job. The default is `true`. Setting this to `false` if you don't need this metric.
81
81
  * `global_metrics_enabled`: Boolean that determines whether to report global metrics from the PeriodicMetrics reporter. When `true` this will report on a number of stats from the Sidekiq API for the cluster. This requires Sidekiq::Enterprise as the reporter uses the leader election functionality to ensure that only one worker per cluster is reporting metrics.
82
+ * `init_label_sets`: Hash of metrics and label sets that are initialized by calling `metric.init_label_set` after the metric is registered. See[ prometheus-client docs](https://github.com/prometheus/client_ruby/tree/e144d6225d3c346e9a4dd0a11f41f8acde386dd8#init_label_set) for details. `Hash{Symbol (metric name) => Array<Hash> (label sets)}`.
82
83
  * `periodic_metrics_enabled`: Boolean that determines whether to run the periodic metrics reporter. `PeriodicMetrics` runs a separate thread that reports on global metrics (if enabled) as well worker GC stats (if enabled). It reports metrics on the interval defined by `periodic_reporting_interval`. Defaults to `true`.
83
84
  * `periodic_reporting_interval`: interval in seconds for reporting periodic metrics. Default: `30`
84
85
  * `metrics_server_enabled`: Boolean that determines whether to run the rack server. Defaults to `true`
@@ -94,6 +95,7 @@ SidekiqPrometheus.configure do |config|
94
95
  config.custom_labels = { sidekiq_job_count: [:worker_class, :job_type, :any_other_label] }
95
96
  config.gc_metrics_enabled = false
96
97
  config.global_metrics_enabled = true
98
+ config.init_label_sets = { sidekiq_job_count: [{worker_class: "class", job_type: "single", any_other_label: "value"}, {worker_class: "class", job_type: "batch", any_other_label: "other-value"}] }
97
99
  config.periodic_metrics_enabled = true
98
100
  config.periodic_reporting_interval = 20
99
101
  config.metrics_server_enabled = true
@@ -101,7 +103,7 @@ SidekiqPrometheus.configure do |config|
101
103
  end
102
104
  ```
103
105
 
104
- Custom labels may be added by defining the `prometheus_labels` method in the worker class,
106
+ Custom labels may be added by defining the `prometheus_labels` method in the worker class,
105
107
  prior you need to register the custom labels as of the above example:
106
108
 
107
109
  ```ruby
@@ -130,10 +132,13 @@ All Sidekiq job metrics are reported with these labels:
130
132
  | sidekiq_job_success | counter | Count of successful Sidekiq jobs |
131
133
  | sidekiq_job_allocated_objects | histogram | Count of ruby objects allocated by a Sidekiq job |
132
134
  | sidekiq_job_failed | counter | Count of failed Sidekiq jobs |
135
+ | sidekiq_job_over_limit | counter | Count of over limit Sidekiq jobs |
136
+
133
137
 
134
138
  Notes:
135
139
 
136
140
  * when a job fails only `sidekiq_job_count` and `sidekiq_job_failed` will be reported.
141
+ * when a job fails due to Sidekiq::Limiter::OverLimit error, only `sidekiq_job_count` and `sidekiq_job_over_limit` will be reported.
137
142
  * `sidekiq_job_allocated_objects` will only be reported if `SidekiqPrometheus.gc_metrics_enabled? == true`
138
143
 
139
144
  ### Periodic GC Metrics
@@ -217,7 +222,7 @@ There is also a method to register more than one metric at a time:
217
222
  customer_worker_metrics = [
218
223
  {
219
224
  name: :file_count, type: :counter, docstring: 'Number of active files',
220
- name: :file_size, type: :gauge, docstring: 'Size of files in bytes',
225
+ name: :file_size, type: :gauge, docstring: 'Size of files in bytes',
221
226
  }
222
227
  ]
223
228
 
@@ -30,7 +30,7 @@ class SidekiqPrometheus::JobMetrics
30
30
 
31
31
  result
32
32
  rescue => e
33
- if e.class.to_s == "Sidekiq::Limiter::OverLimit"
33
+ if e.instance_of?(::Sidekiq::Limiter::OverLimit)
34
34
  registry[:sidekiq_job_over_limit].increment(labels: labels)
35
35
  else
36
36
  err_label = {error_class: e.class.to_s}
@@ -176,7 +176,12 @@ module SidekiqPrometheus::Metrics
176
176
 
177
177
  options[:buckets] = buckets if buckets
178
178
 
179
- registry.send(type, name.to_sym, **options)
179
+ metric = registry.send(type, name.to_sym, **options)
180
+
181
+ init_label_sets = SidekiqPrometheus.init_label_sets.fetch(name, [])
182
+ init_label_sets.each { |label_set| metric.init_label_set(label_set) }
183
+
184
+ metric
180
185
  end
181
186
 
182
187
  def unregister(name:)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SidekiqPrometheus
4
- VERSION = "1.8.3"
4
+ VERSION = "1.9.0"
5
5
  end
@@ -42,6 +42,14 @@ module SidekiqPrometheus
42
42
  # @return [Boolean] Setting to control enabling/disabling global metrics. Default: true
43
43
  attr_accessor :global_metrics_enabled
44
44
 
45
+ # @return [Hash{Symbol => Array(Hash)}] Label sets that will be initiliazed when a metric is registered.
46
+ # @example
47
+ # {
48
+ # metric_name: [{label: 'value1', other_label: 'value1'}, {label: 'value1', other_label: 'value2'}],
49
+ # another_metric_name: [{label: 'value1', other_label: 'value1'}]
50
+ # }
51
+ attr_accessor :init_label_sets
52
+
45
53
  # @return [Boolean] Setting to control enabling/disabling periodic metrics. Default: true
46
54
  attr_accessor :periodic_metrics_enabled
47
55
 
@@ -82,6 +90,7 @@ module SidekiqPrometheus
82
90
  self.metrics_server_logger_enabled = true
83
91
  self.custom_labels = {}
84
92
  self.custom_metrics = []
93
+ self.init_label_sets = {}
85
94
 
86
95
  module_function
87
96
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq_prometheus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Eklund
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-01-30 00:00:00.000000000 Z
12
+ date: 2023-08-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  - !ruby/object:Gem::Version
189
189
  version: '0'
190
190
  requirements: []
191
- rubygems_version: 3.4.1
191
+ rubygems_version: 3.3.7
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: Prometheus Instrumentation for Sidekiq