prometheus-client 0.10.0.pre.alpha.1 → 0.10.0.pre.alpha.2

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: 58aea5e1eb91b3b53326f8c183c65187d5fcd6d87fc908c107f73d65257809aa
4
- data.tar.gz: 8d78ea6b70ebc78ed1deba5229b5e2f8b608b11511d8a4278be794dadf945284
3
+ metadata.gz: e96f1eb09651c421cf23add6ac51950a38a76615273028adb445e81dc9b41b70
4
+ data.tar.gz: 7d64d5d5c46e651baf548b7ad37ffdf99e12369d58e4031ed7f6543d4281ca02
5
5
  SHA512:
6
- metadata.gz: 07573f45a2555b063ad4987bd26640bfe7388f98e3f1d11e1b21c65ecf7a853aa372c32326fe944ae656efb9d6837171039ee465712f67dc50513c0f62c0baed
7
- data.tar.gz: ee75b0ad0b4b2664d3d54bb3bcb29f6fe26d4e6b3801c70db37148343c73cc53b769125ad8fb56ad820d24355a2c862fe3e70832961ee7486a2b748357d205cb
6
+ metadata.gz: 9422cab62cef0935c81166448c75e2b60cee2fde06db72c541851d7243604e63fc922da97d0590e8f3b42f24658d9bef9703833fdec896684cae0653e4427a90
7
+ data.tar.gz: 3d0d1a685727206b6813201163c5e2d29bfd5f1757bcb2962b0b753b79088ffcba21dd0735dee7c5eaa4e27494261e8ff20696c111a585f1926ebad4c80167ac
data/README.md CHANGED
@@ -168,8 +168,8 @@ summary.observe(Benchmark.realtime { service.call() }, labels: { service: 'datab
168
168
 
169
169
  # retrieve the current sum and total values
170
170
  summary_value = summary.get(labels: { service: 'database' })
171
- summary_value.sum # => 123.45
172
- summary_value.count # => 100
171
+ summary_value['sum'] # => 123.45
172
+ summary_value['count'] # => 100
173
173
  ```
174
174
 
175
175
  ## Labels
@@ -256,6 +256,15 @@ class MyComponent
256
256
  end
257
257
  ```
258
258
 
259
+ ### Reserved labels
260
+
261
+ The following labels are reserved by the client library, and attempting to use them in a
262
+ metric definition will result in a
263
+ `Prometheus::Client::LabelSetValidator::ReservedLabelError` being raised:
264
+
265
+ - `:job`
266
+ - `:instance`
267
+ - `:pid`
259
268
 
260
269
  ## Data Stores
261
270
 
@@ -362,7 +371,8 @@ summing the values of each process.
362
371
 
363
372
  For Gauges, however, this may not be the right thing to do, depending on what they're
364
373
  measuring. You might want to take the maximum or minimum value observed in any process,
365
- rather than the sum of all of them.
374
+ rather than the sum of all of them. You may also want to export each process's individual
375
+ value.
366
376
 
367
377
  In those cases, you should use the `store_settings` parameter when registering the
368
378
  metric, to specify an `:aggregation` setting.
@@ -1,4 +1,3 @@
1
- require 'concurrent'
2
1
  require 'fileutils'
3
2
  require "cgi"
4
3
 
@@ -26,8 +25,9 @@ module Prometheus
26
25
 
27
26
  class DirectFileStore
28
27
  class InvalidStoreSettingsError < StandardError; end
29
- AGGREGATION_MODES = [MAX = :max, MIN = :min, SUM = :sum]
28
+ AGGREGATION_MODES = [MAX = :max, MIN = :min, SUM = :sum, ALL = :all]
30
29
  DEFAULT_METRIC_SETTINGS = { aggregation: SUM }
30
+ DEFAULT_GAUGE_SETTINGS = { aggregation: ALL }
31
31
 
32
32
  def initialize(dir:)
33
33
  @store_settings = { dir: dir }
@@ -35,7 +35,12 @@ module Prometheus
35
35
  end
36
36
 
37
37
  def for_metric(metric_name, metric_type:, metric_settings: {})
38
- settings = DEFAULT_METRIC_SETTINGS.merge(metric_settings)
38
+ default_settings = DEFAULT_METRIC_SETTINGS
39
+ if metric_type == :gauge
40
+ default_settings = DEFAULT_GAUGE_SETTINGS
41
+ end
42
+
43
+ settings = default_settings.merge(metric_settings)
39
44
  validate_metric_settings(settings)
40
45
 
41
46
  MetricStore.new(metric_name: metric_name,
@@ -66,7 +71,7 @@ module Prometheus
66
71
  @store_settings = store_settings
67
72
  @values_aggregation_mode = metric_settings[:aggregation]
68
73
 
69
- @rwlock = Concurrent::ReentrantReadWriteLock.new
74
+ @lock = Monitor.new
70
75
  end
71
76
 
72
77
  # Synchronize is used to do a multi-process Mutex, when incrementing multiple
@@ -136,10 +141,14 @@ module Prometheus
136
141
  private
137
142
 
138
143
  def in_process_sync
139
- @rwlock.with_write_lock { yield }
144
+ @lock.synchronize { yield }
140
145
  end
141
146
 
142
147
  def store_key(labels)
148
+ if @values_aggregation_mode == ALL
149
+ labels[:pid] = process_id
150
+ end
151
+
143
152
  labels.map{|k,v| "#{CGI::escape(k.to_s)}=#{CGI::escape(v.to_s)}"}.join('&')
144
153
  end
145
154
 
@@ -168,6 +177,8 @@ module Prometheus
168
177
  values.max
169
178
  elsif @values_aggregation_mode == MIN
170
179
  values.min
180
+ elsif @values_aggregation_mode == ALL
181
+ values.first
171
182
  else
172
183
  raise InvalidStoreSettingsError,
173
184
  "Invalid Aggregation Mode: #{ @values_aggregation_mode }"
@@ -1,5 +1,3 @@
1
- require 'concurrent'
2
-
3
1
  module Prometheus
4
2
  module Client
5
3
  module DataStores
@@ -1,5 +1,3 @@
1
- require 'concurrent'
2
-
3
1
  module Prometheus
4
2
  module Client
5
3
  module DataStores
@@ -27,11 +25,11 @@ module Prometheus
27
25
  class MetricStore
28
26
  def initialize
29
27
  @internal_store = Hash.new { |hash, key| hash[key] = 0.0 }
30
- @rwlock = Concurrent::ReentrantReadWriteLock.new
28
+ @lock = Monitor.new
31
29
  end
32
30
 
33
31
  def synchronize
34
- @rwlock.with_write_lock { yield }
32
+ @lock.synchronize { yield }
35
33
  end
36
34
 
37
35
  def set(labels:, val:)
@@ -6,7 +6,7 @@ module Prometheus
6
6
  # Prometheus specification.
7
7
  class LabelSetValidator
8
8
  # TODO: we might allow setting :instance in the future
9
- BASE_RESERVED_LABELS = [:job, :instance].freeze
9
+ BASE_RESERVED_LABELS = [:job, :instance, :pid].freeze
10
10
 
11
11
  class LabelSetError < StandardError; end
12
12
  class InvalidLabelSetError < LabelSetError; end
@@ -42,7 +42,7 @@ module Prometheus
42
42
  docstring: docstring,
43
43
  labels: labels,
44
44
  preset_labels: preset_labels,
45
- store_settings: {}))
45
+ store_settings: store_settings))
46
46
  end
