Class: Logsy::SidekiqMiddleware::Server
- Inherits:
-
Object
- Object
- Logsy::SidekiqMiddleware::Server
- Defined in:
- lib/logsy/sidekiq_middleware/server.rb
Overview
Server-side middleware: reads propagated tags back from the job payload, sets them on the per-job Logsy store, sets job_id from Sidekiq’s ‘jid` and job_class from the worker (the wrapped ActiveJob class name when run through ActiveJob), and resets the store after the job runs (even on error) so tags don’t leak between jobs sharing a worker thread.
Anything the job code writes via ‘Logsy = bar` while running will appear on every log line emitted during the job.
Instance Method Summary collapse
Instance Method Details
#call(_worker_instance, job, _queue) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/logsy/sidekiq_middleware/server.rb', line 15 def call(_worker_instance, job, _queue) Logsy[:job_id] = job['jid'] Logsy[:job_class] = job['wrapped'] || job['class'] Logsy.configuration.job_propagated_keys.each do |key| value = job[key.to_s] Logsy[key] = value if value end yield ensure Logsy.reset end |