Skip to content

Logging after action has been processed. #144

@braindeaf

Description

@braindeaf

It would appear according to lib/logstasher/rails_ext/action_controller/metal/instrumentation.rb
That the two locations where the payload is appended to occur before the action is processed. Can you clarify how they then differ from one another.

The downside to this is that something that occurs within the action cannot be appended to the log, e.g. logging a user in, or the changed state of an order, etc. Shouldn't :logstasher_add_custom_fields_to_payload be after the process_action?

` if self.respond_to?(:logstasher_add_custom_fields_to_request_context)
logstasher_add_custom_fields_to_request_context(LogStasher.request_context)
end

    if self.respond_to?(:logstasher_add_custom_fields_to_payload)
      before_keys = raw_payload.keys.clone
      logstasher_add_custom_fields_to_payload(raw_payload)
      after_keys = raw_payload.keys
      # Store all extra keys added to payload hash in payload itself. This is a thread safe way
      LogStasher::CustomFields.add(*(after_keys - before_keys))
    end

    result = super

`

Also the method call 'append_info_to_payload(payload)' after the request has been processed seems to duplicate the same logic which is confusing.

Can you clarify?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions