Allow log_tags to accept a hash

10 views
Skip to first unread message

Anthony Ross

unread,
Dec 17, 2019, 11:01:16 PM12/17/19
to Ruby on Rails: Core
Tagged loggers like ActiveSupport::TaggedLogger make logging both named and unnamed tags visible for better application debugging. Currently log_tags only supported an array of tags such as:


config.log_tags = [
  :remote_ip,
  ->(request) { some_computed_value }
]


However as this list gets long it has two issues:

1.  Parsing JSON logs requires positional references (ie remote_ip will
always be at some index)
2.  Some tags look similar and are hard to discern in a log message.
For example a datadog trace id and epoch time look indistinguishable to a
human reading those logs

I submitted https://github.com/rails/rails/pull/38009 as one solution

Reply all
Reply to author
Forward
0 new messages