Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass headers through to payload for logging. #24115

Merged
merged 1 commit into from
Mar 9, 2016
Merged

Pass headers through to payload for logging. #24115

merged 1 commit into from
Mar 9, 2016

Conversation

garethson
Copy link
Contributor

Summary

In attempting to log certain request headers the Rails way while still leveraging the output of ActionController::LogSubscriber's start_processing method, we realized we'd love to have the request headers in the event payload. This allows us to add header logging like this:

Started POST "/create" for 127.0.0.1 at 2016-03-09 03:14:49 +0000
Processing by RailsController#create as JSON
  Parameters: {"param_1"=>"A", "param_2"=> "B"}
  Headers: {"X-Platform-Id"=>"1", "X-Request-Id"=>"2"}
Application logic logging.
More application model logging.
Completed 200 OK in 108ms (Views: 3.1ms | ActiveRecord: 0.0ms)

via OurLogSubscriber.attach_to :action_controller.

Any other options I investigated involved completely replacing the default request logging.

@rafaelfranca

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @kaspth (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

Make request headers available in the event payload so that it is available to attached ActionController::LogSubscribers.
@kmcphillips
Copy link
Contributor

👍

rafaelfranca added a commit that referenced this pull request Mar 9, 2016
Pass headers through to payload for logging.
@rafaelfranca rafaelfranca merged commit 49e6d0a into rails:master Mar 9, 2016
@garethson garethson deleted the instrumentation-headers branch March 9, 2016 15:41
rafaelfranca added a commit that referenced this pull request Mar 9, 2016
y-yagi added a commit to y-yagi/rails that referenced this pull request Mar 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants