diff --git a/Gemfile b/Gemfile index b2af28e2..c5de281e 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,7 @@ gem 'zeitwerk', '~> 2.6.18' # keep zeitwerk 2.6 until Ruby is 3.2 or higher gem 'pg', '~> 1.6.2' # Use Puma as the app server -gem 'puma', '~> 5.2' +gem 'puma', '~> 6' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder # gem 'jbuilder', '~> 2.5' @@ -47,9 +47,9 @@ gem 'message_bus' # for publishing notifications about integration status gem 'validate_url' -gem 'prometheus-client', '~> 2.1.0', require: %w[prometheus/client] +gem 'prometheus-client', '~> 4' gem 'yabeda-rails' -gem 'yabeda-prometheus', '~> 0.6.1' +gem 'yabeda-prometheus', '~> 0.9' gem 'yabeda-puma-plugin' # Dependency for yabeda-prometheus @@ -75,6 +75,7 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] group :test do gem 'minitest-reporters' gem 'minitest-stub-const' + gem "minitest-mock", "~> 5.27" gem 'webmock' gem 'codecov', require: false gem 'simplecov', '~> 0.21.2', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 4f00de5a..5e2e173f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,29 +9,29 @@ GEM remote: https://rubygems.org/ specs: 3scale-api (1.4.0) - actioncable (8.0.2.1) - actionpack (= 8.0.2.1) - activesupport (= 8.0.2.1) + actioncable (8.0.5) + actionpack (= 8.0.5) + activesupport (= 8.0.5) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (8.0.2.1) - actionpack (= 8.0.2.1) - activejob (= 8.0.2.1) - activerecord (= 8.0.2.1) - activestorage (= 8.0.2.1) - activesupport (= 8.0.2.1) + actionmailbox (8.0.5) + actionpack (= 8.0.5) + activejob (= 8.0.5) + activerecord (= 8.0.5) + activestorage (= 8.0.5) + activesupport (= 8.0.5) mail (>= 2.8.0) - actionmailer (8.0.2.1) - actionpack (= 8.0.2.1) - actionview (= 8.0.2.1) - activejob (= 8.0.2.1) - activesupport (= 8.0.2.1) + actionmailer (8.0.5) + actionpack (= 8.0.5) + actionview (= 8.0.5) + activejob (= 8.0.5) + activesupport (= 8.0.5) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (8.0.2.1) - actionview (= 8.0.2.1) - activesupport (= 8.0.2.1) + actionpack (8.0.5) + actionview (= 8.0.5) + activesupport (= 8.0.5) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) @@ -39,35 +39,35 @@ GEM rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (8.0.2.1) - actionpack (= 8.0.2.1) - activerecord (= 8.0.2.1) - activestorage (= 8.0.2.1) - activesupport (= 8.0.2.1) + actiontext (8.0.5) + actionpack (= 8.0.5) + activerecord (= 8.0.5) + activestorage (= 8.0.5) + activesupport (= 8.0.5) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (8.0.2.1) - activesupport (= 8.0.2.1) + actionview (8.0.5) + activesupport (= 8.0.5) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (8.0.2.1) - activesupport (= 8.0.2.1) + activejob (8.0.5) + activesupport (= 8.0.5) globalid (>= 0.3.6) - activemodel (8.0.2.1) - activesupport (= 8.0.2.1) - activerecord (8.0.2.1) - activemodel (= 8.0.2.1) - activesupport (= 8.0.2.1) + activemodel (8.0.5) + activesupport (= 8.0.5) + activerecord (8.0.5) + activemodel (= 8.0.5) + activesupport (= 8.0.5) timeout (>= 0.4.0) - activestorage (8.0.2.1) - actionpack (= 8.0.2.1) - activejob (= 8.0.2.1) - activerecord (= 8.0.2.1) - activesupport (= 8.0.2.1) + activestorage (8.0.5) + actionpack (= 8.0.5) + activejob (= 8.0.5) + activerecord (= 8.0.5) + activesupport (= 8.0.5) marcel (~> 1.0) - activesupport (8.0.2.1) + activesupport (8.0.5) base64 benchmark (>= 0.3) bigdecimal @@ -83,6 +83,8 @@ GEM addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) ansi (1.5.0) + anyway_config (2.8.0) + ruby-next-core (~> 1.0) ast (2.4.3) base64 (0.3.0) benchmark (0.5.0) @@ -134,7 +136,7 @@ GEM dry-inflector (~> 1.0) dry-logic (~> 1.4) zeitwerk (~> 2.6) - erb (6.0.1) + erb (6.0.2) erubi (1.13.1) excon (0.112.0) faraday (2.14.1) @@ -155,8 +157,9 @@ GEM ice_nine (0.11.2) interception (0.5) io-console (0.8.2) - irb (1.16.0) + irb (1.17.0) pp (>= 0.6.0) + prism (>= 1.3.0) rdoc (>= 4.0.0) reline (>= 0.4.2) json (2.19.2) @@ -204,7 +207,10 @@ GEM method_source (1.1.0) mini_mime (1.1.5) mini_portile2 (2.8.9) - minitest (5.26.2) + minitest (6.0.2) + drb (~> 2.0) + prism (~> 1.5) + minitest-mock (5.27.0) minitest-reporters (1.4.3) ansi builder @@ -214,12 +220,12 @@ GEM msgpack (1.7.1) multi_json (1.18.0) multi_xml (0.6.0) - mustermann (2.0.2) + mustermann (3.0.4) ruby2_keywords (~> 0.0.1) mutex_m (0.3.0) net-http (0.9.1) uri (>= 0.11.1) - net-imap (0.6.2) + net-imap (0.6.3) date net-protocol net-pop (0.1.2) @@ -229,7 +235,7 @@ GEM net-smtp (0.5.1) net-protocol nio4r (2.7.5) - nokogiri (1.19.1) + nokogiri (1.19.2) mini_portile2 (~> 2.8.2) racc (~> 1.4) oauth2 (2.0.18) @@ -250,7 +256,8 @@ GEM prettyprint prettyprint (0.2.0) prism (1.6.0) - prometheus-client (2.1.0) + prometheus-client (4.2.5) + base64 pry (0.15.2) coderay (~> 1.1) method_source (~> 1.0) @@ -269,47 +276,49 @@ GEM date stringio public_suffix (4.0.6) - puma (5.6.9) + puma (6.6.1) nio4r (~> 2.0) que (2.4.1) que-web (0.10.0) que (>= 1) sinatra racc (1.8.1) - rack (2.2.22) - rack-protection (2.2.3) - rack - rack-session (1.0.2) - rack (< 3) + rack (3.2.5) + rack-protection (4.2.1) + base64 (>= 0.1.0) + logger (>= 1.6.0) + rack (>= 3.0.0, < 4) + rack-session (2.1.1) + base64 (>= 0.1.0) + rack (>= 3.0.0) rack-test (2.2.0) rack (>= 1.3) - rackup (1.0.1) - rack (< 3) - webrick - rails (8.0.2.1) - actioncable (= 8.0.2.1) - actionmailbox (= 8.0.2.1) - actionmailer (= 8.0.2.1) - actionpack (= 8.0.2.1) - actiontext (= 8.0.2.1) - actionview (= 8.0.2.1) - activejob (= 8.0.2.1) - activemodel (= 8.0.2.1) - activerecord (= 8.0.2.1) - activestorage (= 8.0.2.1) - activesupport (= 8.0.2.1) + rackup (2.3.1) + rack (>= 3) + rails (8.0.5) + actioncable (= 8.0.5) + actionmailbox (= 8.0.5) + actionmailer (= 8.0.5) + actionpack (= 8.0.5) + actiontext (= 8.0.5) + actionview (= 8.0.5) + activejob (= 8.0.5) + activemodel (= 8.0.5) + activerecord (= 8.0.5) + activestorage (= 8.0.5) + activesupport (= 8.0.5) bundler (>= 1.15.0) - railties (= 8.0.2.1) + railties (= 8.0.5) rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.2) - loofah (~> 2.21) + rails-html-sanitizer (1.7.0) + loofah (~> 2.25) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (8.0.2.1) - actionpack (= 8.0.2.1) - activesupport (= 8.0.2.1) + railties (8.0.5) + actionpack (= 8.0.5) + activesupport (= 8.0.5) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) @@ -318,7 +327,7 @@ GEM zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.3.1) - rdoc (7.1.0) + rdoc (7.2.0) erb psych (>= 4.0.0) tsort @@ -357,6 +366,7 @@ GEM rack (>= 1.1) rubocop (>= 1.75.0, < 2.0) rubocop-ast (>= 1.44.0, < 2.0) + ruby-next-core (1.2.0) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) rubyzip (2.3.2) @@ -367,10 +377,12 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.2) - sinatra (2.2.3) - mustermann (~> 2.0) - rack (~> 2.2) - rack-protection (= 2.2.3) + sinatra (4.2.1) + logger (>= 1.6.0) + mustermann (~> 3.0) + rack (>= 3.0.0, < 4) + rack-protection (= 4.2.1) + rack-session (>= 2.0.0, < 3) tilt (~> 2.0) snaky_hash (2.0.3) hashie (>= 0.1.0, < 6) @@ -378,7 +390,7 @@ GEM stringio (3.2.0) thor (1.5.0) tilt (2.0.11) - timeout (0.6.0) + timeout (0.6.1) tomlrb (2.0.3) tsort (0.2.0) tzinfo (2.0.6) @@ -404,13 +416,14 @@ GEM with_env (1.1.0) xml-simple (1.1.9) rexml - yabeda (0.8.0) + yabeda (0.16.0) + anyway_config (>= 1.0, < 3) concurrent-ruby dry-initializer - yabeda-prometheus (0.6.1) - prometheus-client (>= 0.10, < 3.0) + yabeda-prometheus (0.9.1) + prometheus-client (>= 3.0, < 5.0) rack - yabeda (~> 0.5) + yabeda (~> 0.10) yabeda-puma-plugin (0.6.0) json puma @@ -437,17 +450,18 @@ DEPENDENCIES license_finder (~> 7.0.1) lograge message_bus + minitest-mock (~> 5.27) minitest-reporters minitest-stub-const mutex_m (~> 0.3.0) oauth2 pg (~> 1.6.2) - prometheus-client (~> 2.1.0) + prometheus-client (~> 4) pry-byebug pry-rails pry-rescue pry-stack_explorer - puma (~> 5.2) + puma (~> 6) que (~> 2.4.1) que-web rails (~> 8.0.2) @@ -460,7 +474,7 @@ DEPENDENCIES validate_url webmock webrick - yabeda-prometheus (~> 0.6.1) + yabeda-prometheus (~> 0.9) yabeda-puma-plugin yabeda-rails zeitwerk (~> 2.6.18) diff --git a/lib/prometheus/que_stats.rb b/lib/prometheus/que_stats.rb index ce707fdd..045877a9 100644 --- a/lib/prometheus/que_stats.rb +++ b/lib/prometheus/que_stats.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require 'prometheus/client/metric' require 'que/active_record/model' module Prometheus diff --git a/lib/puma/plugin/yabeda_prometheus.rb b/lib/puma/plugin/yabeda_prometheus.rb index 27100848..2cac8ad6 100644 --- a/lib/puma/plugin/yabeda_prometheus.rb +++ b/lib/puma/plugin/yabeda_prometheus.rb @@ -6,17 +6,16 @@ def start(launcher) options = launcher.options events = launcher.events + logger = launcher.log_writer host = options[:prometheus_host] || ENV['PROMETHEUS_EXPORTER_BIND'] || '0.0.0.0' port = options[:prometheus_port] || ENV['PROMETHEUS_EXPORTER_PORT'] || 9393 app = Yabeda::Prometheus::Exporter.rack_app - metrics = Puma::Server.new app, events - metrics.min_threads = 0 - metrics.max_threads = 1 + metrics = Puma::Server.new app, events, min_threads: 0, max_threads: 1 - events.log "* Starting metrics server on #{host}:#{port}" + logger.log "* Starting metrics server on #{host}:#{port}" metrics.add_tcp_listener host, port events.register(:state) do |state|