yabeda-prometheus-mmap 0.2.0 → 0.4.0

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: 759db288b622e2ae72ba1d304d0cabbf31d67f9e68cbc7f056c34a33b636e101
4
- data.tar.gz: c6778787416e6ebe3a719d2bf8e88e910e6eb4518fa1f5d8fde4571839f0fb4a
3
+ metadata.gz: 4ae6601a66f8d497062fc78cf79a2c148b2f8b6f03ba7ad39a689afa821a6b40
4
+ data.tar.gz: 0761d311cd01b780e4ef02dfc03636a3dad90846fcdfd1fb44a7553cb0d20f69
5
5
  SHA512:
6
- metadata.gz: 739bfbbb8de20743592d0528bd0e7a83c3a8c2e416cab44c10e2a4f90fd8577c3d17f287df1ece768bded0a4645f401e78856f59782a2c0e22d001aec650fc42
7
- data.tar.gz: a69d049adb2ef301e0efd1cc01bb49fa0632c4584727de5ac4d0f647602df887bbc92203cb22ceb4585f5c20d926c09f9db6222a0310033fd71cc481d095d252
6
+ metadata.gz: 7b9ea598802e0ee12bc6b597fc928bbde0cd885970310838d6f2e024e089a59904c4a03b92a67d5b84d8005e5aaf4106bced7756ab9a0f2fbaec38a8b52b6f0e
7
+ data.tar.gz: fecedc71c04707a220b59f512fcff784edaff6158eaaf740d8d9e17b8978368fe71c48103f45dd58a8a0f587841416b25b5d4206a5066165a4cf3c5e4322cf8c
@@ -0,0 +1,32 @@
1
+ name: Lint Ruby
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ paths:
8
+ - "gemfiles/*"
9
+ - "Gemfile"
10
+ - "**/*.rb"
11
+ - "**/*.gemspec"
12
+ - ".github/workflows/lint.yml"
13
+ pull_request:
14
+ paths:
15
+ - "gemfiles/*"
16
+ - "Gemfile"
17
+ - "**/*.rb"
18
+ - "**/*.gemspec"
19
+ - ".github/workflows/lint.yml"
20
+
21
+ jobs:
22
+ rubocop:
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v3
26
+ - uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: 3.2
29
+ bundler-cache: true
30
+ - name: Lint Ruby code with RuboCop
31
+ run: |
32
+ bundle exec rubocop
@@ -17,31 +17,15 @@ jobs:
17
17
  fail-fast: false
18
18
  matrix:
19
19
  include:
20
- - ruby: 3.0
21
- - ruby: 2.7
22
- - ruby: 2.6
23
- - ruby: 2.5
24
- container:
25
- image: ruby:${{ matrix.ruby }}
26
- env:
27
- CI: true
20
+ - ruby: "3.2"
21
+ - ruby: "3.1"
22
+ - ruby: "3.0"
23
+ - ruby: "2.7"
28
24
  steps:
29
- - uses: actions/checkout@v2
30
- - uses: actions/cache@v2
25
+ - uses: actions/checkout@v3
26
+ - uses: ruby/setup-ruby@v1
31
27
  with:
32
- path: vendor/bundle
33
- key: bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
34
- restore-keys: |
35
- bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
36
- bundle-${{ matrix.ruby }}-
37
- - name: Upgrade Bundler to 2.0 (for older Rubies)
38
- run: gem install bundler -v '~> 2.0'
39
- - name: Bundle install
40
- run: |
41
- bundle config path vendor/bundle
42
- bundle install
43
- bundle update
44
- - name: Run Rubocop
45
- run: bundle exec rubocop
28
+ ruby-version: ${{ matrix.ruby }}
29
+ bundler-cache: true
46
30
  - name: Run RSpec
47
31
  run: bundle exec rspec
