yabeda-prometheus 0.6.2 → 0.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec39031cd5a8edd3f8ab3badfac7568683e2d15dd84eb2adfacd0953af9a4f1b
4
- data.tar.gz: 68e2c9f81ab756ff009ce0d3e638cf6391fe7e7d9a02ee482857843462db66a7
3
+ metadata.gz: c36a4a73e4e698126e81bf8cb5069de6521ac396742a59dc13a906b2e6470f12
4
+ data.tar.gz: 67b7b8d5d56cff197c47bbac7b27d9a3eefe3cbbc1f63a01d8d35d2d4cd97305
5
5
  SHA512:
6
- metadata.gz: 267557ee543e48873693cfb61c31e1e535f75c0947355f3d613aac372b132848b481a5aa03fe9d1f0c2709b34482df189dd28a18039d84023384ee61016b6d52
7
- data.tar.gz: f32dfd90a9814d1eef154cb36486029467d22792cd21d63dc57f9bc3028f87d2f4d939429d58a75fb6fc8e5cffd5d3d56aaa0da2f663e868c3c6d8e3c8e4be25
6
+ metadata.gz: 25eae376eda44fd094891a717efaf877bd629b7ae9fcb0867ecf146fd0ea70e1afc7df3d24f8e615c4be11081004719de67bbfd89cacdeb011e51d74a331f1b4
7
+ data.tar.gz: 7184e70ea9a35daaf7b29e4fc8e2f9fd18e6b89679d1a4ebcb97722e359853e5723ace3a17cc3fb4a132947f758f2a4e88ccd6a8fe30bd7b48ff5d0872d46de4
data/CHANGELOG.md CHANGED
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## Unreleased
9
+
10
+ ## 0.7.0 - 2021-07-21
11
+
12
+ ### Added
13
+
14
+ - Debug mode with metric `yabeda_prometheus_render_duration` to measure how long takes to render response with already collected metrics for Prometheus. Requires Yabeda 0.10+. [@Envek], [@dsalahutdinov]
15
+
16
+ ### Changed
17
+
18
+ - Yabeda 0.10.0 or newer is required. [@Envek]
19
+
20
+ ## 0.6.2 - 2021-06-23
21
+
22
+ ### Fixed
23
+
24
+ - Fix `uninitialized constant Yabeda::Rack::Handler (NameError)` when using [yabeda-rack-attack](https://github.com/dsalahutdinov/yabeda-rack-attack). [@dsalahutdinov]
25
+
8
26
  ## 0.6.1 - 2020-04-28
9
27
 
10
28
  ### Changed
@@ -109,3 +127,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
109
127
  [@Envek]: https://github.com/Envek "Andrey Novikov"
110
128
  [@alexander37137]: https://github.com/alexander37137 "Alexander Andreev"
111
129
  [@baarkerlounger]: https://github.com/baarkerlounger "Daniel Baark"
130
+ [@dsalahutdinov]: https://github.com/dsalahutdinov "Dmitry Salahutdinov"
data/README.md CHANGED
@@ -48,6 +48,8 @@ And then execute:
48
48
 
49
49
  WEBrick will be launched in separate thread and will serve metrics on `/metrics` path.
50
50
 
51
+ > **ATTENTION**: Starting from Ruby 3.0 WEBrick isn't included with Ruby by default. You should either add `gem "webrick"` into your Gemfile or launch `Yabeda::Prometheus::Exporter.rack_app` with application server of your choice.
52
+
51
53
  See [yabeda-sidekiq] for example.
52
54
 
53
55
  Listening address is configured via `PROMETHEUS_EXPORTER_BIND` env variable (default is `0.0.0.0`).
@@ -86,6 +88,12 @@ group :some do
86
88
  end
87
89
  ```
88
90
 
91
+ ## Debugging metrics
92
+
93
+ - Time of already collected metrics rendering in response for Prometheus: `yabeda_prometheus_render_duration`.
94
+
95
+ These are only enabled in debug mode. See [Yabeda debugging metrics](https://github.com/yabeda-rb/yabeda#debugging-metrics) on how to enable it (e.g. by specifying `YABEDA_DEBUG=true` in your environment variables).
96
+
89
97
  ## Development
90
98
 
91
99
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -83,6 +83,17 @@ module Yabeda
83
83
  raise ArgumentError, 'Prometheus require metrics to have comments'
84
84
  end
85
85
 
86
+ def debug!
87
+ Yabeda.configure do
88
+ group :prometheus_exporter
89
+
90
+ histogram :render_duration,
91
+ tags: %i[], unit: :seconds,
92
+ buckets: [0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10],
93
+ comment: "Time required to render all metrics in Prometheus format"
94
+ end
95
+ end
96
+
86
97
  private
87
98
 
88
99
  # @param metric [Yabeda::Metric]
@@ -45,8 +45,17 @@ module Yabeda
45
45
  end
46
46
 
47
47
  def call(env)
48
- Yabeda.collectors.each(&:call) if env["PATH_INFO"] == path
49
- super
48
+ ::Yabeda.collect! if env["PATH_INFO"] == path
49
+
50
+ if ::Yabeda.debug?
51
+ result = nil
52
+ ::Yabeda.prometheus_exporter.render_duration.measure({}) do
53
+ result = super
54
+ end
55
+ result
56
+ else
57
+ super
58
+ end
50
59
  end
51
60
  end
52
61
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module Prometheus
5
- VERSION = "0.6.2"
5
+ VERSION = "0.7.0"
6
6
  end
7
7
  end
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.required_ruby_version = ">= 2.3"
29
29
 
30
30
  spec.add_dependency "prometheus-client", ">= 0.10", "< 3.0" # Known to work with 1.x and 2.x
31
- spec.add_dependency "yabeda", "~> 0.5"
31
+ spec.add_dependency "yabeda", "~> 0.10"
32
32
  spec.add_dependency "rack"
33
33
 
34
34
  spec.add_development_dependency "bundler", "~> 2.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yabeda-prometheus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Novikov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-23 00:00:00.000000000 Z
11
+ date: 2021-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prometheus-client
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.5'
39
+ version: '0.10'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.5'
46
+ version: '0.10'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rack
49
49
  requirement: !ruby/object:Gem::Requirement