prometheus_exporter 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +7 -2
- data/README.md +4 -2
- data/bin/prometheus_exporter +7 -1
- data/lib/prometheus_exporter/server/runner.rb +9 -1
- data/lib/prometheus_exporter/server/web_server.rb +3 -2
- data/lib/prometheus_exporter/version.rb +1 -1
- data/lib/prometheus_exporter.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab23e225a84eae5cc41b7c74e5590781cdcfddf15390848df761750c15b38f35
|
4
|
+
data.tar.gz: 193032ba1f46d910ed9d18c3d60c721513d24a952fe1912cc972fe030dcd9676
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b11c5f1c4f989ab529f4d99beec7d60066d656ea59ce7e474939d68de8723e20e7e5ff17ae63d8bb3ba1e74f51703f2f733b2e57fe4b0484badd692f8af8632
|
7
|
+
data.tar.gz: 3086862d65a45a60b71d6e0c4ebd358eac472f8a5d463701f26fad879cd1da0def826ee6867c0153a5adbb7d4c8cf4a3f60ad7a2038b252d8e3d01677d8bc7ef
|
data/CHANGELOG
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
|
1
|
+
0.3.1
|
2
2
|
|
3
|
-
-
|
3
|
+
- Allow runner to accept a --timeout var
|
4
|
+
- Allow runner to accept a blank prefix
|
5
|
+
|
6
|
+
0.3.0
|
7
|
+
|
8
|
+
- Breaking change: Follow Prometheus metric [naming conventions](https://prometheus.io/docs/practices/naming/#metric-names)
|
4
9
|
|
5
10
|
0.1.15 - 2018-02-19
|
6
11
|
|
data/README.md
CHANGED
@@ -324,14 +324,16 @@ thing2 12
|
|
324
324
|
|
325
325
|
### Metrics default prefix / labels
|
326
326
|
|
327
|
+
_This only works in single process mode_
|
328
|
+
|
327
329
|
You can specify default prefix or labels for metrics, for example:
|
328
330
|
|
329
331
|
```ruby
|
330
332
|
# Specify prefix for metric names
|
331
|
-
PrometheusExporter::Metric.
|
333
|
+
PrometheusExporter::Metric::Base.default_prefix = "ruby"
|
332
334
|
|
333
335
|
# Specify default labels for metrics
|
334
|
-
PrometheusExporter::Metric.
|
336
|
+
PrometheusExporter::Metric::Base.default_labels = { "hostname" => "app-server-01" }
|
335
337
|
|
336
338
|
counter = PrometheusExporter::Metric::Counter.new("web_requests", "number of web requests")
|
337
339
|
|
data/bin/prometheus_exporter
CHANGED
@@ -18,7 +18,13 @@ def run
|
|
18
18
|
"Port exporter should listen on (default: #{PrometheusExporter::DEFAULT_PORT})") do |o|
|
19
19
|
options[:port] = o.to_i
|
20
20
|
end
|
21
|
-
opt.on('
|
21
|
+
opt.on('-t',
|
22
|
+
'--timeout INTEGER',
|
23
|
+
Integer,
|
24
|
+
"Timeout in seconds for metrics endpoint (default: #{PrometheusExporter::DEFAULT_TIMEOUT})") do |o|
|
25
|
+
options[:timeout] = o.to_i
|
26
|
+
end
|
27
|
+
opt.on('--prefix METRIC_PREFIX', "Prefix to apply to all metrics (default: #{PrometheusExporter::DEFAULT_PREFIX})") do |o|
|
22
28
|
options[:prefix] = o.to_s
|
23
29
|
end
|
24
30
|
opt.on('-c', '--collector FILE', String, "(optional) Custom collector to run") do |o|
|
@@ -20,7 +20,7 @@ module PrometheusExporter::Server
|
|
20
20
|
raise WrongInheritance, 'Collector class must be inherited from PrometheusExporter::Server::CollectorBase'
|
21
21
|
end
|
22
22
|
|
23
|
-
server = server_class.new port: port, collector: collector, verbose: verbose
|
23
|
+
server = server_class.new port: port, collector: collector, timeout: timeout, verbose: verbose
|
24
24
|
server.start
|
25
25
|
end
|
26
26
|
|
@@ -56,6 +56,14 @@ module PrometheusExporter::Server
|
|
56
56
|
@type_collectors || []
|
57
57
|
end
|
58
58
|
|
59
|
+
def timeout=(timeout)
|
60
|
+
@timeout = timeout
|
61
|
+
end
|
62
|
+
|
63
|
+
def timeout
|
64
|
+
@timeout || PrometheusExporter::DEFAULT_TIMEOUT
|
65
|
+
end
|
66
|
+
|
59
67
|
def verbose=(verbose)
|
60
68
|
@verbose = verbose
|
61
69
|
end
|
@@ -9,7 +9,7 @@ module PrometheusExporter::Server
|
|
9
9
|
class WebServer
|
10
10
|
attr_reader :collector
|
11
11
|
|
12
|
-
def initialize(port: , collector: nil, verbose: false)
|
12
|
+
def initialize(port: , collector: nil, timeout: PrometheusExporter::DEFAULT_TIMEOUT, verbose: false)
|
13
13
|
|
14
14
|
@verbose = verbose
|
15
15
|
|
@@ -44,6 +44,7 @@ module PrometheusExporter::Server
|
|
44
44
|
|
45
45
|
@collector = collector || Collector.new
|
46
46
|
@port = port
|
47
|
+
@timeout = timeout
|
47
48
|
|
48
49
|
@server.mount_proc '/' do |req, res|
|
49
50
|
res['ContentType'] = 'text/plain; charset=utf-8'
|
@@ -113,7 +114,7 @@ module PrometheusExporter::Server
|
|
113
114
|
def metrics
|
114
115
|
metric_text = nil
|
115
116
|
begin
|
116
|
-
Timeout::timeout(
|
117
|
+
Timeout::timeout(@timeout) do
|
117
118
|
metric_text = @collector.prometheus_metrics_text
|
118
119
|
end
|
119
120
|
rescue Timeout::Error
|
data/lib/prometheus_exporter.rb
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.3.
|
4
|
+
version: 0.3.1
|
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-
|
11
|
+
date: 2018-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|