Skip to content

make sidekiq.job as a child for the sidekiq.publish span #1273

Open
@bolahanna44

Description

the context is not being propagated from sidekiq publish to sidekiq job

Share details about your runtime

Operating system details: Linux, Ubuntu 20.04 LTS
RUBY_ENGINE: "ruby"
RUBY_VERSION: "3.3.0"
RUBY_DESCRIPTION: "ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]"

Share a simplified reproduction if possible

initializer/otel.rb

require 'opentelemetry/sdk'
require 'opentelemetry/instrumentation/all'
require 'opentelemetry/exporter/jaeger'

ENV["OTEL_TRACES_EXPORTER"] ||= "console"

OpenTelemetry::SDK.configure do |c|
  c.use_all({
    'OpenTelemetry::Instrumentation::Sidekiq' => {
      span_naming: :job_class,
      propagation_style: :child,
      trace_poller_wait: true,
      trace_poller_enqueue: true,
      trace_processor_process_one: true,
    },
  })
  c.service_name = "test-otel"
  c.add_span_processor(
    OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
      # OpenTelemetry::Exporter::Jaeger::AgentExporter.new(
      #   host: 'localhost',
      #   port: '6831'
      # )
      OpenTelemetry::Exporter::Jaeger::CollectorExporter.new(endpoint: 'http://localhost:14268/api/traces')
    )
  )
end

controllers/enqueue_controller.rb

class EnqueueController < ApplicationController
  def create
    MyJob.perform_in(2.seconds, 'bob', 5)
    render plain: OpenTelemetry::Trace.current_span.context.trace_id.unpack1('H*')
  end
end

and here i can see sidekiq publish job
Screenshot 2024-11-28 at 11 37 24 PM

and here is the sidekiq job in a separate trace

Screenshot 2024-11-29 at 2 01 20 AM

my question is: how i can have sidekiq job in the 2nd photo as a child span for sidekiq publish job in the 1st photo ?

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions