sidekiq_prometheus 1.8.0 → 1.8.2

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: 564b12c7284161a3350d677f809da15ca5d70b0b2a9eb5303970639cb85aeedb
4
- data.tar.gz: 99c3995589218b36b0016d7585bedf17a4ac783fdfa4efb306b5bffbd8c6e766
3
+ metadata.gz: cfef2dcf926147bf8113fc2ef76ebc53e194b742bff8024e52915829ed315403
4
+ data.tar.gz: d312f2be0b37be88b32e4031560c03ad1386283c935e911435ba8929c108dc2b
5
5
  SHA512:
6
- metadata.gz: 261e2cc263e08cf1d5784c63a2af38855db615f995f5d66f5b8c8c837e80fe22c0a5f2c6a85671c7bc1c4144a5b5ca816916088a77281ffd5e099ebf1da07a23
7
- data.tar.gz: 6bccef33e7d74236fdad77eb93072f02804e838c5dc6760b26e7ed624667b1a73d0ebce1170469ce60345d2fed43bb1c2fab615e202c6fe4a76388b11d8e6054
6
+ metadata.gz: edc39e79efebc8d713ab0b4c60913b860c115fd99e6b8d096e705e41c698accb8e1765316e98371f67bd13c53e612254f656cf49713580b50675b15f8c9664f3
7
+ data.tar.gz: d03bdf927308ed353d34922c894c0363e68e1326792d95dd7052f87c2a38d2156a6cfd13954b3ee593adbc9a7e80407a84569387ead503ea5adcb1f2baccf955
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  CHANGELOG
2
2
 
