sidekiq_prometheus 0.9.1 → 1.2.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: db02e6a73906c876430f6d54584035af02baaa208ef092c31fc08e0182d01534
4
- data.tar.gz: bb146c52c773bc61edab389892326901fab130560c6f7cf1d449abae3250a929
3
+ metadata.gz: 6cef078a53e6742cd0cea7140dbe65ab96849acc8886880f530cbe208ee8fefc
4
+ data.tar.gz: 63dc0623415214f85a2bcb0b37cfaef012a016bb75d430763d9bfa3ed097460a
5
5
  SHA512:
6
- metadata.gz: e6408684452a45e2145b9294ae7bb0f991b7824d14b847ccbcf6b951b9d372cd72ce946945f07e138a7b8ad312b03343590f2ac8314bc270f2e75c66368b3b1d
7
- data.tar.gz: 91f0409841a1a29e30809fee05478310a74ef58ed009de90b439e2a81e3e73f55f3f618e77c150d023a64b256700e1820ec09b490f51ac05e52e1776fbfdcd9c
6
+ metadata.gz: 3721b3aaf34de0717d2d23639aeb2413fe5f9b9580ae1f07bcf333bcfae1d7c110425b1e0c850d06ba29459ca7506d06130322dd3ea1461e164c3264228628c0
7
+ data.tar.gz: cf08ac6f8f3779c3a8789063de3073e4838945cd4d6190b7284184c19bbd2ec2f156143502a160f9b9a91fb11bb644ca2f43e20aa11533313f4ada60d80a2a21
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /tmp/
9
9
  .rspec_status
10
10
  Gemfile.lock
11
+ /.idea/
@@ -1,5 +1,48 @@
1
1
  CHANGELOG
2
2
 
