prometheus-client 1.0.0 → 2.0.0

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: edc489cbe60b73d291c523b070bd74d361cf28e7c57193865bc8d8d88f8780ef
4
- data.tar.gz: ec17c3fb9999a4ed475bfbfe3da3f931f0e66f319c9733ee787ddc40229e9059
3
+ metadata.gz: 2a751a9f1859db76b453a64f74ae033ad6e197ccdd5e868fa72a267f074ea6cb
4
+ data.tar.gz: 5f68748f976f3c1ce975f950d352c4d015fa021bd1fc93e3dd337cff19bd8d7f
5
5
  SHA512:
6
- metadata.gz: d1df07ee9b21d8596bfd191f0d4203cc5dddbcab8ea13ba0d7cf04e7a8708ed622488eb3fb70713abeea0555eecebe3380d1b14b2199b2b056f8cdea1d93ddac
7
- data.tar.gz: 4d219fd0b8a5bec670597b3650c4a1be45bb635f83d8a03f6b659ef5ab44e85dcd19a9a977ac6839fbd922dba813a8653a542db9dbaf13c110ec4beedb33a129
6
+ metadata.gz: beb6e41e1a0fb2a269977646022a1ff055c17087a9736732f53df8ee6dedf3e14257c32584f756980148aeea0cc00635fc5d40c2730ef90b1a39dc5755c9798e
7
+ data.tar.gz: 34c04abc96d1059ff55a4284e33d5a621ec9f76a12325c41ec92ef7650d3deb5ed91bc19eb55124cae54ed904c48779196fc34577a72ed28e24778b07f88c99a
data/README.md CHANGED
@@ -10,6 +10,13 @@ through a HTTP interface. Intended to be used together with a
10
10
 
11
11
  ## Usage
12
12
 
13
+ ### Installation
14
+
15
+ For a global installation run `gem install prometheus-client`.
16
+
17
+ If you're using [Bundler](https://bundler.io/) add `gem "prometheus-client"` to your `Gemfile`.
18
+ Make sure to run `bundle install` afterwards.
19
+
13
20
  ### Overview
14
21
 
15
22
  ```ruby
@@ -254,6 +261,12 @@ class MyComponent
254
261
  end
255
262
  ```
256
263
 
264
+ ### `init_label_set`
265
+
266
+ The time series of a metric are not initialized until something happens. For counters, for example, this means that the time series do not exist until the counter is incremented for the first time.
267
+
268
+ To get around this problem the client provides the `init_label_set` method that can be used to initialise the time series of a metric for a given label set.
269
+
257
270
  ### Reserved labels
258
271
 
259
272
  The following labels are reserved by the client library, and attempting to use them in a
@@ -187,7 +187,7 @@ has created a good amount of research, benchmarks, and experimental stores, whic
187
187
  weren't useful to include in this repo, but may be a useful resource or starting point
188
188
  if you are building your own store.
189
189
 
190
- Check out the [GoCardless Data Stores Experiments](gocardless/prometheus-client-ruby-data-stores-experiments)
190
+ Check out the [GoCardless Data Stores Experiments](https://github.com/gocardless/prometheus-client-ruby-data-stores-experiments)
191
191
  repository for these.
192
192
 
193
193
  ## Sample, imaginary multi-process Data Store
@@ -47,7 +47,7 @@ module Prometheus
47
47
  end
48
48
 
49
49
  def observe(value, labels: {})
50
- bucket = buckets.find {|upper_limit| upper_limit > value }
50
+ bucket = buckets.find {|upper_limit| upper_limit >= value }
51
51
  bucket = "+Inf" if bucket.nil?
52
52
 
53
53
  base_label_set = label_set_for(labels)
@@ -94,6 +94,16 @@ module Prometheus
94
94
  end
95
95
  end
96
96
 
97
+ def init_label_set(labels)
98
+ base_label_set = label_set_for(labels)
99
+
100
+ @store.synchronize do
101
+ (buckets + ["+Inf", "sum"]).each do |bucket|
102
+ @store.set(labels: base_label_set.merge(le: bucket.to_s), val: 0)
103
+ end
104
+ end
105
+ end
106
+
97
107
  private
98
108
 
99
109
  # Modifies the passed in parameter
@@ -55,6 +55,10 @@ module Prometheus
55
55
  store_settings: @store_settings)
56
56
  end
57
57
 
58
+ def init_label_set(labels)
59
+ @store.set(labels: label_set_for(labels), val: 0)
60
+ end
61
+
58
62
  # Returns all label sets with their values
59
63
  def values
60
64
  @store.all_values
@@ -45,6 +45,15 @@ module Prometheus
45
45
  end
46
46
  end
47
47
 
48
+ def init_label_set(labels)
49
+ base_label_set = label_set_for(labels)
50
+
51
+ @store.synchronize do
52
+ @store.set(labels: base_label_set.merge(quantile: "count"), val: 0)
53
+ @store.set(labels: base_label_set.merge(quantile: "sum"), val: 0)
54
+ end
55
+ end
56
+
48
57
  private
49
58
 
50
59
  def reserved_labels
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Prometheus
4
4
  module Client
5
- VERSION = '1.0.0'
5
+ VERSION = '2.0.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prometheus-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Kochie
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-11-04 00:00:00.000000000 Z
13
+ date: 2020-01-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: benchmark-ips