prometheus_exporter 0.1.4 → 0.1.5
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 +4 -4
- data/README.md +6 -4
- data/bench/bench.rb +11 -5
- data/lib/prometheus_exporter/client.rb +0 -1
- data/lib/prometheus_exporter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d17c6718584f3b92aadf8cbfed5cd2b592df3f2407d19bd6575e0ce4efd6a735
|
4
|
+
data.tar.gz: f0cb1972defe21ee5b6ee3fd403fd6b20074f928ca5637f6c03128ecaa882eb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2a5351286014650a71dbec6f723a8373647c54dd2fd6b9f707746468f4023fdb809893ea225ea72c81c2816fc26b5014b4db42c6c98253e8c2261e518d9ca49
|
7
|
+
data.tar.gz: c370dfcff273a85a8706429578e7f85e42930562ccf14eea8820df5858bf3f34ccd1bbb6376248491fe93f102460def7b4d89fb9c1388bf8abccc61e2fd193e7
|
data/README.md
CHANGED
@@ -115,7 +115,8 @@ class MyCustomCollector < PrometheusExporter::Server::Collector
|
|
115
115
|
@mutex = Mutex.new
|
116
116
|
end
|
117
117
|
|
118
|
-
def process(
|
118
|
+
def process(str)
|
119
|
+
obj = JSON.parse(str)
|
119
120
|
@mutex.synchronize do
|
120
121
|
if thing1 = obj["thing1"]
|
121
122
|
@gauge1.observe(thing1)
|
@@ -147,8 +148,8 @@ In your application ship it the metrics you want:
|
|
147
148
|
require 'prometheus_exporter/client'
|
148
149
|
|
149
150
|
client = PrometheusExporter::Client.new(host: 'localhost', port: 12345)
|
150
|
-
client.
|
151
|
-
client.
|
151
|
+
client.send_json(thing1: 122)
|
152
|
+
client.send_json(thing2: 12)
|
152
153
|
```
|
153
154
|
|
154
155
|
Now your exporter will echo the metrics:
|
@@ -173,7 +174,8 @@ thing2 12
|
|
173
174
|
|
174
175
|
Prometheus Exporter handles transport using a simple HTTP protocol. In multi process mode we avoid needing a large number of HTTP request by using chunked encoding to send metrics. This means that a single HTTP channel can deliver 100s or even 1000s of metrics over a single HTTP session to the `/send-metrics` endpoint.
|
175
176
|
|
176
|
-
|
177
|
+
The `/bench` directory has simple benchmark it is able to send through 10k messages in 500ms.
|
178
|
+
|
177
179
|
|
178
180
|
## Contributing
|
179
181
|
|
data/bench/bench.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require_relative '../lib/prometheus_exporter'
|
2
2
|
require_relative '../lib/prometheus_exporter/client'
|
3
3
|
require_relative '../lib/prometheus_exporter/server'
|
4
|
-
require 'oj'
|
5
4
|
|
6
5
|
# test how long it takes a custom collector to process 10k messages
|
7
6
|
|
@@ -13,8 +12,8 @@ class Collector
|
|
13
12
|
|
14
13
|
def process(message)
|
15
14
|
_parsed = JSON.parse(message)
|
16
|
-
|
17
|
-
@done.call if
|
15
|
+
@i += 1
|
16
|
+
@done.call if @i % 10_000 == 0
|
18
17
|
end
|
19
18
|
|
20
19
|
def prometheus_metrics_text
|
@@ -22,16 +21,23 @@ class Collector
|
|
22
21
|
end
|
23
22
|
|
24
23
|
@start = nil
|
24
|
+
@client = nil
|
25
|
+
@runs = 1000
|
26
|
+
|
25
27
|
done = lambda do
|
26
28
|
puts "Elapsed for 10k messages is #{Time.now - @start}"
|
29
|
+
if (@runs -= 1) > 0
|
30
|
+
@start = Time.now
|
31
|
+
10_000.times { @client.send_json(hello: "world") }
|
32
|
+
end
|
27
33
|
end
|
28
34
|
|
29
35
|
collector = Collector.new(done)
|
30
36
|
server = PrometheusExporter::Server::WebServer.new port: 12349, collector: collector
|
31
37
|
server.start
|
32
|
-
client = PrometheusExporter::Client.new port: 12349, max_queue_size:
|
38
|
+
@client = PrometheusExporter::Client.new port: 12349, max_queue_size: 100_000
|
33
39
|
|
34
40
|
@start = Time.now
|
35
|
-
10_000.times { client.send_json(hello: "world") }
|
41
|
+
10_000.times { @client.send_json(hello: "world") }
|
36
42
|
|
37
43
|
sleep
|