3
+ <a name="v1.2.0"></a>
4
+ ## [v1.2.0](https://github.com/fastly/sidekiq-prometheus/compare/v1.1.0...v1.2.0) (2020-10-01)
5
+
6
+ ### Feature
7
+
8
+ * allow the metrics host to be disabled with a configuration option
9
+ * use prometheus-client ~> 2.0
10
+
11
+ ### Pull Requests
12
+
13
+ * Merge pull request [#17](https://github.com/fastly/sidekiq-prometheus/issues/17) from jetpks/add-option-to-disable-metrics-server
14
+ * Merge pull request [#15](https://github.com/fastly/sidekiq-prometheus/issues/15) from silicakes/master
15
+
16
+ <a name="v1.1.0"></a>
17
+ ## [v1.1.0](https://github.com/fastly/sidekiq-prometheus/compare/v1.0.1...v1.1.0) (2020-02-12)
18
+
19
+ ### Feature
20
+
21
+ * allow for configuration of the metrics host (instead of always binding to 127.0.0.1)
22
+ * Use prometheus-client ~> 1.0.0
23
+
24
+ ### Pull Requests
25
+
26
+ * Merge pull request [#13](https://github.com/fastly/sidekiq-prometheus/issues/13) from postmodern/metrics_host
27
+ * Merge pull request [#11](https://github.com/fastly/sidekiq-prometheus/issues/11) from rossjones/patch-1
28
+ * Merge pull request [#12](https://github.com/fastly/sidekiq-prometheus/issues/12) from fastly/hr
29
+
30
+ <a name="v1.0.0"></a>
31
+ ## [v1.0.0](https://github.com/fastly/sidekiq-prometheus/compare/v0.9.1...v1.0.0) (2019-10-24)
32
+
33
+ ### Pull Requests
34
+
35
+ * Merge pull request [#9](https://github.com/fastly/sidekiq-prometheus/issues/9) from we4tech/features/update-prometheus-client
36
+
37
+
38
+ <a name="v0.9.1"></a>
39
+ ## [v0.9.1](https://github.com/fastly/sidekiq-prometheus/compare/v0.9.0...v0.9.1) (2019-07-08)
40
+
41
+ ### Bug Fixes
42
+
43
+ * properly alias configure!
44
+
45
+
3
46
  <a name="v0.9.0"></a>
4
47
  ## [v0.9.0](https://github.com/fastly/sidekiq-prometheus/compare/v0.8.1...v0.9.0) (2019-03-18)
5
48
 
data/README.md CHANGED
@@ -58,43 +58,50 @@ You can configure the gem by calling `configure`:
58
58
 
59
59
  ```ruby
60
60
  SidekiqPrometheus.configure do |config|
61
- config.base_labels = { service: 'kubernandos_api' }
61
+ config.preset_labels = { service: 'kubernandos_api' }
62
62
  end
63
63
  ```
64
64
 
65
65
  `configure` will automatically call setup so
66
66
 
67
- If you are running multiple services that will be reporting Sidekiq metrics you will want to take advantage of the `base_labels` configuration option. For example:
67
+ If you are running multiple services that will be reporting Sidekiq metrics you will want to take advantage of the `preset_labels` configuration option. For example:
68
68
 
69
69
  ```ruby
70
70
  SidekiqPrometheus.configure do |config|
71
- config.base_labels = { service: 'image_api' }
71
+ config.preset_labels = { service: 'image_api' }
72
72
  config.metrics_port = 9090
73
73
  end
74
74
  ```
75
75
 
76
76
  #### Configuration options
77
77
 
78
- * `base_labels`: Hash of labels that will be included with every metric when they are registered.
78
+ * `preset_labels`: Hash of labels that will be included with every metric when they are registered.
79
+ * `custom_labels`: Array of names for each label that will be passed during the reporting.
79
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.
80
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.
81
82
  * `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`.
82
83
  * `periodic_reporting_interval`: interval in seconds for reporting periodic metrics. Default: `30`
84
+ * `metrics_server_enabled`: Boolean that determines whether to run the rack server. Defaults to `true`
85
+ * `metrics_host`: Host on which the rack server will listen. Defaults to
86
+ `localhost`
83
87
  * `metrics_port`: Port on which the rack server will listen. Defaults to `9359`
84
88
  * `registry`: An instance of `Prometheus::Client::Registry`. If you have a registry with defined metrics you can use this option to pass in your registry.
85
89
 
86
90
  ```ruby
87
91
  SidekiqPrometheus.configure do |config|
88
- config.base_labels = { service: 'myapp' }
92
+ config.preset_labels = { service: 'myapp' }
93
+ config.custom_labels = [:worker_class, :job_type, :any_other_label]
89
94
  config.gc_metrics_enabled = false
90
95
  config.global_metrics_enabled = true
91
96
  config.periodic_metrics_enabled = true
92
97
  config.periodic_reporting_interval = 20
98
+ config.metrics_server_enabled = true
93
99
  config.metrics_port = 8675
94
100
  end
95
101
  ```
96
102
 
97
- Custom labels may be added by defining the `prometheus_labels` method in the worker class:
103
+ Custom labels may be added by defining the `prometheus_labels` method in the worker class,
104
+ prior you need to register the custom labels as of the above example:
98
105
 
99
106
  ```ruby
100
107
  class SomeWorker
@@ -164,7 +171,7 @@ which ensures that metrics are only reported once per cluster.
164
171
  | sidekiq_redis_keys | gauge | Number of redis keys |
165
172
  | sidekiq_redis_expires | gauge | Number of redis keys with expiry set |
166
173
 
167
- The global metrics are reported with the only the `base_labels` with the exception of `sidekiq_enqueued` which will add a `queue` label and record a metric per Sidekiq queue.
174
+ The global metrics are reported with the only the `preset_labels` with the exception of `sidekiq_enqueued` which will add a `queue` label and record a metric per Sidekiq queue.
168
175
 
169
176
  ## Custom Worker Metrics
170
177
 
@@ -175,14 +182,14 @@ There are a few different ways to register custom metrics with SidekiqPrometheus
175
182
  name: :metric_name,
176
183
  type: :gauge,
177
184
  docstring: 'description',
178
- base_labels: { label_name: 'label_text' },
185
+ preset_labels: { label_name: 'label_text' },
179
186
  }
180
187
  ```
181
188
 
182
189
  * `:name` (required) - Unique name of the metric and should be a symbol.
183
190
  * `:type` (required) - Prometheus metric type. Supported values are: `:counter`, `:gauge`, `:histogram`, and `:summary`.
184
191
  * `:docstring` (required) - Human readable description of the metric.
185
- * `:base_labels` (optional) - Hash of labels that will be applied to every instance of this metric.
192
+ * `:preset_labels` (optional) - Hash of labels that will be applied to every instance of this metric.
186
193
 
187
194
  #### Registering custom metrics:
188
195
 
@@ -240,10 +247,17 @@ See the [documentation of the Prometheus::Client library](https://github.com/pro
240
247
 
241
248
  ## Development
242
249
 
243
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
250
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
244
251
 
245
252
  To install this gem onto your local machine, run `bundle exec rake install`.
246
253
 
254
+ ## Contributors
255
+
256
+ * Lukas Eklund ([@leklund](https://github.com/leklund))
257
+ * NHM Tanveer Hossain Khan ([@we4tech](https://github.com/we4tech))
258
+ * [@Postmodern](https://github.com/postmodern)
259
+ * Ross Jones ([@rossjones](https://github.com/rossjones))
260
+
247
261
  ## Contributing
248
262
 
249
263
  Bug reports and pull requests are welcome on GitHub at https://github.com/fastly/sidekiq-prometheus. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -259,3 +273,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
259
273
  ## Code of Conduct
260
274
 
261
275
  Everyone interacting in the SidekiqPrometheus project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fastly/sidekiq-prometheus/blob/master/CODE_OF_CONDUCT.md).
276
+
277
+ # Metadata
278
+
279
+ - Ignore
@@ -14,10 +14,10 @@ end
14
14
 
15
15
  module SidekiqPrometheus
16
16
  class << self
17
- # @return [Hash] Base labels applied to every registered metric
18
- attr_accessor :base_labels
17
+ # @return [Hash] Preset labels applied to every registered metric
18
+ attr_accessor :preset_labels
19
19
 
20
- # @return [Hash] Custom labels applied to specific metrics
20
+ # @return [Hash{Symbol => Array<Symbol>}] Custom labels applied to specific metrics
21
21
  attr_accessor :custom_labels
22
22
 
23
23
  # @return [Array] Custom metrics that will be registered on setup.
@@ -27,12 +27,12 @@ module SidekiqPrometheus
27
27
  # name: :metric_name,
28
28
  # type: :prometheus_metric_type,
29
29
  # docstring: 'Description of the metric',
30
- # base_labels : { label: 'value' },
30
+ # preset_labels : { label: 'value' },
31
31
  # }
32
32
  # ]
33
33
  # @note Each element of the array is a hash and must have the required keys: `:name`, `:type`, and `:docstring`.
34
34
  # The values for `:name` and `:type` should be symbols and `:docstring` should be a string.
35
- # `base_labels` is optional and, if used, must be a hash of labels that will be included on every instance of this metric.
35
+ # `preset_labels` is optional and, if used, must be a hash of labels that will be included on every instance of this metric.
36
36
  attr_accessor :custom_metrics
37
37
 
38
38
  # @return [Boolean] Setting to control enabling/disabling GC metrics. Default: true
@@ -47,6 +47,12 @@ module SidekiqPrometheus
47
47
  # @return [Integer] Interval in seconds to record metrics. Default: 30
48
48
  attr_accessor :periodic_reporting_interval
49
49
 
50
+ # @return [Boolean] Setting to control enabling/disabling the metrics server. Default: true
51
+ attr_accessor :metrics_server_enabled
52
+
53
+ # @return [String] Host on which the metrics server will listen. Default: localhost
54
+ attr_accessor :metrics_host
55
+
50
56
  # @return [Integer] Port on which the metrics server will listen. Default: 9357
51
57
  attr_accessor :metrics_port
52
58
 
@@ -66,6 +72,8 @@ module SidekiqPrometheus
66
72
  self.periodic_metrics_enabled = true
67
73
  self.global_metrics_enabled = true
68
74
  self.periodic_reporting_interval = 30
75
+ self.metrics_server_enabled = true
76
+ self.metrics_host = 'localhost'
69
77
  self.metrics_port = 9359
70
78
  self.custom_labels = {}
71
79
  self.custom_metrics = []
@@ -82,8 +90,8 @@ module SidekiqPrometheus
82
90
  # Configure SidekiqPrometheus and setup for reporting
83
91
  # @example
84
92
  # SidekiqPrometheus.configure do |config|
85
- # config.base_labels = { service: 'images_api' }
86
- # config.custom_labels = { sidekiq_job_count: { object_klass: nil } }
93
+ # config.preset_labels = { service: 'images_api' }
94
+ # config.custom_labels = { sidekiq_job_count: [:custom_label_1, :custom_label_2] } }
87
95
  # config.gc_metrics_enabled = true
88
96
  # end
89
97
  def configure
@@ -113,6 +121,13 @@ module SidekiqPrometheus
113
121
  periodic_metrics_enabled
114
122
  end
115
123
 
124
+ ##
125
+ # Helper method for +metrics_server_enabled+ configuration setting
126
+ # @return [Boolean] defaults to true
127
+ def metrics_server_enabled?
128
+ metrics_server_enabled
129
+ end
130
+
116
131
  ##
117
132
  # Get a metric from the registry
118
133
  # @param metric [Symbol] name of metric to fetch
@@ -172,14 +187,17 @@ module SidekiqPrometheus
172
187
  config.on(:shutdown) { SidekiqPrometheus::PeriodicMetrics.reporter.stop }
173
188
  end
174
189
 
175
- config.on(:startup) { SidekiqPrometheus.metrics_server }
176
- config.on(:shutdown) { SidekiqPrometheus.metrics_server.kill }
190
+ if metrics_server_enabled?
191
+ config.on(:startup) { SidekiqPrometheus.metrics_server }
192
+ config.on(:shutdown) { SidekiqPrometheus.metrics_server.kill }
193
+ end
177
194
  end
178
195
  end
179
196
 
180
197
  ##
181
198
  # Start a new Prometheus exporter in a new thread.
182
- # Will listen on SidekiqPrometheus.metrics_port
199
+ # Will listen on SidekiqPrometheus.metrics_host and
200
+ # SidekiqPrometheus.metrics_port
183
201
  def metrics_server
184
202
  @_metrics_server ||= Thread.new do
185
203
  Rack::Handler::WEBrick.run(
@@ -188,7 +206,7 @@ module SidekiqPrometheus
188
206
  run ->(_) { [301, { 'Location' => '/metrics' }, []] }
189
207
  },
190
208
  Port: SidekiqPrometheus.metrics_port,
191
- BindAddress: '127.0.0.1',
209
+ Host: SidekiqPrometheus.metrics_host,
192
210
  )
193
211
  end
194
212
  end
@@ -15,20 +15,20 @@ class SidekiqPrometheus::JobMetrics
15
15
  # In case the labels have changed after the worker perform method has been called
16
16
  labels.merge!(custom_labels(worker))
17
17
 
18
- registry[:sidekiq_job_duration].observe(labels, duration)
19
- registry[:sidekiq_job_success].increment(labels)
18
+ registry[:sidekiq_job_duration].observe(duration, labels: labels)
19
+ registry[:sidekiq_job_success].increment(labels: labels)
20
20
 
21
21
  if SidekiqPrometheus.gc_metrics_enabled?
22
22
  allocated = GC.stat(:total_allocated_objects) - before
23
- registry[:sidekiq_job_allocated_objects].observe(labels, allocated)
23
+ registry[:sidekiq_job_allocated_objects].observe(allocated, labels: labels)
24
24
  end
25
25
 
26
26
  result
27
27
  rescue StandardError => e
28
- registry[:sidekiq_job_failed].increment(labels)
28
+ registry[:sidekiq_job_failed].increment(labels: labels)
29
29
  raise e
30
30
  ensure
31
- registry[:sidekiq_job_count].increment(labels)
31
+ registry[:sidekiq_job_count].increment(labels: labels)
32
32
  end
33
33
  end
34
34
 
@@ -6,6 +6,7 @@ module SidekiqPrometheus::Metrics
6
6
  UNKNOWN = 'unknown'
7
7
 
8
8
  VALID_TYPES = %i[counter gauge histogram summary].freeze
9
+ JOB_LABELS = %i[class queue].freeze
9
10
  SIDEKIQ_GLOBAL_METRICS = [
10
11
  { name: :sidekiq_workers_size,
11
12
  type: :gauge,
@@ -15,10 +16,12 @@ module SidekiqPrometheus::Metrics
15
16
  docstring: 'Total Dead Size', },
16
17
  { name: :sidekiq_enqueued,
17
18
  type: :gauge,
18
- docstring: 'Total Size of all known queues', },
19
+ docstring: 'Total Size of all known queues',
20
+ labels: %i[queue], },
19
21
  { name: :sidekiq_queue_latency,
20
22
  type: :summary,
21
- docstring: 'Latency (in seconds) of all queues', },
23
+ docstring: 'Latency (in seconds) of all queues',
24
+ labels: %i[queue], },
22
25
  { name: :sidekiq_failed,
23
26
  type: :gauge,
24
27
  docstring: 'Number of job executions which raised an error', },
@@ -42,30 +45,37 @@ module SidekiqPrometheus::Metrics
42
45
  docstring: 'Used memory peak from Redis.info', },
43
46
  { name: :sidekiq_redis_keys,
44
47
  type: :gauge,
45
- docstring: 'Number of redis keys', },
48
+ docstring: 'Number of redis keys',
49
+ labels: %i[database], },
46
50
  { name: :sidekiq_redis_expires,
47
51
  type: :gauge,
48
- docstring: 'Number of redis keys with expiry set', },
52
+ docstring: 'Number of redis keys with expiry set',
53
+ labels: %i[database], },
49
54
  ].freeze
50
55
  SIDEKIQ_JOB_METRICS = [
51
56
  { name: :sidekiq_job_count,
52
57
  type: :counter,
53
- docstring: 'Count of Sidekiq jobs', },
58
+ docstring: 'Count of Sidekiq jobs',
59
+ labels: JOB_LABELS, },
54
60
  { name: :sidekiq_job_duration,
55
61
  type: :histogram,
56
- docstring: 'Sidekiq job processing duration', },
62
+ docstring: 'Sidekiq job processing duration',
63
+ labels: JOB_LABELS, },
57
64
  { name: :sidekiq_job_failed,
58
65
  type: :counter,
59
- docstring: 'Count of failed Sidekiq jobs', },
66
+ docstring: 'Count of failed Sidekiq jobs',
67
+ labels: JOB_LABELS, },
60
68
  { name: :sidekiq_job_success,
61
69
  type: :counter,
62
- docstring: 'Count of successful Sidekiq jobs', },
70
+ docstring: 'Count of successful Sidekiq jobs',
71
+ labels: JOB_LABELS, },
63
72
  ].freeze
64
73
  SIDEKIQ_GC_METRIC = {
65
74
  name: :sidekiq_job_allocated_objects,
66
75
  type: :histogram,
67
76
  docstring: 'Count of ruby objects allocated by a Sidekiq job',
68
77
  buckets: [10, 50, 100, 500, 1_000, 2_500, 5_000, 10_000, 50_000, 100_000, 500_000, 1_000_000, 5_000_000, 10_000_000, 25_000_000],
78
+ labels: JOB_LABELS,
69
79
  }.freeze
70
80
  SIDEKIQ_WORKER_GC_METRICS = [
71
81
  { name: :sidekiq_allocated_objects,
@@ -130,21 +140,26 @@ module SidekiqPrometheus::Metrics
130
140
  # @param types [Symbol] type of metric to register. Valid types: %w(counter gauge summary histogram)
131
141
  # @param name [Symbol] name of metric
132
142
  # @param docstring [String] help text for metric
133
- # @param base_labels [Hash] Optional hash of base labels to use for every instance of this metric
143
+ # @param labels [Array] Optionally an array of labels to configure for every instance of this metric
144
+ # @param preset_labels [Hash] Optionally a Hash of labels to use for every instance of this metric
134
145
  # @param buckets [Hash] Optional hash of bucket values. Only used for histogram metrics.
135
- def register(type:, name:, docstring:, base_labels: {}, buckets: nil)
146
+ def register(type:, name:, docstring:, labels: [], preset_labels: {}, buckets: nil)
136
147
  raise InvalidMetricType, type unless VALID_TYPES.include? type
137
148
 
138
- custom_labels = SidekiqPrometheus.custom_labels[name]
149
+ # Aggregate all preset labels
150
+ all_preset_labels = preset_labels.dup
151
+ all_preset_labels.merge!(SidekiqPrometheus.preset_labels) if SidekiqPrometheus.preset_labels
139
152
 
140
- base_labels.merge! custom_labels if custom_labels&.is_a?(Hash)
141
- base_labels.merge! SidekiqPrometheus.base_labels if SidekiqPrometheus.base_labels
153
+ # Aggregate all labels
154
+ all_labels = labels | SidekiqPrometheus.custom_labels.fetch(name, []) | all_preset_labels.keys
142
155
 
143
- args = [name.to_sym, docstring]
144
- args << base_labels
145
- args << buckets if buckets
156
+ options = { docstring: docstring,
157
+ labels: all_labels,
158
+ preset_labels: all_preset_labels, }
146
159
 
147
- registry.send(type, *args)
160
+ options[:buckets] = buckets if buckets
161
+
162
+ registry.send(type, name.to_sym, options)
148
163
  end
149
164
 
150
165
  def unregister(name:)
@@ -71,13 +71,13 @@ class SidekiqPrometheus::PeriodicMetrics
71
71
  def report_gc_metrics
72
72
  stats = GC.stat
73
73
  GC_STATS[:counters].each do |stat|
74
- SidekiqPrometheus["sidekiq_#{stat}"]&.increment({}, stats[stat])
74
+ SidekiqPrometheus["sidekiq_#{stat}"]&.increment(labels: {}, by: stats[stat])
75
75
  end
76
76
  GC_STATS[:gauges].each do |stat|
77
- SidekiqPrometheus["sidekiq_#{stat}"]&.set({}, stats[stat])
77
+ SidekiqPrometheus["sidekiq_#{stat}"]&.set(stats[stat], labels: {})
78
78
  end
79
79
 
80
- SidekiqPrometheus[:sidekiq_rss]&.set({}, rss)
80
+ SidekiqPrometheus[:sidekiq_rss]&.set(rss, labels: {})
81
81
  end
82
82
 
83
83
  ##
@@ -85,12 +85,12 @@ class SidekiqPrometheus::PeriodicMetrics
85
85
  def report_global_metrics
86
86
  current_stats = sidekiq_stats.new
87
87
  GLOBAL_STATS.each do |stat|
88
- SidekiqPrometheus["sidekiq_#{stat}"]&.set({}, current_stats.send(stat))
88
+ SidekiqPrometheus["sidekiq_#{stat}"]&.set(current_stats.send(stat), labels: {})
89
89
  end
90
90
 
91
91
  sidekiq_queue.all.each do |queue|
92
- SidekiqPrometheus[:sidekiq_enqueued]&.set({ queue: queue.name }, queue.size)
93
- SidekiqPrometheus[:sidekiq_queue_latency]&.observe({ queue: queue.name }, queue.latency)
92
+ SidekiqPrometheus[:sidekiq_enqueued]&.set(queue.size, labels: { queue: queue.name })
93
+ SidekiqPrometheus[:sidekiq_queue_latency]&.observe(queue.latency, labels: { queue: queue.name })
94
94
  end
95
95
  end
96
96
 
@@ -106,15 +106,15 @@ class SidekiqPrometheus::PeriodicMetrics
106
106
  return if redis_info.nil?
107
107
 
108
108
  REDIS_STATS.each do |stat|
109
- SidekiqPrometheus["sidekiq_redis_#{stat}"]&.set({}, redis_info[stat].to_i)
109
+ SidekiqPrometheus["sidekiq_redis_#{stat}"]&.set(redis_info[stat].to_i, labels: {})
110
110
  end
111
111
 
112
112
  db_stats = redis_info.select { |k, _v| k.match(/^db/) }
113
113
  db_stats.each do |db, stat|
114
114
  label = { database: db }
115
115
  values = stat.scan(/\d+/)
116
- SidekiqPrometheus[:sidekiq_redis_keys]&.set(label, values[0].to_i)
117
- SidekiqPrometheus[:sidekiq_redis_expires]&.set(label, values[1].to_i)
116
+ SidekiqPrometheus[:sidekiq_redis_keys]&.set(values[0].to_i, labels: label)
117
+ SidekiqPrometheus[:sidekiq_redis_expires]&.set(values[1].to_i, labels: label)
118
118
  end
119
119
  end
120
120
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SidekiqPrometheus
4
- VERSION = '0.9.1'
4
+ VERSION = '1.2.0'
5
5
  end
@@ -7,7 +7,7 @@ require 'sidekiq_prometheus/version'
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'sidekiq_prometheus'
9
9
  spec.version = SidekiqPrometheus::VERSION
10
- spec.authors = ['Lukas Eklund']
10
+ spec.authors = ['Lukas Eklund', 'NHM Tanveer Hossain Khan']
11
11
  spec.email = ['leklund@fastly.com']
12
12
 
13
13
  spec.summary = 'Prometheus Instrumentation for Sidekiq'
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'rspec', '~> 3.0'
28
28
  spec.add_development_dependency 'rubocop', '~> 0.58.0'
29
29
 
30
- spec.add_runtime_dependency 'prometheus-client', '~> 0.8.0'
30
+ spec.add_runtime_dependency 'prometheus-client', '~> 2.0'
31
31
  spec.add_runtime_dependency 'rack'
32
- spec.add_runtime_dependency 'sidekiq', '~> 5.1'
32
+ spec.add_runtime_dependency 'sidekiq', '> 5.1'
33
33
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq_prometheus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Eklund
8
+ - NHM Tanveer Hossain Khan
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2019-07-08 00:00:00.000000000 Z
12
+ date: 2020-10-01 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
@@ -86,14 +87,14 @@ dependencies:
86
87
  requirements:
87
88
  - - "~>"
88
89
  - !ruby/object:Gem::Version
89
- version: 0.8.0
90
+ version: '2.0'
90
91
  type: :runtime
91
92
  prerelease: false
92
93
  version_requirements: !ruby/object:Gem::Requirement
93
94
  requirements:
94
95
  - - "~>"
95
96
  - !ruby/object:Gem::Version
96
- version: 0.8.0
97
+ version: '2.0'
97
98
  - !ruby/object:Gem::Dependency
98
99
  name: rack
99
100
  requirement: !ruby/object:Gem::Requirement
@@ -112,14 +113,14 @@ dependencies:
112
113
  name: sidekiq
113
114
  requirement: !ruby/object:Gem::Requirement
114
115
  requirements:
115
- - - "~>"
116
+ - - ">"
116
117
  - !ruby/object:Gem::Version
117
118
  version: '5.1'
118
119
  type: :runtime
119
120
  prerelease: false
120
121
  version_requirements: !ruby/object:Gem::Requirement
121
122
  requirements:
122
- - - "~>"
123
+ - - ">"
123
124
  - !ruby/object:Gem::Version
124
125
  version: '5.1'
125
126
  description:
@@ -167,8 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
168
  - !ruby/object:Gem::Version
168
169
  version: '0'
169
170
  requirements: []
170
- rubyforge_project:
171
- rubygems_version: 2.7.8
171
+ rubygems_version: 3.0.6
172
172
  signing_key:
173
173
  specification_version: 4
174
174
  summary: Prometheus Instrumentation for Sidekiq