prometheus_exporter 0.4.6 → 0.4.7

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: 194941c0e02ab01e7e35d9931b66d2403100eab66b7b8708b5e512a400293bb8
4
- data.tar.gz: 4059f738ec94d58d91c676ac24da5f2d6abd006d4b38ac42ca18ba92af43ab6b
3
+ metadata.gz: 88f0f450fbf76e51d739c1f9abc7cea62e2651dd366c5e9bd38df9464ebf797e
4
+ data.tar.gz: a89f2e00749002ba9323a6741cc682fb9bd2df051dd96cd68c9c9fd6e51d73d6
5
5
  SHA512:
6
- metadata.gz: e1b835e597e67fbe25e3d8c61869f68e7c5d7d5dd51e6c0972508a3816dc81f3454ad7680b74245496a73e14e86ff43dc0569d50fe8488ece2637631f1f4c4cf
7
- data.tar.gz: dcb886ecc1e568e93509fd73046cf2f498015791a41521ae567b14467ad4b2e33b93899a9145b997604bbc35916d45303e6845d31a2b284bd268bd685e4dea1e
6
+ metadata.gz: 32922666245bacfd8d608a4a08c255ef8103f70c7ba31974ed3c2685cc261b05df25d17e2c0bc38c50d67a576388d98ae9150b204a0385d3d516f298b77aa6e4
7
+ data.tar.gz: 360d70c6f3c03e31158a43f26fccee61ec25717a2b4f021ff46902b447f864533e543083d5dc675bdab0f47df93288f3f7f60157145fbea5a1e1062d6981e4fa
data/.travis CHANGED
@@ -2,8 +2,8 @@ sudo: false
2
2
  dist: trusty
3
3
  language: ruby
4
4
  rvm:
5
- - 2.2
6
5
  - 2.3
7
6
  - 2.4
8
7
  - 2.5
8
+ - 2.6
9
9
  - jruby
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ 0.4.7 - 08-04-2019
2
+
3
+ - Fix: collector was not escaping " \ and \n correctly. This could lead
4
+ to a corrupt payload in some cases.
5
+
1
6
  0.4.6 - 02-04-2019
2
7
 
3
8
  - Feature: Allow resetting a counter
@@ -11,7 +16,7 @@
11
16
 
12
17
  0.4.4 - 13-02-2019
13
18
 
14
- - Feature: add support for local metric collection without using HTTP
19
+ - Feature: add support for local metric collection without using HTTP
15
20
 
16
21
  0.4.3 - 11-02-2019
17
22
 
@@ -57,6 +57,8 @@ module PrometheusExporter::Metric
57
57
  labels = (labels || {}).merge(Base.default_labels)
58
58
  if labels && labels.length > 0
59
59
  s = labels.map do |key, value|
60
+ value = value.to_s
61
+ value = escape_value(value) if needs_escape?(value)
60
62
  "#{key}=\"#{value}\""
61
63
  end.join(",")
62
64
  "{#{s}}"
@@ -70,5 +72,29 @@ module PrometheusExporter::Metric
70
72
  #{metric_text}
71
73
  TEXT
72
74
  end
75
+
76
+ private
77
+
78
+ def escape_value(str)
79
+ str.gsub(/[\n"\\]/m) do |m|
80
+ if m == "\n"
81
+ "\\n"
82
+ else
83
+ "\\#{m}"
84
+ end
85
+ end
86
+ end
87
+
88
+ # when we drop Ruby 2.3 we can drop this
89
+ if "".respond_to? :match?
90
+ def needs_escape?(str)
91
+ str.match?(/[\n"\\]/m)
92
+ end
93
+ else
94
+ def needs_escape?(str)
95
+ !!str.match(/[\n"\\]/m)
96
+ end
97
+ end
98
+
73
99
  end
74
100
  end
@@ -1,3 +1,3 @@
1
1
  module PrometheusExporter
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prometheus_exporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-02 00:00:00.000000000 Z
11
+ date: 2019-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler