Open andruby opened 7 years ago
+1
def add_custom_fields(&block)
wrapped_block = Proc.new do |fields|
LogStasher::CustomFields.add(*LogStasher.store.keys)
instance_exec(fields, &block)
end
::ActionController::Metal.send(:define_method, :logstasher_add_custom_fields_to_payload, &wrapped_block)
::ActionController::Base.send(:define_method, :logstasher_add_custom_fields_to_payload, &wrapped_block)
end
def add_custom_fields_to_request_context(&block)
wrapped_block = Proc.new do |fields|
instance_exec(fields, &block)
LogStasher::CustomFields.add(*fields.keys)
end
::ActionController::Metal.send(:define_method, :logstasher_add_custom_fields_to_request_context, &wrapped_block)
::ActionController::Base.send(:define_method, :logstasher_add_custom_fields_to_request_context, &wrapped_block)
end
someone can explain?
The only difference I see is that the add_custom_fields uses the request-store cache.
Any update on this?
I'm struggling in figuring out the difference between
LogStasher.add_custom_fields
andLogStasher.add_custom_fields_to_request_context
.The example in the Readme doesn't help explain the difference or when to use which. It seems to duplicate the block.
If I want to send some field to our logstash, do I use add_custom_fields or add_custom_fields_to_request_context?