Class: Instana::Exporter::Otlp::BackgroundJobConverter

Inherits:
BaseConverter
  • Object
show all
Defined in:
lib/instana/exporter/otlp/background_job_converter.rb

Instance Method Summary collapse

Methods inherited from BaseConverter

#convert, #initialize

Constructor Details

This class inherits a constructor from Instana::Exporter::Otlp::BaseConverter

Instance Method Details

#convert_attributesObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/instana/exporter/otlp/background_job_converter.rb', line 32

def convert_attributes
  attributes = {}
  span_type  = span[:n].to_s

  if span_type == 'sidekiq-client' # rubocop:disable Style/CaseLikeIf
    convert_job_attributes(attributes, span[:'sidekiq-client'] || span[:data]&.[](:'sidekiq-client'), 'sidekiq', 'publish')
  elsif span_type == 'sidekiq-worker'
    convert_job_attributes(attributes, span[:'sidekiq-worker'] || span[:data]&.[](:'sidekiq-worker'), 'sidekiq', 'process')
  elsif span_type == 'resque-client'
    convert_job_attributes(attributes, span[:'resque-client'] || span[:data]&.[](:'resque-client'), 'resque', 'publish')
  elsif span_type == 'resque-worker'
    convert_job_attributes(attributes, span[:'resque-worker'] || span[:data]&.[](:'resque-worker'), 'resque', 'process')
  end

  attributes
end

#span_nameString

Build OTel-compliant span name for background-job spans

Formula per SPAN_NAME_PATTERNS.txt Section 3 (sidekiq / resque):

client/producer → "{queue} publish"
worker/consumer → "{queue} process"

Returns:

  • (String)

    The span name



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/instana/exporter/otlp/background_job_converter.rb', line 20

def span_name
  span_type = span[:n].to_s
  data_key  = span_type.to_sym
  job_data  = span[data_key] || span[:data]&.[](data_key) || {}

  queue = job_data[:queue] || job_data['queue']
  queue = queue.to_s.strip

  operation = span_type.end_with?('-client') ? 'publish' : 'process'
  queue.empty? ? operation : "#{queue} #{operation}"
end