Skip to content

Commit

Permalink
Use single block of initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
robertomiranda committed Sep 10, 2024
1 parent 6b1ddff commit bf44e90
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
1 change: 0 additions & 1 deletion lib/promenade/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class Configuration
def initialize
@rack_latency_buckets = DEFAULT_RACK_LATENCY_BUCKETS
@queue_time_buckets = DEFAULT_QUEUE_TIME_BUCKETS
@pitchfork_stats_enabled = false
end
end
end
12 changes: 4 additions & 8 deletions lib/promenade/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
require "promenade/client/rack/http_request_duration_collector"
require "promenade/client/rack/http_request_queue_time_collector"
require "promenade/yjit/middleware"
require "promenade/raindrops/middleware"
require "promenade/pitchfork/middleware"

module Promenade
class Railtie < ::Rails::Railtie
Expand All @@ -13,18 +15,12 @@ class Railtie < ::Rails::Railtie
Promenade::Client::Rack::HTTPRequestDurationCollector
Rails.application.config.middleware.insert 0,
Promenade::Client::Rack::HTTPRequestQueueTimeCollector
end

initializer "promenade.configure_middlewares", after: :load_config_initializers do
pitchfork_stats_enabled = false

if pitchfork_stats_enabled && defined?(::Raindrops)
require "promenade/raindrops/middleware"
if defined?(::Raindrops)
Rails.application.config.middleware.use Promenade::Raindrops::Middleware
end

if pitchfork_stats_enabled && defined?(::Pitchfork)
require "promenade/pitchfork/middleware"
if defined?(::Pitchfork)
Rails.application.config.middleware.use Promenade::Pitchfork::Middleware
end
end
Expand Down

0 comments on commit bf44e90

Please sign in to comment.