Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module ActionController
module Instrumentation
alias orig_process_action process_action
def process_action(*args)
ActiveSupport::ExecutionContext[:controller] = self if Rails.version.to_i >= 7

raw_payload = {
controller: self.class.name,
action: action_name,
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/logstasher/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ def subject.index(*_args)
end

describe '.process_action' do
if Rails.version.to_i >= 7
it 'sets the controller in ActiveSupport::ExecutionContext' do
expect(ActiveSupport::ExecutionContext).to receive(:[]=).with(:controller, subject)
subject.send(:process_action, :index)
end
else
it 'does not set the controller in ActiveSupport::ExecutionContext' do
expect(ActiveSupport::ExecutionContext).not_to receive(:[]=).with(:controller, anything)
subject.send(:process_action, :index)
end
end

it 'adds default fields to payload' do
expect(LogStasher).to receive(:add_default_fields_to_payload).once
expect(LogStasher).to receive(:add_default_fields_to_request_context).once
Expand Down