prometheus_exporter 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis +9 -0
- data/CHANGELOG +8 -0
- data/lib/prometheus_exporter/client.rb +4 -2
- data/lib/prometheus_exporter/server/collector.rb +3 -2
- data/lib/prometheus_exporter/version.rb +1 -1
- data/lib/prometheus_exporter.rb +31 -0
- data/prometheus_exporter.gemspec +1 -0
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d2f98b4a43ff42569d5b63f603fca9dbc011aba6
|
4
|
+
data.tar.gz: 80f468ac5abf12049e4d58bd981186b7134b5059
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d77695ef60e34eafd2dcbec8d7247eba6610568305a6d0a5a146300ff59f2f7c5776756bcd20562d14743d5354d493dc50e95a9e8f72d4bcdfaac55283bb100
|
7
|
+
data.tar.gz: e8e4c0b5a0ea42b97c2fdd9dd75ba6894a9063a22764c8817488eaa31c6cc0fd627194a3664af067e9de0a5019bfabfe73a9031f81b16742fdceb7ba40f8df27
|
data/.travis
ADDED
data/CHANGELOG
ADDED
@@ -35,7 +35,7 @@ class PrometheusExporter::Client
|
|
35
35
|
MAX_SOCKET_AGE = 25
|
36
36
|
MAX_QUEUE_SIZE = 10_000
|
37
37
|
|
38
|
-
def initialize(host: 'localhost', port: PrometheusExporter::DEFAULT_PORT, max_queue_size: nil, thread_sleep: 0.5)
|
38
|
+
def initialize(host: 'localhost', port: PrometheusExporter::DEFAULT_PORT, max_queue_size: nil, thread_sleep: 0.5, json_serializer: nil)
|
39
39
|
@metrics = []
|
40
40
|
|
41
41
|
@queue = Queue.new
|
@@ -55,6 +55,8 @@ class PrometheusExporter::Client
|
|
55
55
|
@worker_thread = nil
|
56
56
|
@mutex = Mutex.new
|
57
57
|
@thread_sleep = thread_sleep
|
58
|
+
|
59
|
+
@json_serializer = PrometheusExporter.detect_json_serializer(@json_serializer)
|
58
60
|
end
|
59
61
|
|
60
62
|
def register(type, name, help)
|
@@ -64,7 +66,7 @@ class PrometheusExporter::Client
|
|
64
66
|
end
|
65
67
|
|
66
68
|
def send_json(obj)
|
67
|
-
send(obj
|
69
|
+
send(@json_serializer.dump(obj))
|
68
70
|
end
|
69
71
|
|
70
72
|
def send(str)
|
@@ -20,11 +20,12 @@ module PrometheusExporter::Server
|
|
20
20
|
total_allocated_objects: "Total number of allocateds objects by process",
|
21
21
|
}
|
22
22
|
|
23
|
-
def initialize
|
23
|
+
def initialize(json_serializer: nil)
|
24
24
|
@process_metrics = []
|
25
25
|
@metrics = {}
|
26
26
|
@mutex = Mutex.new
|
27
27
|
@collectors = {}
|
28
|
+
@json_serializer = PrometheusExporter.detect_json_serializer(json_serializer)
|
28
29
|
register_collector(WebCollector.new)
|
29
30
|
register_collector(ProcessCollector.new)
|
30
31
|
register_collector(SidekiqCollector.new)
|
@@ -35,7 +36,7 @@ module PrometheusExporter::Server
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def process(str)
|
38
|
-
obj =
|
39
|
+
obj = @json_serializer.parse(str)
|
39
40
|
@mutex.synchronize do
|
40
41
|
if collector = @collectors[obj["type"]]
|
41
42
|
collector.collect(obj)
|
data/lib/prometheus_exporter.rb
CHANGED
@@ -6,4 +6,35 @@ module PrometheusExporter
|
|
6
6
|
# per: https://github.com/prometheus/prometheus/wiki/Default-port-allocations
|
7
7
|
DEFAULT_PORT = 9394
|
8
8
|
DEFAULT_PREFIX = 'ruby_'
|
9
|
+
|
10
|
+
class OjCompat
|
11
|
+
def self.parse(obj)
|
12
|
+
Oj.compat_load(obj)
|
13
|
+
end
|
14
|
+
def self.dump(obj)
|
15
|
+
Oj.dump(obj, mode: :compat)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.detect_json_serializer(preferred)
|
20
|
+
if preferred.nil?
|
21
|
+
preferred = :oj if has_oj?
|
22
|
+
end
|
23
|
+
|
24
|
+
preferred == :oj ? OjCompat : JSON
|
25
|
+
end
|
26
|
+
|
27
|
+
@@has_oj = nil
|
28
|
+
def self.has_oj?
|
29
|
+
(
|
30
|
+
@@has_oj ||=
|
31
|
+
begin
|
32
|
+
require 'oj'
|
33
|
+
:true
|
34
|
+
rescue LoadError
|
35
|
+
:false
|
36
|
+
end
|
37
|
+
) == :true
|
38
|
+
end
|
39
|
+
|
9
40
|
end
|
data/prometheus_exporter.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prometheus_exporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '2.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: oj
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
97
111
|
description: Prometheus metric collector and exporter for Ruby
|
98
112
|
email:
|
99
113
|
- sam.saffron@gmail.com
|
@@ -104,7 +118,9 @@ extra_rdoc_files: []
|
|
104
118
|
files:
|
105
119
|
- ".gitignore"
|
106
120
|
- ".rubocop.yml"
|
121
|
+
- ".travis"
|
107
122
|
- ".travis.yml"
|
123
|
+
- CHANGELOG
|
108
124
|
- CODE_OF_CONDUCT.md
|
109
125
|
- Gemfile
|
110
126
|
- Guardfile
|
@@ -158,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
174
|
version: '0'
|
159
175
|
requirements: []
|
160
176
|
rubyforge_project:
|
161
|
-
rubygems_version: 2.
|
177
|
+
rubygems_version: 2.5.2
|
162
178
|
signing_key:
|
163
179
|
specification_version: 4
|
164
180
|
summary: Prometheus Exporter
|