prometheus_exporter 0.1.1 → 0.1.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: 7305782eba6ee46bb2a297842faf57e7b877fd49e74f40da92453940d95e61b1
4
- data.tar.gz: 3ff1296f2c98f7b7eb1dbae10bef84c1df85f570bfc3987e863997b003ae69e6
3
+ metadata.gz: 0ab5d3f6ca1ef701116fda3e93cd10f27f2b6dec09d9c51e85a5cfb630680cb8
4
+ data.tar.gz: a743e9b6aa2b30d5cf815126bc75093a6ea99128b2837b7ab0008c732fb89a03
5
5
  SHA512:
6
- metadata.gz: 91213aa47a87810ee96b9ad7ce24551777aca27ad806aaf4f5d4894580ead9328c948d1cd015d3b00d44d251dbd7a227061de513c2871571c1a35e28ee65bc36
7
- data.tar.gz: 7b243acc29e72fb3c4913665f1e3a6c393c1445225234d4c11fc48fa9c457ace5ed4242dc88c6fcd26bdecbb54aaae2db60e4d5c147be360c9e14199c824578e
6
+ metadata.gz: 40d8f8b98148df693fdc543a3f2a48893f3a101ecc30a9fddeae68a42c1aeb7a31c1848879e5226aae6e81662be4e1d83b1ed34d3e4a69f16ade8b5465e66957
7
+ data.tar.gz: 18960e4fefd02b61cbfd8188c8fd47fcb9e20c606e4adedf838e68e09a0446d5187583978a06edf6e2cc1668f4da9e80a01a6b399202f95bd007cfd3dc7b20e7
@@ -26,9 +26,13 @@ module PrometheusExporter::Server
26
26
  res.status = 200
27
27
  if req.header["accept-encoding"].to_s.include?("gzip")
28
28
  sio = StringIO.new
29
- writer = Zlib::GzipWriter.new(sio)
30
- writer.write(metrics)
31
- writer.close
29
+ collected_metrics = metrics
30
+ begin
31
+ writer = Zlib::GzipWriter.new(sio)
32
+ writer.write(collected_metrics)
33
+ ensure
34
+ writer.close
35
+ end
32
36
  res.body = sio.string
33
37
  res.header["content-encoding"] = "gzip"
34
38
  else
@@ -91,12 +95,23 @@ module PrometheusExporter::Server
91
95
  metric_text && metric_text.length > 0 ? 1 : 0
92
96
  )
93
97
 
98
+ add_gauge(
99
+ "collector_rss",
100
+ "total memory used by collector process",
101
+ get_rss
102
+ )
103
+
94
104
  <<~TEXT
95
105
  #{@metrics.map(&:to_prometheus_text).join("\n\n")}
96
106
  #{metric_text}
97
107
  TEXT
98
108
  end
99
109
 
110
+ def get_rss
111
+ @pagesize ||= `getconf PAGESIZE`.to_i rescue 4096
112
+ File.read("/proc/#{pid}/statm").split(' ')[1].to_i * @pagesize rescue 0
113
+ end
114
+
100
115
  def add_gauge(name, help, value)
101
116
  gauge = PrometheusExporter::Metric::Gauge.new(name, help)
102
117
  gauge.observe(value)
@@ -1,3 +1,3 @@
1
1
  module PrometheusExporter
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prometheus_exporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron