Module: Labkit::Middleware::Sidekiq::Tracing::SidekiqCommon

Included in:
Client, Server
Defined in:
lib/labkit/middleware/sidekiq/tracing/sidekiq_common.rb

Overview

SidekiqCommon is a mixin for the sidekiq middleware components

Instance Method Summary collapse

Instance Method Details

#job_class(job) ⇒ Object



9
10
11
12
13
# File 'lib/labkit/middleware/sidekiq/tracing/sidekiq_common.rb', line 9

def job_class(job)
  # Active Job wrapping can be found at
  # https://github.com/rails/rails/blob/v6.0.3.1/activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb
  job["wrapped"].presence || job["class"].presence || "undefined"
end

#tags_from_job(job, kind) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/labkit/middleware/sidekiq/tracing/sidekiq_common.rb', line 19

def tags_from_job(job, kind)
  tags = {
    "component" => "sidekiq",
    "span.kind" => kind,
    "sidekiq.wrapped" => wrapped?(job),
    "sidekiq.queue" => job["queue"],
    "sidekiq.jid" => job["jid"],
    "sidekiq.retry" => job["retry"].to_s,
    "sidekiq.args" => job["args"]&.join(", "),
  }
  tags["sidekiq.at"] = job["at"] if job["at"]
  tags
end

#wrapped?(job) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/labkit/middleware/sidekiq/tracing/sidekiq_common.rb', line 15

def wrapped?(job)
  job["wrapped"].present?
end