data/CHANGELOG.md CHANGED
@@ -5,6 +5,22 @@ 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
+ ## 0.4.0 - 2023-12-11
9
+
10
+ ### Added
11
+
12
+ - Support for gauge aggregation setting [#6](https://github.com/yabeda-rb/yabeda-prometheus-mmap/pull/6) by [@andreaswachowski][].
13
+
14
+ ### Fixed
15
+
16
+ - Compatibility with Rack 3 and Rack 2. [#8](https://github.com/yabeda-rb/yabeda-prometheus-mmap/pull/8) by [@aroop][].
17
+
18
+ ## 0.3.0 - 2021-08-27
19
+
20
+ ### Added
21
+
22
+ - Possibility to disable metrics web server logs [@bibendi]
23
+
8
24
  ## 0.2.0 - 2021-07-21
9
25
 
10
26
  ### Added
@@ -34,3 +50,6 @@ Initial release. [@dsalahutdinov][]
34
50
  [@macchiang]: https://github.com/macchiang "Mac"
35
51
  [@dsalahutdinov]: https://github.com/dsalahutdinov "Salahutdinov Dmitry"
36
52
  [@Envek]: https://github.com/Envek "Andrey Novikov"
53
+ [@bibendi]: https://github.com/bibendi/ "Misha Merkushin"
54
+ [@andreaswachowski]: https://github.com/andreaswachowski "Andreas Wachowski"
55
+ [@aroop]: https://github.com/aroop "Ajay Kumar G"
data/Gemfile CHANGED
@@ -7,6 +7,6 @@ gemspec
7
7
 
8
8
  gem 'byebug'
9
9
  gem 'rack'
10
- gem 'rake', '~> 12.0'
10
+ gem 'rake', '~> 13.0'
11
11
  gem 'rspec', '~> 3.0'
12
- gem 'rubocop', '~> 0.81.0'
12
+ gem 'rubocop', '~> 1.0'
@@ -35,7 +35,8 @@ module Yabeda
35
35
  registry.gauge(
36
36
  build_name(metric),
37
37
  metric.comment,
38
- build_tags(metric.tags)
38
+ build_tags(metric.tags),
39
+ gauge_aggregation_mode(metric.aggregation)
39
40
  )
40
41
  end
41
42
 
@@ -86,6 +87,21 @@ module Yabeda
86
87
  end
87
88
  end
88
89
 
90
+ private
91
+
92
+ def gauge_aggregation_mode(yabeda_mode)
93
+ case yabeda_mode
94
+ when nil, :most_recent # TODO: Switch to most_recent when supported: https://gitlab.com/gitlab-org/ruby/gems/prometheus-client-mmap/-/issues/36
95
+ :all
96
+ when :min, :max, :all, :liveall
97
+ yabeda_mode
98
+ when :sum
99
+ :livesum
100
+ else
101
+ raise ArgumentError, "Unsupported gauge aggregation mode #{yabeda_mode.inspect}"
102
+ end
103
+ end
104
+
89
105
  Yabeda.register_adapter(:prometheus, new)
90
106
  end
91
107
  end
@@ -23,7 +23,8 @@ module Yabeda
23
23
  def start_metrics_server!
24
24
  Thread.new do
25
25
  default_port = ENV.fetch('PORT', 9394)
26
- ::Rack::Handler::WEBrick.run(
26
+
27
+ rack_handler.run(
27
28
  rack_app,
28
29
  Host: ENV['PROMETHEUS_EXPORTER_BIND'] || '0.0.0.0',
29
30
  Port: ENV.fetch('PROMETHEUS_EXPORTER_PORT', default_port),
@@ -32,9 +33,21 @@ module Yabeda
32
33
  end
33
34
  end
34
35
 
36
+ def rack_handler
37
+ if Gem.loaded_specs['rack']&.version&.>= Gem::Version.new('3.0')
38
+ require 'rackup'
39
+ ::Rackup::Handler::WEBrick
40
+ else
41
+ ::Rack::Handler::WEBrick
42
+ end
43
+ rescue LoadError
44
+ warn 'Please add gems rackup and webrick to your Gemfile to expose Yabeda metrics from prometheus-mmap'
45
+ ::Rack::Handler::WEBrick
46
+ end
47
+
35
48
  def rack_app(exporter = self, path: '/metrics')
36
49
  ::Rack::Builder.new do
37
- use ::Rack::CommonLogger
50
+ use ::Rack::CommonLogger if ENV['PROMETHEUS_EXPORTER_LOG_REQUESTS'] != 'false'
38
51
  use ::Rack::ShowExceptions
39
52
  use exporter, path: path
40
53
  run NOT_FOUND_HANDLER
@@ -3,7 +3,7 @@
3
3
  module Yabeda
4
4
  module Prometheus
5
5
  module Mmap
6
- VERSION = '0.2.0'
6
+ VERSION = '0.4.0'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yabeda-prometheus-mmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Salahutdinov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-21 00:00:00.000000000 Z
11
+ date: 2023-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prometheus-client-mmap
@@ -46,6 +46,7 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - ".github/workflows/build-release.yml"
49
+ - ".github/workflows/lint.yaml"
49
50
  - ".github/workflows/test.yml"
50
51
  - ".gitignore"
51
52
  - ".rspec"