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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49c574a415d9c6c164b9e0671c6649928bbee2cb5645e52a43ef37b899d13bc3
4
- data.tar.gz: 822b077292371a669291e69944c85d220dfda7c592711e5bc73e252e41b3ee84
3
+ metadata.gz: ab23e225a84eae5cc41b7c74e5590781cdcfddf15390848df761750c15b38f35
4
+ data.tar.gz: 193032ba1f46d910ed9d18c3d60c721513d24a952fe1912cc972fe030dcd9676
5
5
  SHA512:
6
- metadata.gz: 14eb93a948c46817e889f95c0f9899c0046c667408710eac60a9f96b2693da35d8a0724b9d426e5b5f0882b31f498acfefe5944dce9895629c04dc32af0a3466
7
- data.tar.gz: 4ed4f50b3ee95e527d0820cfbbf24f90a44bb51f0ecd652d7159a9a53d7731e1490f8bbd46e0090ca39d723cadbded57f0c2567afc93e7f9700839274e3ce6cd
6
+ metadata.gz: 5b11c5f1c4f989ab529f4d99beec7d60066d656ea59ce7e474939d68de8723e20e7e5ff17ae63d8bb3ba1e74f51703f2f733b2e57fe4b0484badd692f8af8632
7
+ data.tar.gz: 3086862d65a45a60b71d6e0c4ebd358eac472f8a5d463701f26fad879cd1da0def826ee6867c0153a5adbb7d4c8cf4a3f60ad7a2038b252d8e3d01677d8bc7ef
data/CHANGELOG CHANGED
@@ -1,6 +1,11 @@
1
- Unreleased
1
+ 0.3.1
2
2
 
3
- - Follow Prometheus metric [naming conventions](https://prometheus.io/docs/practices/naming/#metric-names)
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.base.default_prefix = "ruby"
333
+ PrometheusExporter::Metric::Base.default_prefix = "ruby"
332
334
 
333
335
  # Specify default labels for metrics
334
- PrometheusExporter::Metric.base.default_labels = { "hostname" => "app-server-01" }
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
 
@@ -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('--prefix METRIC_PREFIX', String, "Prefix to apply to all metrics (default: #{PrometheusExporter::DEFAULT_PREFIX})") do |o|
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(2) do
117
+ Timeout::timeout(@timeout) do
117
118
  metric_text = @collector.prometheus_metrics_text
118
119
  end
119
120
  rescue Timeout::Error
@@ -1,3 +1,3 @@
1
1
  module PrometheusExporter
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -6,6 +6,7 @@ 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
+ DEFAULT_TIMEOUT = 2
9
10
 
10
11
  class OjCompat
11
12
  def self.parse(obj)
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.0
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-05-30 00:00:00.000000000 Z
11
+ date: 2018-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler