mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Add prometheus_exporter gem and instrumentation to the project
This commit is contained in:
parent
8b3602523f
commit
055faac14f
5 changed files with 31 additions and 0 deletions
1
Gemfile
1
Gemfile
|
|
@ -6,6 +6,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|||
ruby File.read('.ruby-version').strip
|
||||
|
||||
gem 'bootsnap', require: false
|
||||
gem 'prometheus_exporter'
|
||||
gem 'chartkick'
|
||||
gem 'data_migrate'
|
||||
gem 'devise'
|
||||
|
|
|
|||
|
|
@ -233,6 +233,8 @@ GEM
|
|||
patience_diff (1.2.0)
|
||||
optimist (~> 3.0)
|
||||
pg (1.5.9)
|
||||
prometheus_exporter (2.1.1)
|
||||
webrick
|
||||
pry (0.14.2)
|
||||
coderay (~> 1.1)
|
||||
method_source (~> 1.0)
|
||||
|
|
@ -408,6 +410,7 @@ GEM
|
|||
addressable (>= 2.8.0)
|
||||
crack (>= 0.3.2)
|
||||
hashdiff (>= 0.4.0, < 2.0.0)
|
||||
webrick (1.9.0)
|
||||
websocket-driver (0.7.6)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
|
|
@ -441,6 +444,7 @@ DEPENDENCIES
|
|||
lograge
|
||||
oj
|
||||
pg
|
||||
prometheus_exporter
|
||||
pry-byebug
|
||||
pry-rails
|
||||
puma
|
||||
|
|
|
|||
15
config/initializers/prometheus.rb
Normal file
15
config/initializers/prometheus.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# in config/initializers/prometheus.rb
|
||||
if Rails.env != "test"
|
||||
require 'prometheus_exporter/middleware'
|
||||
|
||||
# This reports stats per request like HTTP status and timings
|
||||
Rails.application.middleware.unshift PrometheusExporter::Middleware
|
||||
end
|
||||
|
||||
if Rails.env != "test"
|
||||
require 'prometheus_exporter/instrumentation'
|
||||
|
||||
# this reports basic process stats like RSS and GC info, type master
|
||||
# means it is instrumenting the master process
|
||||
PrometheusExporter::Instrumentation::Process.start(type: "master")
|
||||
end
|
||||
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
Sidekiq.configure_server do |config|
|
||||
config.redis = { url: ENV['REDIS_URL'] }
|
||||
|
||||
config.server_middleware do |chain|
|
||||
require 'prometheus_exporter/instrumentation'
|
||||
chain.add PrometheusExporter::Instrumentation::Sidekiq
|
||||
end
|
||||
end
|
||||
|
||||
Sidekiq.configure_client do |config|
|
||||
|
|
|
|||
|
|
@ -41,3 +41,9 @@ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
|||
|
||||
# Allow puma to be restarted by `bin/rails restart` command.
|
||||
plugin :tmp_restart
|
||||
|
||||
# in unicorn/puma/passenger be sure to run a new process instrumenter after fork
|
||||
after_worker_boot do
|
||||
require 'prometheus_exporter/instrumentation'
|
||||
PrometheusExporter::Instrumentation::Process.start(type:"web")
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue