module Datadog::Tracing::Contrib::Resque::ResqueJob

def around_perform0_ddtrace(*args)

own method.
We could also just use `around_perform` but this might override the user's

to unreadable stack traces that contain this method call.
We could, in theory, use any character (e.g "\x00"), but this will lead

method definition ('0'), alongside our naming prefix for identification.
we use the lowest printable character that allows for an inline
`around_perform` hooks are executed in alphabetical order.
def around_perform0_ddtrace(*args)
  return yield unless datadog_configuration && Tracing.enabled?
  Tracing.trace(Ext::SPAN_JOB, **span_options) do |span|
    span.resource = args.first.is_a?(Hash) && args.first['job_class'] || name
    span.span_type = Tracing::Metadata::Ext::AppTypes::TYPE_WORKER
    span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_COMPONENT)
    span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
    span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_JOB)
    span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CONSUMER)
    # Set analytics sample rate
    if Contrib::Analytics.enabled?(datadog_configuration[:analytics_enabled])
      Contrib::Analytics.set_sample_rate(span, datadog_configuration[:analytics_sample_rate])
    end
    # Measure service stats
    Contrib::Analytics.set_measured(span)
    yield
  end
end