Class: LogStruct::Integrations::Sidekiq::JobContextMiddleware
- Inherits:
-
Object
- Object
- LogStruct::Integrations::Sidekiq::JobContextMiddleware
- Extended by:
- T::Sig
- Defined in:
- lib/log_struct/integrations/sidekiq/job_context_middleware.rb
Overview
Sidekiq server middleware that adds the running job's ID and class to every line
logged while it runs, in the same ctx field as Sidekiq's own log lines. A query
on ctx.jid then returns every line for one job run.
Instance Method Summary collapse
Instance Method Details
#call(job_instance, job_hash, queue, &block) ⇒ T.untyped
21 22 23 24 25 26 27 28 |
# File 'lib/log_struct/integrations/sidekiq/job_context_middleware.rb', line 21 def call(job_instance, job_hash, queue, &block) context = { jid: job_hash["jid"], # Same precedence as Sidekiq's own context, so ActiveJob jobs show their class class: job_hash["display_class"] || job_hash["wrapped"] || job_hash["class"] } ::SemanticLogger.named_tagged(sidekiq_context: context, &block) end |