logstasher icon indicating copy to clipboard operation
logstasher copied to clipboard

Missing ActionContoller event fields due to `#process_action` monkey patch

Open avlazarov opened this issue 3 years ago • 2 comments
trafficstars

Hey!

I'm trying to get information about the request's headers after ActiveSupport::Notifications.subscribe 'process_action.action_controller', but the :headers key is missing from the event's payload. As far as I can see, this gem monkey patches ActionController::Instrumentation#process_action hence a few Rails generated fields will be missing: headers and request.

Could these extra fields be still visible for subscribers of the ActionController?

avlazarov avatar Dec 30 '21 09:12 avlazarov

@avlazarov good point - would you be able to create a PR ?

cc @petergoldstein

shadabahmed avatar Jan 20 '22 17:01 shadabahmed

@shadabahmed Sure, but before that I have a few questions about the current guards, namely:

https://github.com/shadabahmed/logstasher/blob/9de62bcca656ca76d1942c86478559909364efe3/lib/logstasher/rails_ext/action_controller/metal/instrumentation.rb#L11 https://github.com/shadabahmed/logstasher/blob/9de62bcca656ca76d1942c86478559909364efe3/lib/logstasher/rails_ext/action_controller/metal/instrumentation.rb#L13-L17

I've gone through all versions that this gem supports (Rails 5.2+) and none seem to be defensive about format and path:

Am I missing something or can I just use the instrumentation logic from Rails 7.0, without any guards?

avlazarov avatar Jan 24 '22 09:01 avlazarov