prometheus-client 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDk0MDcwZDZiNTAzOWQ4M2M1ZTQ3MzI0MzVmYTU4OThkMTc4MWFhZg==
4
+ YWQ3NGY0YTg3OGJjMzdlNGQ2YjczNDcxNjdiZTQ1MDMxYzg2YzE5Yw==
5
5
  data.tar.gz: !binary |-
6
- NDI0OThmMTY0ZDMzNGY3N2UzMTExODRjOWEwNDc3ZWEzMzZmNmNlZA==
6
+ NzNiODVjNWMwMzRhOTJhYzljNmFiMGI2YzQ5ZWZmODI0MWUxZWYyYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTE3ZGQ1ZjIyYWFlZTJiNzQ2MWFjY2Y5ZTZlMTA0NWJkMmZkNWRkYzAwZDM0
10
- NWVlYzQ2YjgyMDUxZDIyZDBkMmY4N2EzZWEwZDc5NmQ5Zjc2M2M1MzAyZjg3
11
- YzRhMzQyMTYwMWYzM2Q3YzJkMzExYWRmYmEwZjI0NjM3YmU2Mjk=
9
+ NWE1YTIxZjliZTZmZTI5ZmJmM2QyNDQyYmE0OWIyNzg3MTZhNGE3YzI4ZTA4
10
+ M2IyOTAxNDUwZDU5NWI0MjczYzUyNTI2YjQzZWExNThjNTU5MzM4ZDQ2MjBj
11
+ NWM2OGY5YjNhZDZhMjgzYTZlYzVmYTAyNWU5ODdmZmRiZTQwZjM=
12
12
  data.tar.gz: !binary |-
13
- YTFjMzU5NDA3N2VjMTM4Y2Q4MDZiOGM3MTU1YWYwZmI0YTY0MjQxMTUyNDg5
14
- NGJjMTQyZGFkNDQ5NmE3NzE3NWYyYzAzODMwMzNiOThjMzBlZTA5N2U2ZWI0
15
- OTA5M2MwMjcwMzI1ZWU2Y2MyMTk4ZDExY2I2NmU4OTY2ZjU5YWE=
13
+ MTYxMGE5ZGNkYWNlYWNhNDU4YmY4ODIxYzVjZGM1NmVkMTUxZDBjZGYzOTA1
14
+ YzNmMzkxMTM2Zjc1ZTgzYTIzNjY1N2NkZDgxNzhjZjljMzQwZWJmZTM4ODAw
15
+ Njc1M2M0NWZiMGMwYTkyZmYzOGNmZjY0YWYyMGMwOGZmNGY1Yzk=
data/README.md CHANGED
@@ -71,11 +71,15 @@ prometheus = Prometheus::Client.registry
71
71
  # ... register some metrics, set/add/increment/etc. their values
72
72
 
73
73
  # push the registry state to the default gateway
74
- Prometheus::Client::Push.new('my-batch-job').push(prometheus)
74
+ Prometheus::Client::Push.new('my-batch-job').add(prometheus)
75
75
 
76
76
  # optional: specify the instance name (instead of IP) and gateway
77
77
  Prometheus::Client::Push.new(
78
- 'my-job', 'instance-name', 'http://example.domain:1234').push(prometheus)
78
+ 'my-job', 'instance-name', 'http://example.domain:1234').add(prometheus)
79
+
80
+ # If you want to replace any previously pushed metrics for a given instance,
81
+ # use the #replace method.
82
+ Prometheus::Client::Push.new('my-batch-job', 'instance').replace(prometheus)
79
83
  ```
80
84
 
81
85
  ## Metrics
@@ -24,13 +24,19 @@ module Prometheus
24
24
 
25
25
  @uri = parse(@gateway)
26
26
  @path = build_path(job, instance)
27
+ @http = Net::HTTP.new(@uri.host, @uri.port)
27
28
  end
28
29
 
29
- def push(registry)
30
+ def add(registry)
30
31
  data = Formats::Text.marshal(registry)
31
- http = Net::HTTP.new(@uri.host, @uri.port)
32
32
 
33
- http.send_request('PUT', path, data, HEADER)
33
+ @http.send_request('PUT', path, data, HEADER)
34
+ end
35
+
36
+ def replace(registry)
37
+ @http.send_request('DELETE', path)
38
+
39
+ add(registry)
34
40
  end
35
41
 
36
42
  private
@@ -33,20 +33,20 @@ module Prometheus
33
33
  def init_request_metrics
34
34
  @requests = @registry.counter(
35
35
  :http_requests_total,
36
- 'A counter of the total number of HTTP requests made.',)
36
+ 'A counter of the total number of HTTP requests made.')
37
37
  @requests_duration = @registry.counter(
38
38
  :http_request_durations_total_microseconds,
39
39
  'The total amount of time spent answering HTTP requests ' \
40
40
  '(microseconds).',)
41
41
  @durations = @registry.summary(
42
42
  :http_request_durations_microseconds,
43
- 'A histogram of the response latency (microseconds).',)
43
+ 'A histogram of the response latency (microseconds).')
44
44
  end
45
45
 
46
46
  def init_exception_metrics
47
47
  @exceptions = @registry.counter(
48
48
  :http_exceptions_total,
49
- 'A counter of the total number of exceptions raised.',)
49
+ 'A counter of the total number of exceptions raised.')
50
50
  end
51
51
 
52
52
  def trace(env)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Prometheus
4
4
  module Client
5
- VERSION = '0.3.1'
5
+ VERSION = '0.4.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prometheus-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Schmidt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-24 00:00:00.000000000 Z
11
+ date: 2014-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: quantile