Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds span.kind tag for que, shoryuken, sneakers, and resque #2394

Merged
merged 2 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/datadog/tracing/contrib/que/tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def call(job)
request_span.set_tag(Ext::TAG_JOB_ARGS, job.que_attrs[:args]) if configuration[:tag_args]
request_span.set_tag(Ext::TAG_JOB_DATA, job.que_attrs[:data]) if configuration[:tag_data]

request_span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CONSUMER)

set_sample_rate(request_span)
Contrib::Analytics.set_measured(request_span)

Expand Down
2 changes: 2 additions & 0 deletions lib/datadog/tracing/contrib/resque/resque_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def around_perform0_ddtrace(*args)
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])
Expand Down
2 changes: 2 additions & 0 deletions lib/datadog/tracing/contrib/shoryuken/tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def call(worker_instance, queue, sqs_msg, body)
span.set_tag(Ext::TAG_JOB_ATTRIBUTES, sqs_msg.attributes) if sqs_msg.respond_to?(:attributes)
span.set_tag(Ext::TAG_JOB_BODY, body) if configuration[:tag_body]

span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CONSUMER)

yield
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/datadog/tracing/contrib/sneakers/tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def call(deserialized_msg, delivery_info, metadata, handler)

request_span.set_tag(Ext::TAG_JOB_BODY, deserialized_msg) if configuration[:tag_body]

request_span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CONSUMER)

@app.call(deserialized_msg, delivery_info, metadata, handler)
end
end
Expand Down
6 changes: 6 additions & 0 deletions spec/datadog/tracing/contrib/que/tracer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ def run(*_args)
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::Errors::TAG_TYPE)).to eq('StandardError')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::Errors::TAG_STACK)).not_to be_nil
end

it 'has span.kind tag with value consumer' do
enqueue

expect(span.get_tag('span.kind')).to eq('consumer')
end
end

context 'with tag_args enabled' do
Expand Down
2 changes: 2 additions & 0 deletions spec/datadog/tracing/contrib/resque/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def perform_job(klass, *args)
expect(span).to_not have_error
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('resque')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION)).to eq('job')
expect(span.get_tag('span.kind')).to eq('consumer')
end

it_behaves_like 'analytics for integration' do
Expand Down Expand Up @@ -119,6 +120,7 @@ def perform_job(klass, *args)
expect(span).to have_error_type(error_class_name)
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('resque')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION)).to eq('job')
expect(span.get_tag('span.kind')).to eq('consumer')
end

context 'with custom error handler' do
Expand Down
1 change: 1 addition & 0 deletions spec/datadog/tracing/contrib/shoryuken/tracer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def perform(sqs_msg, body); end
expect(span.get_tag(Datadog::Tracing::Contrib::Shoryuken::Ext::TAG_JOB_ATTRIBUTES)).to eq(attributes.to_s)
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('shoryuken')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION)).to eq('job')
expect(span.get_tag('span.kind')).to eq('consumer')
end

it_behaves_like 'analytics for integration' do
Expand Down
1 change: 1 addition & 0 deletions spec/datadog/tracing/contrib/sneakers/tracer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def work_with_params(_msg, _delivery_info, _metadata)
expect(span.get_tag(Datadog::Tracing::Contrib::Sneakers::Ext::TAG_JOB_QUEUE)).to eq(queue_name)
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('sneakers')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION)).to eq('job')
expect(span.get_tag('span.kind')).to eq('consumer')
end

context 'when the tag_body is true' do
Expand Down