exq icon indicating copy to clipboard operation
exq copied to clipboard

Add job_id to Logger metadata for tracing

Open bluzky opened this issue 1 year ago • 1 comments

Hi,

I think it would be helpful to add job id to Logger metadata. So it would provide better log tracebility.

For example:

config :logger, :console,
  format: "$time $metadata[$level] $message\n",
  metadata: [:job_id]

produce log 13:13:00.120 job_id=8a762129-beff-4a2e-b9f6-35d1a1067581 [info] Time calculate pending orders - 0

and we can find all log that belongs to the same job

How do you think.

bluzky avatar Aug 22 '24 06:08 bluzky

Couple of things to do

  1. rename it to jid, which is what we use everywhere
  2. do the same on Exq.Middleware.Logger as well in the before_work, so all the logs from exq logger will also have the correct jid and would be useful to filter out the logs of a single job with structured logging

ananthakumaran avatar Aug 26 '24 05:08 ananthakumaran