prometheus-client-mmap 0.7.0.beta2 → 0.7.0.beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/prometheus/client/formats/text.rb +2 -27
- data/lib/prometheus/client/histogram.rb +3 -8
- data/lib/prometheus/client/label_set_validator.rb +3 -2
- data/lib/prometheus/client/metric.rb +8 -1
- data/lib/prometheus/client/rack/collector.rb +8 -2
- data/lib/prometheus/client/summary.rb +22 -9
- data/lib/prometheus/client/version.rb +1 -1
- data/lib/prometheus/client/version.rb.orig +11 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbf674d68c795209cafac2fd8084b48243ce83bf
|
4
|
+
data.tar.gz: 57ce2be5c369876f6f0783cbb33b5a0b8f6f1ebd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41b21a3ccbcf1ba6b7e96d9c3d83f66e214f4818f06a6ba4b7ffebb057a81a6204156e37e0aac45607e593c41fe87d30564fce30362877c54241f916ad4f7a0c
|
7
|
+
data.tar.gz: dfe1456e7b4d279a981efb28080e4616e473700a5fc5e44f4bc51325bc580785b196cc1bfb89ea66e1142c2d7eadd08f57a263cbbdeefc2662e82f5d85e89373
|
@@ -85,38 +85,13 @@ module Prometheus
|
|
85
85
|
else # all/liveall
|
86
86
|
samples[[name, labels]] = value
|
87
87
|
end
|
88
|
-
when :histogram
|
89
|
-
bucket = labels.select{|l| l[0] == 'le' }.map {|k, v| v.to_f}.first
|
90
|
-
if bucket
|
91
|
-
without_le = labels.select{ |l| l[0] != 'le' }
|
92
|
-
b = buckets.fetch(without_le, {})
|
93
|
-
v = b.fetch(bucket, 0.0) + value
|
94
|
-
if !buckets.has_key?(without_le)
|
95
|
-
buckets[without_le] = {}
|
96
|
-
end
|
97
|
-
buckets[without_le][bucket] = v
|
98
|
-
else
|
99
|
-
s = samples.fetch([name, labels], 0.0)
|
100
|
-
samples[[name, labels]] = s + value
|
101
|
-
end
|
102
88
|
else
|
103
|
-
# Counter and Summary.
|
89
|
+
# Counter, Histogram and Summary.
|
90
|
+
without_pid = labels.select{ |l| l[0] != 'pid' }
|
104
91
|
s = samples.fetch([name, without_pid], 0.0)
|
105
92
|
samples[[name, without_pid]] = s + value
|
106
93
|
end
|
107
94
|
|
108
|
-
if metric[:type] == :histogram
|
109
|
-
buckets.each do |labels, values|
|
110
|
-
acc = 0.0
|
111
|
-
values.sort.each do |bucket, value|
|
112
|
-
acc += value
|
113
|
-
# TODO: handle Infinity
|
114
|
-
samples[[metric[:metric_name] + '_bucket', labels + [['le', bucket.to_s]]]] = acc
|
115
|
-
end
|
116
|
-
samples[[metric[:metric_name] + '_count', labels]] = acc
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
95
|
metric[:samples] = samples.map do |name_labels, value|
|
121
96
|
name, labels = name_labels
|
122
97
|
[name, labels.to_h, value]
|
@@ -13,13 +13,12 @@ module Prometheus
|
|
13
13
|
attr_accessor :sum, :total
|
14
14
|
|
15
15
|
def initialize(type, name, labels, buckets)
|
16
|
-
@sum = ValueClass.new(type, name, name
|
16
|
+
@sum = ValueClass.new(type, name, "#{name}_sum", labels)
|
17
17
|
# TODO: get rid of total and use +Inf bucket instead.
|
18
|
-
@total = ValueClass.new(type, name, name
|
18
|
+
@total = ValueClass.new(type, name, "#{name}_count", labels)
|
19
19
|
|
20
20
|
buckets.each do |bucket|
|
21
|
-
|
22
|
-
self[bucket] = ValueClass.new(type, name, name.to_s + '_bucket', labels.merge({'le' => bucket.to_s}))
|
21
|
+
self[bucket] = ValueClass.new(type, name, "#{name}_bucket", labels.merge({:le => bucket.to_s}))
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
@@ -61,10 +60,6 @@ module Prometheus
|
|
61
60
|
end
|
62
61
|
|
63
62
|
def observe(labels, value)
|
64
|
-
if labels[:le]
|
65
|
-
raise ArgumentError, 'Label with name "le" is not permitted'
|
66
|
-
end
|
67
|
-
|
68
63
|
label_set = label_set_for(labels)
|
69
64
|
synchronize { @values[label_set].observe(value) }
|
70
65
|
end
|
@@ -13,7 +13,8 @@ module Prometheus
|
|
13
13
|
class InvalidLabelError < LabelSetError; end
|
14
14
|
class ReservedLabelError < LabelSetError; end
|
15
15
|
|
16
|
-
def initialize
|
16
|
+
def initialize(reserved_labels = [])
|
17
|
+
@reserved_labels = (reserved_labels + RESERVED_LABELS).freeze
|
17
18
|
@validated = {}
|
18
19
|
end
|
19
20
|
|
@@ -60,7 +61,7 @@ module Prometheus
|
|
60
61
|
end
|
61
62
|
|
62
63
|
def validate_reserved_key(key)
|
63
|
-
return true unless
|
64
|
+
return true unless @reserved_labels.include?(key)
|
64
65
|
|
65
66
|
raise ReservedLabelError, "#{key} is reserved"
|
66
67
|
end
|
@@ -12,7 +12,14 @@ module Prometheus
|
|
12
12
|
|
13
13
|
def initialize(name, docstring, base_labels = {})
|
14
14
|
@mutex = Mutex.new
|
15
|
-
|
15
|
+
case type
|
16
|
+
when :summary
|
17
|
+
@validator = LabelSetValidator.new(['quantile'])
|
18
|
+
when :histogram
|
19
|
+
@validator = LabelSetValidator.new(['le'])
|
20
|
+
else
|
21
|
+
@validator = LabelSetValidator.new
|
22
|
+
end
|
16
23
|
@values = Hash.new { |hash, key| hash[key] = default(key) }
|
17
24
|
|
18
25
|
validate_name(name)
|
@@ -41,6 +41,10 @@ module Prometheus
|
|
41
41
|
)
|
42
42
|
@durations = @registry.summary(
|
43
43
|
:http_request_duration_seconds,
|
44
|
+
'A summary of the response latency.',
|
45
|
+
)
|
46
|
+
@durations_hist = @registry.histogram(
|
47
|
+
:http_req_duration_seconds,
|
44
48
|
'A histogram of the response latency.',
|
45
49
|
)
|
46
50
|
end
|
@@ -72,8 +76,10 @@ module Prometheus
|
|
72
76
|
def record(labels, duration)
|
73
77
|
@requests.increment(labels)
|
74
78
|
@durations.observe(labels, duration)
|
75
|
-
|
76
|
-
|
79
|
+
@durations_hist.observe(labels, duration)
|
80
|
+
rescue => exception
|
81
|
+
@exceptions.increment(exception: exception.class.name)
|
82
|
+
raise
|
77
83
|
nil
|
78
84
|
end
|
79
85
|
end
|
@@ -14,17 +14,30 @@ module Prometheus
|
|
14
14
|
class Value < Hash
|
15
15
|
attr_accessor :sum, :total
|
16
16
|
|
17
|
-
def initialize(name, labels
|
18
|
-
@sum = ValueClass.new(name, name
|
19
|
-
@total = ValueClass.new(name, name
|
17
|
+
def initialize(type, name, labels)
|
18
|
+
@sum = ValueClass.new(type, name, "#{name}_sum", labels)
|
19
|
+
@total = ValueClass.new(type, name, "#{name}_count", labels)
|
20
|
+
@estimator = Quantile::Estimator.new
|
21
|
+
@estimator.invariants.each do |invariant|
|
22
|
+
self[invariant.quantile] = ValueClass.new(type, name, "#{name}_summary", labels.merge({:quantile => invariant.quantile}))
|
23
|
+
end
|
24
|
+
end
|
20
25
|
|
21
|
-
|
22
|
-
|
26
|
+
def observe(value)
|
27
|
+
@sum.increment(value)
|
28
|
+
@total.increment()
|
29
|
+
# TODO: The quantile info is innaccurate as it only contains
|
30
|
+
# observations per-process. What needs to happen is for
|
31
|
+
# observations to be read into the estimator and then reported.
|
32
|
+
# Alternatively it could be done in the exporter.
|
33
|
+
@estimator.observe(value)
|
34
|
+
@estimator.invariants.each do |invariant|
|
35
|
+
self[invariant.quantile].set(@estimator.query(invariant.quantile))
|
23
36
|
end
|
24
37
|
end
|
25
38
|
end
|
26
39
|
|
27
|
-
def initialize(name, docstring, base_labels = {}
|
40
|
+
def initialize(name, docstring, base_labels = {})
|
28
41
|
super(name, docstring, base_labels)
|
29
42
|
end
|
30
43
|
|
@@ -45,7 +58,7 @@ module Prometheus
|
|
45
58
|
@validator.valid?(labels)
|
46
59
|
|
47
60
|
synchronize do
|
48
|
-
Value.new(@values[labels])
|
61
|
+
Value.new(@values[labels].sum)
|
49
62
|
end
|
50
63
|
end
|
51
64
|
|
@@ -53,7 +66,7 @@ module Prometheus
|
|
53
66
|
def values
|
54
67
|
synchronize do
|
55
68
|
@values.each_with_object({}) do |(labels, value), memo|
|
56
|
-
memo[labels] = value
|
69
|
+
memo[labels] = value.sum
|
57
70
|
end
|
58
71
|
end
|
59
72
|
end
|
@@ -61,7 +74,7 @@ module Prometheus
|
|
61
74
|
private
|
62
75
|
|
63
76
|
def default(labels)
|
64
|
-
Value.new(type, @name, labels
|
77
|
+
Value.new(type, @name, labels)
|
65
78
|
end
|
66
79
|
end
|
67
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prometheus-client-mmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.0.
|
4
|
+
version: 0.7.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Schmidt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: quantile
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- lib/prometheus/client/summary.rb
|
48
48
|
- lib/prometheus/client/valuetype.rb
|
49
49
|
- lib/prometheus/client/version.rb
|
50
|
+
- lib/prometheus/client/version.rb.orig
|
50
51
|
homepage: https://github.com/pchojnacki/client_ruby
|
51
52
|
licenses:
|
52
53
|
- Apache 2.0
|