sidekiq-influxdb 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,4 @@
1
1
  require "sidekiq/influxdb/version"
2
2
  require "sidekiq/middleware/server/influxdb"
3
+ require "sidekiq/metrics/queues"
4
+ require "sidekiq/metrics/stats"
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module InfluxDB
3
- VERSION = "1.3.0"
3
+ VERSION = "1.4.0"
4
4
  end
5
5
  end
@@ -0,0 +1,41 @@
1
+ require 'sidekiq/api'
2
+
3
+ module Sidekiq
4
+ module Metrics
5
+ class Queues
6
+
7
+ def initialize(
8
+ influxdb_client:,
9
+ series_name: 'sidekiq_queues',
10
+ retention_policy: nil,
11
+ tags: {}
12
+ )
13
+ @influxdb = influxdb_client
14
+ @series = series_name
15
+ @retention = retention_policy
16
+ @tags = tags
17
+ end
18
+
19
+ def publish
20
+ queues = Sidekiq::Stats::Queues.new.lengths
21
+
22
+ queues.each do |queue, size|
23
+ save(
24
+ tags: {queue: queue}.merge(@tags),
25
+ values: {size: size}
26
+ )
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def save(data)
33
+ @influxdb.write_point(@series, data, precision, @retention)
34
+ end
35
+
36
+ def precision
37
+ @influxdb.config.time_precision
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,42 @@
1
+ require 'sidekiq/api'
2
+
3
+ module Sidekiq
4
+ module Metrics
5
+ class Stats
6
+
7
+ def initialize(
8
+ influxdb_client:,
9
+ series_name: 'sidekiq_stats',
10
+ retention_policy: nil,
11
+ tags: {}
12
+ )
13
+ @influxdb = influxdb_client
14
+ @series = series_name
15
+ @retention = retention_policy
16
+ @tags = tags
17
+ end
18
+
19
+ def publish
20
+ stats = Sidekiq::Stats.new.instance_variable_get(:@stats)
21
+ stats.delete(:default_queue_latency)
22
+
23
+ stats.each do |stat, size|
24
+ save(
25
+ tags: {stat: stat}.merge(@tags),
26
+ values: {size: size}
27
+ )
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def save(data)
34
+ @influxdb.write_point(@series, data, precision, @retention)
35
+ end
36
+
37
+ def precision
38
+ @influxdb.config.time_precision
39
+ end
40
+ end
41
+ end
42
+ end
@@ -22,5 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_runtime_dependency "sidekiq"
23
23
 
24
24
  spec.add_development_dependency "rspec"
25
- spec.add_development_dependency "simplecov"
25
+ spec.add_development_dependency "coveralls"
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-influxdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Vassilevsky
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-23 00:00:00.000000000 Z
11
+ date: 2021-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: influxdb
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: simplecov
56
+ name: coveralls
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -73,17 +73,24 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".coveralls.yml"
76
77
  - ".gitignore"
77
78
  - ".rspec"
79
+ - ".ruby-version"
80
+ - ".travis.yml"
78
81
  - CHANGELOG.md
79
82
  - CODE_OF_CONDUCT.md
83
+ - CONTRIBUTING.md
80
84
  - Gemfile
81
85
  - LICENSE
82
86
  - Makefile
83
87
  - README.md
84
88
  - Rakefile
89
+ - grafana_dashboard.json
85
90
  - lib/sidekiq/influxdb.rb
86
91
  - lib/sidekiq/influxdb/version.rb
92
+ - lib/sidekiq/metrics/queues.rb
93
+ - lib/sidekiq/metrics/stats.rb
87
94
  - lib/sidekiq/middleware/server/influxdb.rb
88
95
  - sidekiq-influxdb.gemspec
89
96
  homepage: https://github.com/vassilevsky/sidekiq-influxdb
@@ -104,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
111
  - !ruby/object:Gem::Version
105
112
  version: '0'
106
113
  requirements: []
107
- rubygems_version: 3.0.3
114
+ rubygems_version: 3.2.3
108
115
  signing_key:
109
116
  specification_version: 4
110
117
  summary: Writes Sidekiq job metrics to InfluxDB