12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/datadog/tracing/contrib/qless/qless_job.rb', line 12
def around_perform(job)
return super unless datadog_configuration && Tracing.enabled?
Tracing.trace(Ext::SPAN_JOB, **span_options) do |span|
span.resource = job.klass_name
span.span_type = Tracing::Metadata::Ext::AppTypes::TYPE_WORKER
span.set_tag(Ext::TAG_JOB_ID, job.jid)
span.set_tag(Ext::TAG_JOB_QUEUE, job.queue_name)
tag_job_tags = datadog_configuration[:tag_job_tags]
span.set_tag(Ext::TAG_JOB_TAGS, job.tags) if tag_job_tags
tag_job_data = datadog_configuration[:tag_job_data]
if tag_job_data && !job.data.empty?
job_data = job.data.with_indifferent_access
formatted_data = job_data.except(:tags).map do |key, value|
"#{key}:#{value}".underscore
end
span.set_tag(Ext::TAG_JOB_DATA, formatted_data)
end
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)
span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_COMPONENT)
if Contrib::Analytics.enabled?(datadog_configuration[:analytics_enabled])
Contrib::Analytics.set_sample_rate(span, datadog_configuration[:analytics_sample_rate])
end
Contrib::Analytics.set_measured(span)
super
end
end
|