sidekiq-opentsdb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +20 -0
- data/CHANGELOG.md +23 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +20 -0
- data/README.md +59 -0
- data/Rakefile +6 -0
- data/VERSION +1 -0
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/lib/sidekiq/opentsdb.rb +12 -0
- data/lib/sidekiq/opentsdb/server_middleware.rb +58 -0
- data/lib/sidekiq/opentsdb/tags.rb +31 -0
- data/lib/sidekiq/opentsdb/version.rb +5 -0
- data/sidekiq-opentsdb.gemspec +23 -0
- metadata +133 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MmIyNzYzZjljYTJhMjdlODUzZGJjYThiMzNiMjU1MTFhZjdmZWVjZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
M2E3YTIwOTJkN2IxMTI5YjMyMWE3NzM2NmQ0MjFhOTY1NzMwZjUyZQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
N2RkYjg3NGFjZTI2NjYzNmM1ZjZmMGU2NTcwYjFkMWU2MjJiNTMyNDcyMmY5
|
10
|
+
MDc4MGMyMmVmZmM2MGFmYTdmODJkZGJhNGMyMDhkMThjOWM0NWQwNzY2NzUy
|
11
|
+
YWZkYjE1ZGJlMGI3MjM0MGNmZmVjMjAwODJlYjUzMDAxMzgzZTk=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YzdjMTc5YTgwZWJmNzYxOTlmNjI1ZjMzZmQwY2RiNDMzZjBmOTI2ZGY1MTM4
|
14
|
+
MDg0MjliYmRmYTY3MGQ2N2FhZGU1NDA2Mzk0ZjIxYzk3ZDk3YzBmNmRiNTQw
|
15
|
+
YTI4ZGI3MjQxZmM0NWEyYmQ1NzkzOTU1MmZjMmNiMGVhMjg1MTg=
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.0
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.3.0
|
4
|
+
- 2.2
|
5
|
+
- 2.1
|
6
|
+
sudo: false
|
7
|
+
cache: bundler
|
8
|
+
script: bundle exec rspec
|
9
|
+
notifications:
|
10
|
+
email: false
|
11
|
+
deploy:
|
12
|
+
provider: rubygems
|
13
|
+
api_key:
|
14
|
+
secure: GRvMGszfopDomvWOWaSVsEpE3ZI8QHykuM8U7RTFQ1/wAwGe5P33sGGw3eciSGYHRB+UgQyxFdJUPz5kp+rYojSD7XvvRwMfNkY3o4LlJpkb5Yi8vf7Htg6tgLflWLXVwM1ekkGXbDFDEZnjsBcgsS/ZPIkXBivbRcTGnd9WESxVK9tvly/htkMmGefYTWISOoSC4NLBuZVD4esFY+G19HdX48Gg8VneIqA0NdMoRgVTltD53fWFtRxzdF+Z1unynvNrQ3ZaI1BgW3It6V+S+Uuwz4tpXQ20fheYoLxA8XG3ER6ay3NxriSgTufFWTeEZWMqoKIBk3HoXTaYEb9Oici0R/IWNQdXMeoz0nPZDlPLWUdPz+MwFJAG0hmIQV9JCalP9rXoe1sOdcGn9o+tfl+E9jXiED8DtWl0++xn79ZpsdIvehzuOSwZWuPBDxMTmQNJX2yGKRgaXGsDqu8Q4d2osvF9wPt+1yKs5eyRWos6alGF+LlLOQ4Gy63nQaS4bBxXQoH1m40Fvgh7N6GNmhi/AckP88Vqfw2gqxSHtrSCPzfhnbXsc0dyqO8SoAKe103q/EyE58W91EmHdhgUNoD9tpZJRxrzFhvo3Oo/C2Q63GtOCRzbig9bzrNrks5ZAIXne45RQ8EOLxnB2jXt/hwAjGLSia9ydGtw3FdXSfk=
|
15
|
+
gem: sidekiq-opentsdb
|
16
|
+
on:
|
17
|
+
branch: master
|
18
|
+
tags: true
|
19
|
+
repo: ninech/sidekiq-opentsdb
|
20
|
+
rvm: 2.3.0
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2016 nine.ch
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Sidekiq::Opentsdb
|
2
|
+
|
3
|
+
[](https://travis-ci.org/ninech/sidekiq-opentsdb)
|
4
|
+
|
5
|
+
Sidekiq middleware that sends useful Sidekiq statistics to OpenTSDB.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'sidekiq-opentsdb'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
You need to add the middleware to your call stack. To do so, put the folllowing code in an initializer (ideally `sidekiq.rb`):
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
Sidekiq.configure_server do |config|
|
25
|
+
config.server_middleware do |chain|
|
26
|
+
middleware_options = {
|
27
|
+
opentsdb_hostname: 'localhost',
|
28
|
+
opentsdb_port: '4242',
|
29
|
+
metric_prefix: 'nine',
|
30
|
+
only: %w(retry_size dead_size)
|
31
|
+
}
|
32
|
+
|
33
|
+
chain.add Sidekiq::Opentsdb::ServerMiddleware, middleware_options
|
34
|
+
end
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
### Available Options
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
opentsdb_hostname: 'localhost' # (required) Hostname of your opentsdb server.
|
42
|
+
opentsdb_port: '4242' # (required) Port of your opentsdb server.
|
43
|
+
|
44
|
+
metric_prefix: 'nine' # (optional) Prefix of the metric keys (default: '').
|
45
|
+
only: %w(retry_size dead_size) # (optional) Only send the given metrics to OpenTSDB.
|
46
|
+
except: %w(retry_size dead_size) # (optional) Send all but the given metrics to OpenTSDB.
|
47
|
+
|
48
|
+
# Tags
|
49
|
+
app: 'MyApp' # (optional) Your app name (Rails app name if available)
|
50
|
+
environment: 'staging' # (optional) Your app environment (default: ENV['RACK_ENV'])
|
51
|
+
```
|
52
|
+
|
53
|
+
## About
|
54
|
+
|
55
|
+
This Gem is maintained and funded by nine.ch.
|
56
|
+
|
57
|
+

|
58
|
+
|
59
|
+
We run your Linux server infrastructure – without interruptions, around the clock.
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'sidekiq/opentsdb'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
require 'pry'
|
10
|
+
Pry.start
|
data/bin/setup
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
module Sidekiq
|
2
|
+
module Opentsdb
|
3
|
+
class ServerMiddleware
|
4
|
+
SIDEKIQ_METRICS = %w(processed failed scheduled_size retry_size dead_size
|
5
|
+
processes_size default_queue_latency workers_size enqueued).freeze
|
6
|
+
|
7
|
+
def initialize(options = {})
|
8
|
+
@options = options
|
9
|
+
|
10
|
+
if !options.key?(:opentsdb_hostname) || !options.key?(:opentsdb_port)
|
11
|
+
fail '[sidekiq-opentsdb] OpenTSDB configuration not found...'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(*)
|
16
|
+
yield
|
17
|
+
|
18
|
+
sidekiq_stats_metrics_with_values.each do |metric, value|
|
19
|
+
opentsdb_client.put metric: "#{metric_prefix}sidekiq.#{metric}", value: value,
|
20
|
+
timestamp: Time.now.to_i, tags: tags
|
21
|
+
end
|
22
|
+
rescue ::OpenTSDB::Errors::UnableToConnectError
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def sidekiq_stats_metrics_with_values
|
28
|
+
sidekiq_stats_instance = Sidekiq::Stats.new
|
29
|
+
selected_metrics.inject({}) do |hash, sidekiq_metric|
|
30
|
+
hash.merge("stats.#{sidekiq_metric}" => sidekiq_stats_instance.send(sidekiq_metric))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def selected_metrics
|
35
|
+
if @options.key?(:only)
|
36
|
+
SIDEKIQ_METRICS.select { |key| @options[:only].include?(key) }
|
37
|
+
elsif @options.key?(:except)
|
38
|
+
SIDEKIQ_METRICS.select { |key| !@options[:except].include?(key) }
|
39
|
+
else
|
40
|
+
SIDEKIQ_METRICS
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def tags
|
45
|
+
Tags.new(@options).to_hash
|
46
|
+
end
|
47
|
+
|
48
|
+
def metric_prefix
|
49
|
+
@options.key?(:metric_prefix) ? "#{@options[:metric_prefix]}." : ''
|
50
|
+
end
|
51
|
+
|
52
|
+
def opentsdb_client
|
53
|
+
@opentsdb_client ||= ::OpenTSDB::Client.new hostname: @options[:opentsdb_hostname],
|
54
|
+
port: @options[:opentsdb_port]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Sidekiq
|
2
|
+
module Opentsdb
|
3
|
+
class Tags
|
4
|
+
def initialize(options = {})
|
5
|
+
@options = options
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_hash
|
9
|
+
{
|
10
|
+
host: Socket.gethostname,
|
11
|
+
environment: environment,
|
12
|
+
app: app,
|
13
|
+
}.delete_if { |k, v| v.nil? }
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def environment
|
19
|
+
@options[:environment] || ENV['RACK_ENV']
|
20
|
+
end
|
21
|
+
|
22
|
+
def app
|
23
|
+
@options[:app] || rails_app_name
|
24
|
+
end
|
25
|
+
|
26
|
+
def rails_app_name
|
27
|
+
::Rails.application.class.parent_name if defined?(::Rails)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'sidekiq-opentsdb'
|
5
|
+
spec.version = File.read(File.expand_path('../VERSION', __FILE__)).strip
|
6
|
+
spec.authors = ['David Dieulivol', 'Philippe Haessig']
|
7
|
+
spec.email = ['dadie@nine.ch', 'phil@nine.ch']
|
8
|
+
|
9
|
+
spec.summary = 'Sidekiq middleware to log useful sidekiq stats to OpenTSDB.'
|
10
|
+
spec.description = 'Sidekiq middleware to log useful sidekiq stats to OpenTSDB.'
|
11
|
+
spec.homepage = 'http://github.com/ninech/sidekiq-opentsdb'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
15
|
+
spec.require_paths = ['lib']
|
16
|
+
|
17
|
+
spec.add_runtime_dependency 'sidekiq', '>= 2.6'
|
18
|
+
spec.add_runtime_dependency 'opentsdb', '~> 1.0'
|
19
|
+
|
20
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
21
|
+
spec.add_development_dependency 'rake', '~> 11.1'
|
22
|
+
spec.add_development_dependency 'pry', '~> 0'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sidekiq-opentsdb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Dieulivol
|
8
|
+
- Philippe Haessig
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-06-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sidekiq
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ! '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '2.6'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ! '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '2.6'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: opentsdb
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '11.1'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '11.1'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: pry
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ~>
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
description: Sidekiq middleware to log useful sidekiq stats to OpenTSDB.
|
85
|
+
email:
|
86
|
+
- dadie@nine.ch
|
87
|
+
- phil@nine.ch
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- .gitignore
|
93
|
+
- .rspec
|
94
|
+
- .ruby-version
|
95
|
+
- .travis.yml
|
96
|
+
- CHANGELOG.md
|
97
|
+
- Gemfile
|
98
|
+
- LICENSE.txt
|
99
|
+
- README.md
|
100
|
+
- Rakefile
|
101
|
+
- VERSION
|
102
|
+
- bin/console
|
103
|
+
- bin/setup
|
104
|
+
- lib/sidekiq/opentsdb.rb
|
105
|
+
- lib/sidekiq/opentsdb/server_middleware.rb
|
106
|
+
- lib/sidekiq/opentsdb/tags.rb
|
107
|
+
- lib/sidekiq/opentsdb/version.rb
|
108
|
+
- sidekiq-opentsdb.gemspec
|
109
|
+
homepage: http://github.com/ninech/sidekiq-opentsdb
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ! '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ! '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 2.4.5
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: Sidekiq middleware to log useful sidekiq stats to OpenTSDB.
|
133
|
+
test_files: []
|