3
+ <a name="v1.8.1"></a>
4
+ ## [v1.8.1](https://github.com/fastly/sidekiq-prometheus/compare/v1.8.0...v1.8.1) (2022-10-18)
5
+
6
+ ### Feature
7
+
8
+ * Support newer Sidekiq-Enterprise (#[31](https://github.com/fastly/sidekiq-prometheus/pull/31))
9
+
10
+ <a name="v1.8.0"></a>
11
+ ## [v1.8.0](https://github.com/fastly/sidekiq-prometheus/compare/v1.7.0...v1.8.0) (2022-10-04)
12
+
13
+ ### Features
14
+
15
+ * handle rate limiting exceptions distinctly from other exceptions ([#28](https://github.com/fastly/sidekiq-prometheus/issues/28))
16
+
17
+ ### Pull Requests
18
+
19
+ * Merge pull request [#27](https://github.com/fastly/sidekiq-prometheus/issues/27) from pinkahd/patch-1
20
+
21
+
3
22
  <a name="v1.7.0"></a>
4
23
  ## [v1.7.0](https://github.com/fastly/sidekiq-prometheus/compare/v1.6.0...v1.7.0) (2022-09-29)
5
24
 
data/README.md CHANGED
@@ -75,8 +75,8 @@ end
75
75
 
76
76
  #### Configuration options
77
77
 
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.
78
+ * `preset_labels`: Hash of labels that will be included with every metric when they are registered. `Hash{Symbol (label name) => String (label value)}`
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
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`.
@@ -91,7 +91,7 @@ end
91
91
  ```ruby
92
92
  SidekiqPrometheus.configure do |config|
93
93
  config.preset_labels = { service: 'myapp' }
94
- config.custom_labels = [:worker_class, :job_type, :any_other_label]
94
+ config.custom_labels = { sidekiq_job_count: [:worker_class, :job_type, :any_other_label] }
95
95
  config.gc_metrics_enabled = false
96
96
  config.global_metrics_enabled = true
97
97
  config.periodic_metrics_enabled = true
@@ -254,11 +254,7 @@ To install this gem onto your local machine, run `bundle exec rake install`.
254
254
 
255
255
  ## Contributors
256
256
 
257
- * Lukas Eklund ([@leklund](https://github.com/leklund))
258
- * NHM Tanveer Hossain Khan ([@we4tech](https://github.com/we4tech))
259
- * [@Postmodern](https://github.com/postmodern)
260
- * Ross Jones ([@rossjones](https://github.com/rossjones))
261
- * Alejandro Arrufat ([@mirubiri](https://github.com/mirubiri))
257
+ See: https://github.com/fastly/sidekiq-prometheus/graphs/contributors
262
258
 
263
259
  ## Contributing
264
260
 
@@ -10,7 +10,14 @@
10
10
  # @see https://github.com/mperham/sidekiq/wiki/Ent-Leader-Election
11
11
  # @see https://github.com/mperham/sidekiq/blob/main/lib/sidekiq/api.rb
12
12
 
13
+ begin
14
+ require 'sidekiq/component'
15
+ rescue LoadError
16
+ end
17
+
13
18
  class SidekiqPrometheus::PeriodicMetrics
19
+ include Sidekiq::Component if defined? Sidekiq::Component
20
+
14
21
  # @return [Boolean] When +true+ will stop the reporting loop.
15
22
  attr_accessor :done
16
23
 
@@ -28,23 +35,27 @@ class SidekiqPrometheus::PeriodicMetrics
28
35
  ##
29
36
  # Instance of SidekiqPrometheus::PeriodicMetrics
30
37
  # @return [SidekiqPrometheus:PeriodicMetrics]
31
- def self.reporter
32
- @reporter ||= new
38
+ def self.reporter(config)
39
+ @reporter ||= new(config: config)
33
40
  end
34
41
 
35
42
  ##
36
43
  # @param interval [Integer] Interval in seconds to record metrics.
37
44
  # @param sidekiq_stats [Sidekiq::Stats]
38
45
  # @param senate [#leader?] Sidekiq::Senate
39
- def initialize(interval: SidekiqPrometheus.periodic_reporting_interval, sidekiq_stats: Sidekiq::Stats, sidekiq_queue: Sidekiq::Queue, senate: nil)
46
+ def initialize(interval: SidekiqPrometheus.periodic_reporting_interval, sidekiq_stats: Sidekiq::Stats, sidekiq_queue: Sidekiq::Queue, senate: nil, config: nil)
40
47
  self.done = false
41
48
  @interval = interval
42
-
49
+ @config = config
43
50
  @sidekiq_stats = sidekiq_stats
44
51
  @sidekiq_queue = sidekiq_queue
45
52
  @senate = if senate.nil?
46
53
  if Object.const_defined?('Sidekiq::Senate')
47
- Sidekiq::Senate
54
+ if respond_to?(:leader?)
55
+ self
56
+ else
57
+ Sidekiq::Senate
58
+ end
48
59
  else
49
60
  Senate
50
61
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SidekiqPrometheus
4
- VERSION = '1.8.0'
4
+ VERSION = '1.8.2'
5
5
  end
@@ -195,8 +195,8 @@ module SidekiqPrometheus
195
195
  end
196
196
 
197
197
  if periodic_metrics_enabled?
198
- config.on(:startup) { SidekiqPrometheus::PeriodicMetrics.reporter.start }
199
- config.on(:shutdown) { SidekiqPrometheus::PeriodicMetrics.reporter.stop }
198
+ config.on(:startup) { SidekiqPrometheus::PeriodicMetrics.reporter(config).start }
199
+ config.on(:shutdown) { SidekiqPrometheus::PeriodicMetrics.reporter(config).stop }
200
200
  end
201
201
 
202
202
  if metrics_server_enabled?
@@ -27,8 +27,8 @@ 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', '~> 2.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', '< 7.0'
33
33
  spec.add_runtime_dependency 'webrick'
34
34
  end
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.0
4
+ version: 1.8.2
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: 2022-10-04 00:00:00.000000000 Z
12
+ date: 2022-11-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -85,14 +85,14 @@ dependencies:
85
85
  name: prometheus-client
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - "~>"
88
+ - - ">="
89
89
  - !ruby/object:Gem::Version
90
90
  version: '2.0'
91
91
  type: :runtime
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - "~>"
95
+ - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '2.0'
98
98
  - !ruby/object:Gem::Dependency
@@ -116,6 +116,9 @@ dependencies:
116
116
  - - ">"
117
117
  - !ruby/object:Gem::Version
118
118
  version: '5.1'
119
+ - - "<"
120
+ - !ruby/object:Gem::Version
121
+ version: '7.0'
119
122
  type: :runtime
120
123
  prerelease: false
121
124
  version_requirements: !ruby/object:Gem::Requirement
@@ -123,6 +126,9 @@ dependencies:
123
126
  - - ">"
124
127
  - !ruby/object:Gem::Version
125
128
  version: '5.1'
129
+ - - "<"
130
+ - !ruby/object:Gem::Version
131
+ version: '7.0'
126
132
  - !ruby/object:Gem::Dependency
127
133
  name: webrick
128
134
  requirement: !ruby/object:Gem::Requirement