prometheus_exporter 0.1.11 → 0.1.12

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: 0f8cdad15069a123e796605403a905e67ba6b0310961fecf5e9eb0a96d3f1d9e
4
- data.tar.gz: 2b5c3584a871a670dbbb2166e801de402a279164261281a3693769bef705fe37
3
+ metadata.gz: 2b09dff4a49846230b74243135fcacc1d88b440b04b69e76cf4dce76bd3eaa90
4
+ data.tar.gz: fb48d9cecb4d0ed600c00c8c8265ec88f4ab8b0e81369adf08eaee478895c337
5
5
  SHA512:
6
- metadata.gz: ee0180cc0497889ca30f6f9920be065a35cbad7553a6ceddbfbb3647c8fc9e92f9a61b72973671232e07f5326b182460bd7e841c02f4e82cf73e311d451e7903
7
- data.tar.gz: 0607ff6aca87265054f28f0a187186bfd55472a8271a7184c81ef82ee4f3febabde16ca354e634a953c31c5d989befb0ed5adaf5e95ed4e68bb7b1ad85d3c7f6
6
+ metadata.gz: 777e3913f7fd24cd455af42e6ac1d73b98ef6a803189c43443f2d3d517bf4aa540b3be994d99afbb5060bc83ff83ed42be2037217b14522d848918891d64cb1c
7
+ data.tar.gz: bcbde54a95042c01a80e297ca6096444574d9e8c1d17027759469e51f4ff36b8b23cf574f6111034233805546e7f7a73e8cc8922b96f787191b4bdb345e8dbfa
data/README.md CHANGED
@@ -155,6 +155,50 @@ Ensure you run the exporter in a monitored background process via
155
155
  % bundle exec prometheus_exporter
156
156
  ```
157
157
 
158
+ ### Custom type collectors
159
+
160
+ In some cases you may have custom metrics you want to ship the collector in a batch, in this case you may still be interested in the base collector behavior but would like to add your own special messages.
161
+
162
+ ```ruby
163
+ # person_collector.rb
164
+ class PersonCollector < PrometheusExporter::Server::TypeCollector
165
+ def initialize
166
+ @oldies = PrometheusExporter::Metric::Counter.new("oldies", "old people")
167
+ @youngies = PrometheusExporter::Metric::Counter.new("youngies", "young people")
168
+ end
169
+
170
+ def type
171
+ "person"
172
+ end
173
+
174
+ def collect(obj)
175
+ if obj["age"] > 21
176
+ @oldies.observe(1)
177
+ else
178
+ @youngies.observe(1)
179
+ end
180
+ end
181
+
182
+ def metrics
183
+ [@oldies, @youngies]
184
+ end
185
+ end
186
+ ```
187
+
188
+ Shipping metrics then is done via:
189
+
190
+ ```
191
+ PrometheusExporter::Client.default.send_json(type: "person", age: 40)
192
+ ```
193
+
194
+ To load the custom collector run:
195
+
196
+
197
+ ```
198
+ bundle exec prometheus_exporter -a person_collector.rb
199
+
200
+ ```
201
+
158
202
  ### Multi process mode with custom collector
159
203
 
160
204
  You can opt for custom collector logic in a multi process environment.
@@ -38,7 +38,7 @@ module PrometheusExporter::Server
38
38
  obj = JSON.parse(str)
39
39
  @mutex.synchronize do
40
40
  if collector = @collectors[obj["type"]]
41
- collector.observe(obj)
41
+ collector.collect(obj)
42
42
  else
43
43
  metric = @metrics[obj["name"]]
44
44
  if !metric
@@ -56,7 +56,7 @@ module PrometheusExporter::Server
56
56
  metrics.values
57
57
  end
58
58
 
59
- def observe(obj)
59
+ def collect(obj)
60
60
  now = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
61
61
 
62
62
  obj["created_at"] = now
@@ -5,7 +5,7 @@ module PrometheusExporter::Server
5
5
  "sidekiq"
6
6
  end
7
7
 
8
- def observe(obj)
8
+ def collect(obj)
9
9
  ensure_sidekiq_metrics
10
10
  @sidekiq_job_duration_seconds.observe(obj["duration"], job_name: obj["name"])
11
11
  @sidekiq_job_count.observe(1, job_name: obj["name"])
@@ -1,3 +1,3 @@
1
1
  module PrometheusExporter
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.12"
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.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-31 00:00:00.000000000 Z
11
+ date: 2018-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler