diff --git a/Gemfile b/Gemfile index f31c2c9f7..6b9ef6bf2 100644 --- a/Gemfile +++ b/Gemfile @@ -40,8 +40,10 @@ gem "sentry-ruby" gem "sentry-rails" gem "rails_structured_logging", bc: "rails-structured-logging" gem "yabeda" -gem "prometheus-client-mmap", "~> 1.1" +gem "yabeda-rails" +gem "yabeda-puma-plugin" gem "yabeda-prometheus-mmap" +gem "prometheus-client-mmap", "~> 1.1" # AI gem "ruby_llm", git: "https://github.com/crmne/ruby_llm.git" diff --git a/Gemfile.lock b/Gemfile.lock index 2c1951297..8012aa2c3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -623,6 +623,15 @@ GEM yabeda-prometheus-mmap (0.4.0) prometheus-client-mmap yabeda (~> 0.10) + yabeda-puma-plugin (0.7.1) + json + puma + yabeda (~> 0.5) + yabeda-rails (0.10.0) + activesupport + anyway_config (>= 1.3, < 3) + railties + yabeda (~> 0.8) zeitwerk (2.7.3) PLATFORMS @@ -688,6 +697,8 @@ DEPENDENCIES webmock yabeda yabeda-prometheus-mmap + yabeda-puma-plugin + yabeda-rails BUNDLED WITH 2.7.0 diff --git a/config/initializers/yabeda.rb b/config/initializers/yabeda.rb index daa3a17dc..01362115a 100644 --- a/config/initializers/yabeda.rb +++ b/config/initializers/yabeda.rb @@ -2,6 +2,7 @@ require "prometheus/client/support/puma" Prometheus::Client.configuration.logger = Rails.logger Prometheus::Client.configuration.pid_provider = Prometheus::Client::Support::Puma.method(:worker_pid_provider) +Yabeda::Rails.config.controller_name_case = :camel require "yabeda/solid_queue" Yabeda::SolidQueue.install! diff --git a/config/puma.rb b/config/puma.rb index 774848880..7d17bcab0 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -22,3 +22,19 @@ plugin :tmp_restart # Run Solid Queue with Puma plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"] + +if ENV.fetch("PREFORK") { !Rails.env.local? } + on_worker_boot do + Yabeda::ActiveRecord.start_timed_metric_collection_task + Hey.deployment.start_timed_report_host_refresh + end + + # Expose prometheus metrics on port 9394 + activate_control_app + plugin :yabeda + plugin :yabeda_prometheus + + before_fork do + Process.warmup + end +end