yabeda-prometheus 0.8.0 → 0.9.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: 03ed652a9c06383f38442a04db2ed423b0bf5c2bad99a0e34da5d965ed988ced
4
- data.tar.gz: ec9f84a17b4f8b773a57985fe61cc4f6a0a4a67e4216f36683a0b8d5e6f95671
3
+ metadata.gz: 906db4d10bd83296b001ddaa09d01bb01adb55299f054cd484c52cb8e1168dd8
4
+ data.tar.gz: 870e978d2065aa4ef51904b34bdd6ea38cdd48e2a5ddb19ecab4792f3d5e0194
5
5
  SHA512:
6
- metadata.gz: 45f454d796db3b1202bc238aadb4bb744686ddffe4efbf328ac172d3eeea6c21614a643d21ae49b971ca43eee0ad29b5ebb636773ebce0cd643620b3f99646f6
7
- data.tar.gz: 1300508ed83ecefa768fb7ae6a8de08534eae83b2834fa9bf3577e77897ef7efb1a8ad5dfab88af92a1ba6c96caec9412dd14d48a1aa8938749bdfdaa17a5853
6
+ metadata.gz: d25b3c9449c812c329f1f6fb3acd0dcebc93a73a5895d37e2d6b76a0b3a3d3ee5b7aa04d80111469de5b0f76dfcd6986f6f5b64c8e30b52aec9196116dbda478
7
+ data.tar.gz: 1506ce4596bf8aaef915a1b098f32a376e7d9ec7771f2a40b02c972e9dfc38ffbc7f49171387aa5c44766329a18d26705c24019296bc0cb543594d254ea216d3
data/CHANGELOG.md CHANGED
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 0.9.0 - 2023-07-28
11
+
12
+ ### Added
13
+
14
+ - Support for summary metric type (Yabeda 0.12+ is required). [@Envek]
15
+ - Metrics endpoint response compression with Rack Deflater. [@etsenake], ([#23](https://github.com/yabeda-rb/yabeda-prometheus/pull/23)
16
+
17
+ ### Changed
18
+
19
+ - prometheus-client 3.x or 4.x is required. [@Envek]
20
+
10
21
  ## 0.8.0 - 2021-12-30
11
22
 
12
23
  ### Added
@@ -141,3 +152,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
141
152
  [@dsalahutdinov]: https://github.com/dsalahutdinov "Dmitry Salahutdinov"
142
153
  [@palkan]: https://github.com/palkan "Vladimir Dementyev"
143
154
  [@ollym]: https://github.com/ollym "Oliver Morgan"
155
+ [@etsenake]: https://github.com/etsenake "Josh Etsenake"
data/Gemfile CHANGED
@@ -8,6 +8,8 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
8
8
  gemspec
9
9
 
10
10
  group :development, :test do
11
+ gem "yabeda", ">= 0.12", github: "yabeda-rb/yabeda", branch: "master"
12
+
11
13
  gem "pry"
12
14
  gem "pry-byebug", platform: :mri
13
15
 
data/README.md CHANGED
@@ -36,9 +36,17 @@ And then execute:
36
36
  use Yabeda::Prometheus::Exporter
37
37
  ```
38
38
 
39
- Metrics will be available on `/metrics` path (configured by `:path` option).
39
+ Metrics will be available on `/metrics` path (configured by `:path` option), additionally metrics can be served only on specific port with `:port` option.
40
40
 
41
- Also you can mount it in Rails application routes as standalone Rack application.
41
+ Alternatively you can mount it in Rails application routes as standalone Rack application:
42
+
43
+ ```ruby
44
+ Rails.application.routes.draw do
45
+ mount Yabeda::Prometheus::Exporter, at: "/metrics"
46
+ end
47
+ ```
48
+
49
+ Additional options (like `:port`) are also accepted and forwarded to [Prometheys Exporter](https://github.com/prometheus/client_ruby/blob/main/lib/prometheus/middleware/exporter.rb) middleware.
42
50
 
43
51
  2. Run web-server from long-running processes (delayed jobs, …):
44
52
 
@@ -73,6 +73,22 @@ module Yabeda
73
73
  raise UndeclaredMetricTags.new(build_name(metric), e)
74
74
  end
75
75
 
76
+ def register_summary!(metric)
77
+ validate_metric!(metric)
78
+ registry.summary(
79
+ build_name(metric),
80
+ docstring: metric.comment,
81
+ labels: Array(metric.tags),
82
+ store_settings: store_settings(metric),
83
+ )
84
+ end
85
+
86
+ def perform_summary_observe!(metric, tags, value)
87
+ registry.get(build_name(metric)).observe(value, labels: tags)
88
+ rescue ::Prometheus::Client::LabelSetValidator::InvalidLabelSetError => e
89
+ raise UndeclaredMetricTags.new(build_name(metric), e)
90
+ end
91
+
76
92
  def build_name(metric)
77
93
  [metric.group, metric.name, metric.unit].compact.join('_').to_sym
78
94
  end
@@ -14,7 +14,8 @@ module Yabeda
14
14
  class << self
15
15
  # Allows to use middleware as standalone rack application
16
16
  def call(env)
17
- @app ||= new(NOT_FOUND_HANDLER, path: "/")
17
+ options = env.fetch("action_dispatch.request.path_parameters", {})
18
+ @app ||= new(NOT_FOUND_HANDLER, path: "/", **options)
18
19
  @app.call(env)
19
20
  end
20
21
 
@@ -30,11 +31,12 @@ module Yabeda
30
31
  end
31
32
  end
32
33
 
33
- def rack_app(exporter = self, path: "/metrics", logger: Logger.new(IO::NULL))
34
+ def rack_app(exporter = self, logger: Logger.new(IO::NULL), use_deflater: true, **exporter_options)
34
35
  ::Rack::Builder.new do
36
+ use ::Rack::Deflater if use_deflater
35
37
  use ::Rack::CommonLogger, logger
36
38
  use ::Rack::ShowExceptions
37
- use exporter, path: path
39
+ use exporter, **exporter_options
38
40
  run NOT_FOUND_HANDLER
39
41
  end
40
42
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module Prometheus
5
- VERSION = "0.8.0"
5
+ VERSION = "0.9.0"
6
6
  end
7
7
  end
@@ -15,17 +15,12 @@ module Yabeda
15
15
  end
16
16
 
17
17
  def push_gateway
18
- @push_gateway ||= begin
18
+ @push_gateway ||=
19
19
  ::Prometheus::Client::Push.new(
20
- ENV.fetch("PROMETHEUS_JOB_NAME", "yabeda"),
21
- ENV["PROMETHEUS_INSTANCE"],
22
- ENV.fetch("PROMETHEUS_PUSH_GATEWAY", "http://localhost:9091"),
23
- ).tap do |gateway|
24
- http = gateway.instance_variable_get(:@http)
25
- http.open_timeout = 5
26
- http.read_timeout = 5
27
- end
28
- end
20
+ job: ENV.fetch("PROMETHEUS_JOB_NAME", "yabeda"),
21
+ gateway: ENV.fetch("PROMETHEUS_PUSH_GATEWAY", "http://localhost:9091"),
22
+ open_timeout: 5, read_timeout: 30,
23
+ )
29
24
  end
30
25
  end
31
26
  end
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.required_ruby_version = ">= 2.3"
29
29
 
30
- spec.add_dependency "prometheus-client", ">= 0.10", "< 3.0" # Known to work with 1.x and 2.x
30
+ spec.add_dependency "prometheus-client", ">= 3.0", "< 5.0"
31
31
  spec.add_dependency "yabeda", "~> 0.10"
32
32
  spec.add_dependency "rack"
33
33
 
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.8.0
4
+ version: 0.9.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-12-30 00:00:00.000000000 Z
11
+ date: 2023-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prometheus-client
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.10'
19
+ version: '3.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '3.0'
22
+ version: '5.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '0.10'
29
+ version: '3.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '3.0'
32
+ version: '5.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: yabeda
35
35
  requirement: !ruby/object:Gem::Requirement