Skip to content

Commit

Permalink
test railtie
Browse files Browse the repository at this point in the history
  • Loading branch information
KapustaB committed Mar 24, 2024
1 parent 93c2d32 commit f54110a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/treblle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'treblle/middleware'
require 'treblle/configuration'
require 'treblle/rails/treblle_railtie'
require 'treblle/rails/railtie'

# Treblle middleware for request interception and gathering.
module Treblle
Expand Down
1 change: 1 addition & 0 deletions lib/treblle/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def call_with_treblle_monitoring(env)
response = @app.call(env)
status, _headers, _rack_response = response

log_info("Treblle monitoring response status: #{status}")
handle_monitoring(env, response, started_at) if status < 400

response
Expand Down
3 changes: 1 addition & 2 deletions lib/treblle/rails/capture_exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def call(env)
response = @app.call(env)
status, _headers, _rack_response = response

handle_monitoring(env, response, started_at)
handle_monitoring(env, response, started_at) if status >= 400 && env["action_dispatch.exception"]
handle_monitoring(env, response, started_at) if status >= 400

response
end
Expand Down
7 changes: 3 additions & 4 deletions lib/treblle/rails/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
require 'rails'
require 'treblle/rails/capture_exceptions'
require 'rails'

module Treblle
module Rails
class TreblleRailtie < ::Rails::Railtie
initializer 'treblle_railtie.configure_rails_initialization' do |app|
Rails.logger.debug("debug::" + "TEST #{app.inspect}")
class Railtie < ::Rails::Railtie
initializer 'treblle.install_middleware' do |app|
app.config.middleware.insert_after ActionDispatch::ShowExceptions, Treblle::Rails::CaptureExceptions
end
end
Expand Down

0 comments on commit f54110a

Please sign in to comment.