shadabahmed / logstasher

Awesome rails logs
MIT License
817 stars 136 forks source link

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

Open avlazarov opened 2 years ago

avlazarov commented 2 years ago

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?

shadabahmed commented 2 years ago

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

cc @petergoldstein

avlazarov commented 2 years ago

@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?