honeykiq 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +54 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +89 -0
- data/LICENSE.txt +21 -0
- data/README.md +66 -0
- data/Rakefile +6 -0
- data/honeykiq.gemspec +34 -0
- data/lib/honeykiq/periodic_reporter.rb +81 -0
- data/lib/honeykiq/version.rb +3 -0
- data/lib/honeykiq.rb +8 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6fe3d4a4b5312e30b13477915e40534824d4c3822db65051b6e344007d513b04
|
4
|
+
data.tar.gz: 32a1df92ef150b084871b05365699f08c4a40efe92854c72175d1cdd31e5b662
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c589ef0b5bb7dbcc8a93200fc9e06b3d6ab85bde7ef0bc0ea98c15741f9117fed3c000d876b2acebb0502c5d8f17bd60a40362521ae139bfe919a08efe0a1d74
|
7
|
+
data.tar.gz: 645a9554dd0313970a8e78e80f5d207da4ac2300a280f6f3442df811e743d535a236c57928935012fcea6e9476cd4b960583066de0a1212b3eeff752cee466d5
|
@@ -0,0 +1,54 @@
|
|
1
|
+
ruby: &ruby
|
2
|
+
image: carwow/ruby-ci:2.5.3
|
3
|
+
|
4
|
+
version: 2
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
bundle:
|
8
|
+
working_directory: ~/honeykiq
|
9
|
+
docker:
|
10
|
+
- *ruby
|
11
|
+
steps:
|
12
|
+
- checkout
|
13
|
+
- restore_cache:
|
14
|
+
keys:
|
15
|
+
- bundle-{{ checksum "Gemfile.lock" }}
|
16
|
+
- bundle-
|
17
|
+
- run: |
|
18
|
+
bundle config --local path vendor/bundle &&
|
19
|
+
bundle check || bundle install --jobs=4 --retry=3
|
20
|
+
- save_cache:
|
21
|
+
key: bundle-{{ checksum "Gemfile.lock" }}
|
22
|
+
paths: [~/honeykiq/vendor/bundle]
|
23
|
+
- persist_to_workspace:
|
24
|
+
root: '~'
|
25
|
+
paths: [honeykiq]
|
26
|
+
|
27
|
+
rubocop:
|
28
|
+
working_directory: ~/honeykiq
|
29
|
+
docker:
|
30
|
+
- *ruby
|
31
|
+
steps:
|
32
|
+
- attach_workspace:
|
33
|
+
at: '~'
|
34
|
+
- run: bundle exec rubocop
|
35
|
+
|
36
|
+
tests:
|
37
|
+
working_directory: ~/honeykiq
|
38
|
+
docker:
|
39
|
+
- *ruby
|
40
|
+
steps:
|
41
|
+
- attach_workspace:
|
42
|
+
at: '~'
|
43
|
+
- run: |
|
44
|
+
bundle exec rspec
|
45
|
+
|
46
|
+
workflows:
|
47
|
+
version: 2
|
48
|
+
build:
|
49
|
+
jobs:
|
50
|
+
- bundle
|
51
|
+
- rubocop:
|
52
|
+
requires: [bundle]
|
53
|
+
- tests:
|
54
|
+
requires: [bundle]
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
honeykiq (0.1.0)
|
5
|
+
sidekiq
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.5.2)
|
11
|
+
public_suffix (>= 2.0.2, < 4.0)
|
12
|
+
ast (2.4.0)
|
13
|
+
carwow_rubocop (2.1.1)
|
14
|
+
rubocop (~> 0.58)
|
15
|
+
rubocop-rspec (~> 1.28)
|
16
|
+
connection_pool (2.2.2)
|
17
|
+
diff-lcs (1.3)
|
18
|
+
domain_name (0.5.20180417)
|
19
|
+
unf (>= 0.0.5, < 1.0.0)
|
20
|
+
http (3.3.0)
|
21
|
+
addressable (~> 2.3)
|
22
|
+
http-cookie (~> 1.0)
|
23
|
+
http-form_data (~> 2.0)
|
24
|
+
http_parser.rb (~> 0.6.0)
|
25
|
+
http-cookie (1.0.3)
|
26
|
+
domain_name (~> 0.5)
|
27
|
+
http-form_data (2.1.1)
|
28
|
+
http_parser.rb (0.6.0)
|
29
|
+
jaro_winkler (1.5.1)
|
30
|
+
libhoney (1.11.0)
|
31
|
+
addressable (~> 2.0)
|
32
|
+
http (>= 2.0, < 4.0)
|
33
|
+
parallel (1.12.1)
|
34
|
+
parser (2.5.3.0)
|
35
|
+
ast (~> 2.4.0)
|
36
|
+
powerpack (0.1.2)
|
37
|
+
public_suffix (3.0.3)
|
38
|
+
rack (2.0.6)
|
39
|
+
rack-protection (2.0.4)
|
40
|
+
rack
|
41
|
+
rainbow (3.0.0)
|
42
|
+
rake (12.3.2)
|
43
|
+
redis (4.0.3)
|
44
|
+
rspec (3.8.0)
|
45
|
+
rspec-core (~> 3.8.0)
|
46
|
+
rspec-expectations (~> 3.8.0)
|
47
|
+
rspec-mocks (~> 3.8.0)
|
48
|
+
rspec-core (3.8.0)
|
49
|
+
rspec-support (~> 3.8.0)
|
50
|
+
rspec-expectations (3.8.2)
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
+
rspec-support (~> 3.8.0)
|
53
|
+
rspec-mocks (3.8.0)
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
+
rspec-support (~> 3.8.0)
|
56
|
+
rspec-support (3.8.0)
|
57
|
+
rubocop (0.61.1)
|
58
|
+
jaro_winkler (~> 1.5.1)
|
59
|
+
parallel (~> 1.10)
|
60
|
+
parser (>= 2.5, != 2.5.1.1)
|
61
|
+
powerpack (~> 0.1)
|
62
|
+
rainbow (>= 2.2.2, < 4.0)
|
63
|
+
ruby-progressbar (~> 1.7)
|
64
|
+
unicode-display_width (~> 1.4.0)
|
65
|
+
rubocop-rspec (1.30.1)
|
66
|
+
rubocop (>= 0.60.0)
|
67
|
+
ruby-progressbar (1.10.0)
|
68
|
+
sidekiq (5.2.3)
|
69
|
+
connection_pool (~> 2.2, >= 2.2.2)
|
70
|
+
rack-protection (>= 1.5.0)
|
71
|
+
redis (>= 3.3.5, < 5)
|
72
|
+
unf (0.1.4)
|
73
|
+
unf_ext
|
74
|
+
unf_ext (0.0.7.5)
|
75
|
+
unicode-display_width (1.4.0)
|
76
|
+
|
77
|
+
PLATFORMS
|
78
|
+
ruby
|
79
|
+
|
80
|
+
DEPENDENCIES
|
81
|
+
bundler
|
82
|
+
carwow_rubocop
|
83
|
+
honeykiq!
|
84
|
+
libhoney
|
85
|
+
rake
|
86
|
+
rspec
|
87
|
+
|
88
|
+
BUNDLED WITH
|
89
|
+
1.17.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 carwow
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Honeykiq
|
2
|
+
|
3
|
+
Sidekiq → Honeycomb 🐝
|
4
|
+
|
5
|
+
Send Sidekiq related events to Honeycomb.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'honeykiq'
|
13
|
+
```
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
At the moment the library only provides a periodic reporter which should be
|
18
|
+
scheduled to report every few seconds depending on your use case.
|
19
|
+
|
20
|
+
### Periodic Reporter
|
21
|
+
|
22
|
+
The periodic reporter will send one event with information about the sidekiq
|
23
|
+
instance, plus one event per sidekiq process, plus one event per sidekiq queue.
|
24
|
+
Have a look at [periodic_reporter.rb] to see what kind of information we send
|
25
|
+
for each type.
|
26
|
+
|
27
|
+
[periodic_reporter.rb]: https://github.com/carwow/honeykiq/blob/master/lib/honeykiq/periodic_reporter.rb
|
28
|
+
|
29
|
+
A simple setup using [clockwork] would look like this:
|
30
|
+
|
31
|
+
[clockwork]: https://github.com/adamwiggins/clockwork
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require 'clockwork'
|
35
|
+
require 'libhoney'
|
36
|
+
require 'honeykiq'
|
37
|
+
|
38
|
+
module Clockwork
|
39
|
+
every(30, 'Honeykiq', thread: true) { SidekiqHealth.report }
|
40
|
+
end
|
41
|
+
|
42
|
+
module SidekiqHealth
|
43
|
+
def self.report
|
44
|
+
reporter.report
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.reporter
|
48
|
+
@reporter ||= Honeykiq.periodic_reporter(honey_client: honey_client)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.honey_client
|
52
|
+
Libhoney::Client.new(
|
53
|
+
writekey: ENV.fetch('HONEYCOMB_WRITE_KEY'),
|
54
|
+
dataset: ENV.fetch('HONEYCOMB_DATASET')
|
55
|
+
)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/carwow/honeykiq.
|
63
|
+
|
64
|
+
## License
|
65
|
+
|
66
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/honeykiq.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'honeykiq/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'honeykiq'
|
7
|
+
spec.version = Honeykiq::VERSION
|
8
|
+
spec.authors = ['carwow Developers']
|
9
|
+
spec.email = ['developers@carwow.co.uk']
|
10
|
+
spec.summary = 'Sidekiq → Honeycomb 🐝'
|
11
|
+
spec.description = 'Send Sidekiq related events to Honeycomb.'
|
12
|
+
spec.homepage = 'https://github.com/carwow/honeykiq'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
if spec.respond_to?(:metadata)
|
16
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
17
|
+
else
|
18
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
19
|
+
'public gem pushes.'
|
20
|
+
end
|
21
|
+
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.require_paths = ['lib']
|
26
|
+
|
27
|
+
spec.add_dependency 'sidekiq'
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler'
|
30
|
+
spec.add_development_dependency 'carwow_rubocop'
|
31
|
+
spec.add_development_dependency 'libhoney'
|
32
|
+
spec.add_development_dependency 'rake'
|
33
|
+
spec.add_development_dependency 'rspec'
|
34
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'sidekiq/api'
|
2
|
+
|
3
|
+
module Honeykiq
|
4
|
+
class PeriodicReporter
|
5
|
+
def initialize(honey_client:)
|
6
|
+
@honey_client = honey_client
|
7
|
+
@extra = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def report(&extra)
|
11
|
+
send_instance_event(&extra)
|
12
|
+
Sidekiq::ProcessSet.new.each { |process| send_process_event(process, &extra) }
|
13
|
+
Sidekiq::Queue.all.each { |queue| send_queue_event(queue, &extra) }
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_reader :honey_client
|
19
|
+
|
20
|
+
def send_instance_event(&extra)
|
21
|
+
honey_client.event.add(
|
22
|
+
type: :instance,
|
23
|
+
**instance_stats,
|
24
|
+
**redis_stats,
|
25
|
+
**(extra&.call(:instance) || {})
|
26
|
+
).send
|
27
|
+
end
|
28
|
+
|
29
|
+
def instance_stats
|
30
|
+
stats = Sidekiq::Stats.new
|
31
|
+
|
32
|
+
{
|
33
|
+
'instance.processes': stats.processes_size,
|
34
|
+
'instance.busy': stats.workers_size,
|
35
|
+
'instance.enqueued': stats.enqueued,
|
36
|
+
'instance.scheduled': stats.scheduled_size,
|
37
|
+
'instance.retries': stats.retry_size,
|
38
|
+
'instance.dead': stats.dead_size
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def redis_stats
|
43
|
+
redis_info = fetch_redis_info
|
44
|
+
|
45
|
+
{
|
46
|
+
'redis.connections': redis_info['connected_clients'].to_i,
|
47
|
+
'redis.memory_used': redis_info['used_memory'].to_i
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def fetch_redis_info
|
52
|
+
Sidekiq.redis do |redis|
|
53
|
+
redis.pipelined do
|
54
|
+
redis.info :clients
|
55
|
+
redis.info :memory
|
56
|
+
end.reduce(&:merge)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def send_process_event(process, &extra)
|
61
|
+
honey_client.event.add(
|
62
|
+
type: :process,
|
63
|
+
'meta.dyno': process['hostname'],
|
64
|
+
'meta.process_id': process['pid'],
|
65
|
+
'process.concurrency': process['concurrency'],
|
66
|
+
'process.busy': process['busy'],
|
67
|
+
**(extra&.call(:process, process) || {})
|
68
|
+
).send
|
69
|
+
end
|
70
|
+
|
71
|
+
def send_queue_event(queue, &extra)
|
72
|
+
honey_client.event.add(
|
73
|
+
type: :queue,
|
74
|
+
'queue.name': queue.name,
|
75
|
+
'queue.latency_sec': queue.latency.to_f,
|
76
|
+
'queue.size': queue.size,
|
77
|
+
**(extra&.call(:queue, queue) || {})
|
78
|
+
).send
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/honeykiq.rb
ADDED
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: honeykiq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- carwow Developers
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-12-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sidekiq
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: carwow_rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: libhoney
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Send Sidekiq related events to Honeycomb.
|
98
|
+
email:
|
99
|
+
- developers@carwow.co.uk
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".circleci/config.yml"
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".rubocop.yml"
|
108
|
+
- Gemfile
|
109
|
+
- Gemfile.lock
|
110
|
+
- LICENSE.txt
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- honeykiq.gemspec
|
114
|
+
- lib/honeykiq.rb
|
115
|
+
- lib/honeykiq/periodic_reporter.rb
|
116
|
+
- lib/honeykiq/version.rb
|
117
|
+
homepage: https://github.com/carwow/honeykiq
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata:
|
121
|
+
allowed_push_host: https://rubygems.org
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.7.6
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: "Sidekiq → Honeycomb \U0001F41D"
|
142
|
+
test_files: []
|