module OpenTelemetry::Instrumentation::Que::Patches::QueJob::ClassMethods
def enqueue(*args, tags: nil, **arg_opts)
def enqueue(*args, tags: nil, **arg_opts) tracer = Que::Instrumentation.instance.tracer otel_config = Que::Instrumentation.instance.config tracer.in_span('send', kind: :producer) do |span| # Que doesn't have a good place to store metadata. There are # basically two options: the job payload and the job tags. # # Using the job payload is very brittle. We'd have to modify # existing Hash arguments or add a new argument when there are # no arguments we can modify. If the server side is not using # this instrumentation yet (e.g. old jobs before the # instrumentation was added or when instrumentation is being # added to client side first) then the server can error out due # to unexpected payload. # # The second option (which we are using here) is to use tags. # They also are not meant for tracing information but they are # much safer to use than modifying the payload. if otel_config[:propagation_style] != :none tags ||= [] OpenTelemetry.propagation.inject(tags, setter: TagSetter) end job = super(*args, tags: tags, **arg_opts) span.name = "#{job.que_attrs[:job_class]} send" span.add_attributes(QueJob.job_attributes(job)) job end end