prometheus-client 0.10.0.pre.alpha.2 → 0.10.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: e96f1eb09651c421cf23add6ac51950a38a76615273028adb445e81dc9b41b70
4
- data.tar.gz: 7d64d5d5c46e651baf548b7ad37ffdf99e12369d58e4031ed7f6543d4281ca02
3
+ metadata.gz: be821ad9a35fc316970961619d14342baa8166ff6143e21e30e527e0dc1bd325
4
+ data.tar.gz: bf6583e5e6b45cc96ffa9424abe5707e3f17ba5782ba6e42c89a994e8233a0f6
5
5
  SHA512:
6
- metadata.gz: 9422cab62cef0935c81166448c75e2b60cee2fde06db72c541851d7243604e63fc922da97d0590e8f3b42f24658d9bef9703833fdec896684cae0653e4427a90
7
- data.tar.gz: 3d0d1a685727206b6813201163c5e2d29bfd5f1757bcb2962b0b753b79088ffcba21dd0735dee7c5eaa4e27494261e8ff20696c111a585f1926ebad4c80167ac
6
+ metadata.gz: ff408a86bebf88bc757850dc69c3faf9b56dc8d556f0c837d350496ee37810390e5cf6f0b319785e3c9a79968f67467b1fd2a5213c07468a907bd5eae907363c
7
+ data.tar.gz: df5a509d431e8d7a9ca03f984400cfd3d0705d3322f9f2a336653f6956a828135b75efb99aa3817398c1f559bf4722d2580a5608b598f1d8312b24d97d18098c
@@ -133,7 +133,8 @@ module Prometheus
133
133
  end
134
134
 
135
135
  # Aggregate all the different values for each label_set
136
- stores_data.each_with_object({}) do |(label_set, values), acc|
136
+ aggregate_hash = Hash.new { |hash, key| hash[key] = 0.0 }
137
+ stores_data.each_with_object(aggregate_hash) do |(label_set, values), acc|
137
138
  acc[label_set] = aggregate_values(values)
138
139
  end
139
140
  end
@@ -153,7 +154,12 @@ module Prometheus
153
154
  end
154
155
 
155
156
  def internal_store
156
- @internal_store ||= FileMappedDict.new(filemap_filename)
157
+ if @store_opened_by_pid != process_id
158
+ @store_opened_by_pid = process_id
159
+ @internal_store = FileMappedDict.new(filemap_filename)
160
+ else
161
+ @internal_store
162
+ end
157
163
  end
158
164
 
159
165
  # Filename for this metric's PStore (one per process)
@@ -18,7 +18,6 @@ module Prometheus
18
18
  def initialize(expected_labels:, reserved_labels: [])
19
19
  @expected_labels = expected_labels.sort
20
20
  @reserved_labels = BASE_RESERVED_LABELS + reserved_labels
21
- @validated = {}
22
21
  end
23
22
 
24
23
  def validate_symbols!(labels)
@@ -34,17 +33,17 @@ module Prometheus
34
33
  end
35
34
 
36
35
  def validate_labelset!(labelset)
37
- return labelset if @validated.key?(labelset.hash)
38
-
39
- validate_symbols!(labelset)
40
-
41
- unless keys_match?(labelset)
42
- raise InvalidLabelSetError, "labels must have the same signature " \
43
- "(keys given: #{labelset.keys.sort} vs." \
44
- " keys expected: #{expected_labels}"
36
+ begin
37
+ return labelset if keys_match?(labelset)
38
+ rescue ArgumentError
39
+ # If labelset contains keys that are a mixture of strings and symbols, this will
40
+ # raise when trying to sort them, but the error should be the same:
41
+ # InvalidLabelSetError
45
42
  end
46
43
 
47
- @validated[labelset.hash] = labelset
44
+ raise InvalidLabelSetError, "labels must have the same signature " \
45
+ "(keys given: #{labelset.keys} vs." \
46
+ " keys expected: #{expected_labels}"
48
47
  end
49
48
 
50
49
  private
@@ -27,7 +27,7 @@ module Prometheus
27
27
 
28
28
  @name = name
29
29
  @docstring = docstring
30
- @preset_labels = preset_labels
30
+ @preset_labels = stringify_values(preset_labels)
31
31
 
32
32
  @store = Prometheus::Client.config.data_store.for_metric(
33
33
  name,
@@ -85,8 +85,16 @@ module Prometheus
85
85
  def label_set_for(labels)
86
86
  # We've already validated, and there's nothing to merge. Save some cycles
87
87
  return preset_labels if @all_labels_preset && labels.empty?
88
+ labels = stringify_values(labels)
88
89
  @validator.validate_labelset!(preset_labels.merge(labels))
89
90
  end
91
+
92
+ def stringify_values(labels)
93
+ stringified = {}
94
+ labels.each { |k,v| stringified[k] = v.to_s }
95
+
96
+ stringified
97
+ end
90
98
  end
91
99
  end
92
100
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Prometheus
4
4
  module Client
5
- VERSION = '0.10.0-alpha.2'
5
+ VERSION = '0.10.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: 0.10.0.pre.alpha.2
4
+ version: 0.10.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-06-25 00:00:00.000000000 Z
13
+ date: 2019-10-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: benchmark-ips
@@ -84,12 +84,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
84
84
  version: '0'
85
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 1.3.1
89
+ version: '0'
90
90
  requirements: []
91
- rubyforge_project:
92
- rubygems_version: 2.7.6
91
+ rubygems_version: 3.0.3
93
92
  signing_key:
94
93
  specification_version: 4
95
94
  summary: A suite of instrumentation metric primitivesthat can be exposed through a