47
47
 
48
48
  def summary(name, docstring:, labels: [], preset_labels: {}, store_settings: {})
@@ -50,7 +50,7 @@ module Prometheus
50
50
  docstring: docstring,
51
51
  labels: labels,
52
52
  preset_labels: preset_labels,
53
- store_settings: {}))
53
+ store_settings: store_settings))
54
54
  end
55
55
 
56
56
  def gauge(name, docstring:, labels: [], preset_labels: {}, store_settings: {})
@@ -58,7 +58,7 @@ module Prometheus
58
58
  docstring: docstring,
59
59
  labels: labels,
60
60
  preset_labels: preset_labels,
61
- store_settings: {}))
61
+ store_settings: store_settings))
62
62
  end
63
63
 
64
64
  def histogram(name, docstring:, labels: [], preset_labels: {},
@@ -69,7 +69,7 @@ module Prometheus
69
69
  labels: labels,
70
70
  preset_labels: preset_labels,
71
71
  buckets: buckets,
72
- store_settings: {}))
72
+ store_settings: store_settings))
73
73
  end
74
74
 
75
75
  def exist?(name)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Prometheus
4
4
  module Client
5
- VERSION = '0.10.0-alpha.1'
5
+ VERSION = '0.10.0-alpha.2'
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: 0.10.0.pre.alpha.1
4
+ version: 0.10.0.pre.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Kochie
@@ -10,16 +10,16 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-05-23 00:00:00.000000000 Z
13
+ date: 2019-06-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: concurrent-ruby
16
+ name: benchmark-ips
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
- type: :runtime
22
+ type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
@@ -27,7 +27,7 @@ dependencies:
27
27
  - !ruby/object:Gem::Version
28
28
  version: '0'
29
29
  - !ruby/object:Gem::Dependency
30
- name: benchmark-ips
30
+ name: concurrent-ruby
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - ">="