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

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

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

SidekiqCommon is a mixin for the sidekiq middleware components

Instance Method Summary collapse

Instance Method Details

#job_class(job) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


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

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