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

Add messaging.system tag to all messaging integrations #2590

Merged
merged 1 commit into from
Feb 8, 2023
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
4 changes: 4 additions & 0 deletions lib/datadog/tracing/contrib/delayed_job/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def self.instrument_invoke(job, &block)

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)

yield job
end
end
Expand All @@ -63,6 +65,8 @@ def self.instrument_enqueue(job, &block)

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

span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_COMPONENT)

yield job
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def reserve_job
Datadog::Tracing.trace(Ext::SPAN_RESERVE_JOB, service: configuration[:service_name]) do |span|
span.span_type = Datadog::Tracing::Metadata::Ext::AppTypes::TYPE_WORKER

span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_COMPONENT)

span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_RESERVE_JOB)

Expand Down
4 changes: 4 additions & 0 deletions lib/datadog/tracing/contrib/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ module RPC
TAG_SERVICE = 'rpc.service'
TAG_METHOD = 'rpc.method'
end

module Messaging
TAG_SYSTEM = 'messaging.system'
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/datadog/tracing/contrib/kafka/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def configuration

def process(span, _event, _id, payload)
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_MESSAGING_SYSTEM)

span.set_tag(Ext::TAG_CLIENT, payload[:client_id])

Expand Down
1 change: 1 addition & 0 deletions lib/datadog/tracing/contrib/kafka/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module Ext
TAG_OPERATION_PROCESS_BATCH = 'consumer.process_batch'.freeze
TAG_OPERATION_PROCESS_MESSAGE = 'consumer.process_message'.freeze
TAG_OPERATION_SEND_MESSAGES = 'producer.send_messages'.freeze
TAG_MESSAGING_SYSTEM = 'kafka'.freeze
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/datadog/tracing/contrib/qless/qless_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def around_perform(job)
return super unless datadog_configuration && Tracing.enabled?

Tracing.trace(Ext::SPAN_JOB, **span_options) do |span|
span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_COMPONENT)

span.resource = job.klass_name
span.span_type = Tracing::Metadata::Ext::AppTypes::TYPE_WORKER
span.set_tag(Ext::TAG_JOB_ID, job.jid)
Expand Down
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 @@ -18,6 +18,8 @@ def call(job)
}

Tracing.trace(Ext::SPAN_JOB, **trace_options) do |request_span|
request_span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_COMPONENT)

request_span.resource = job.class.name.to_s

request_span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
Expand Down
1 change: 1 addition & 0 deletions lib/datadog/tracing/contrib/racecar/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def process(span, event, _id, payload)
span.service = configuration[:service_name]
span.resource = payload[:consumer_class]

span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_MESSAGING_SYSTEM)
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)

# Tag as an external peer service
Expand Down
1 change: 1 addition & 0 deletions lib/datadog/tracing/contrib/racecar/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module Ext
TAG_OPERATION_CONSUME = 'consume'.freeze
TAG_OPERATION_BATCH = 'batch'.freeze
TAG_OPERATION_MESSAGE = 'message'.freeze
TAG_MESSAGING_SYSTEM = 'kafka'.freeze
end
end
end
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 @@ -38,6 +38,8 @@ def around_perform0_ddtrace(*args)
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)

Expand Down
1 change: 1 addition & 0 deletions lib/datadog/tracing/contrib/shoryuken/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module Ext
TAG_JOB_BODY = 'shoryuken.body'.freeze
TAG_COMPONENT = 'shoryuken'.freeze
TAG_OPERATION_JOB = 'job'.freeze
TAG_MESSAGING_SYSTEM = 'amazonsqs'.freeze
end
end
end
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 @@ -20,6 +20,8 @@ def call(worker_instance, queue, sqs_msg, body)
span_type: Tracing::Metadata::Ext::AppTypes::TYPE_WORKER,
on_error: @error_handler
) do |span|
span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_MESSAGING_SYSTEM)

span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_JOB)

Expand Down
2 changes: 2 additions & 0 deletions lib/datadog/tracing/contrib/sidekiq/client_tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def call(worker_class, job, queue, redis_pool)
Datadog::Tracing.trace(Ext::SPAN_PUSH, service: @sidekiq_service) do |span|
span.resource = resource

span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_COMPONENT)

span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_PUSH)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def stop
Datadog::Tracing.trace(Ext::SPAN_STOP, service: configuration[:service_name]) do |span|
span.span_type = Datadog::Tracing::Metadata::Ext::AppTypes::TYPE_WORKER

span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_COMPONENT)

span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_STOP)

Expand All @@ -33,6 +35,8 @@ def heartbeat
Datadog::Tracing.trace(Ext::SPAN_HEARTBEAT, service: configuration[:service_name]) do |span|
span.span_type = Datadog::Tracing::Metadata::Ext::AppTypes::TYPE_WORKER

span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_COMPONENT)

span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_HEARTBEAT)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def fetch
Datadog::Tracing.trace(Ext::SPAN_JOB_FETCH, service: configuration[:service_name]) do |span|
span.span_type = Datadog::Tracing::Metadata::Ext::AppTypes::TYPE_WORKER

span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_COMPONENT)

span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_JOB_FETCH)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def redis_info
Datadog::Tracing.trace(Ext::SPAN_REDIS_INFO, service: configuration[:service_name]) do |span|
span.span_type = Datadog::Tracing::Metadata::Ext::AppTypes::TYPE_WORKER

span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_COMPONENT)

span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_REDIS_INFO)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def enqueue
Datadog::Tracing.trace(Ext::SPAN_SCHEDULED_PUSH, service: configuration[:service_name]) do |span|
span.span_type = Datadog::Tracing::Metadata::Ext::AppTypes::TYPE_WORKER

span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_COMPONENT)

span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_SCHEDULED_PUSH)

Expand All @@ -34,6 +36,8 @@ def wait
Datadog::Tracing.trace(Ext::SPAN_SCHEDULED_WAIT, service: configuration[:service_name]) do |span|
span.span_type = Datadog::Tracing::Metadata::Ext::AppTypes::TYPE_WORKER

span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_COMPONENT)

span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_SCHEDULED_WAIT)

Expand Down
2 changes: 2 additions & 0 deletions lib/datadog/tracing/contrib/sidekiq/server_tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def call(worker, job, queue)
) do |span|
span.resource = resource

span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_COMPONENT)

span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_JOB)

Expand Down
1 change: 1 addition & 0 deletions lib/datadog/tracing/contrib/sneakers/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module Ext
TAG_JOB_BODY = 'sneakers.body'
TAG_COMPONENT = 'sneakers'
TAG_OPERATION_JOB = 'job'
TAG_MESSAGING_SYSTEM = 'rabbitmq'
end
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 @@ -24,6 +24,8 @@ def call(deserialized_msg, delivery_info, metadata, handler)
}

Tracing.trace(Ext::SPAN_JOB, **trace_options) do |request_span|
request_span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_MESSAGING_SYSTEM)

request_span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
request_span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_JOB)

Expand Down
12 changes: 12 additions & 0 deletions spec/datadog/tracing/contrib/delayed_job/plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def job_data
expect(span.resource).to eq('UnderlyingJobClass')
expect(enqueue_span.resource).to eq('UnderlyingJobClass')
end

it 'has messaging system tag set correctly' do
expect(span.get_tag('messaging.system')).to eq('delayed_job')
end
end

context 'when job fails' do
Expand Down Expand Up @@ -128,6 +132,10 @@ def perform
expect(span.get_tag('delayed_job.queue')).to be_nil
end

it 'has messaging system tag set correctly' do
expect(span.get_tag('messaging.system')).to eq('delayed_job')
end

context 'when queue name is set' do
let(:queue_name) { 'queue_name' }
let(:job_params) { { queue: queue_name } }
Expand Down Expand Up @@ -247,6 +255,10 @@ def perform
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION))
.to eq(Datadog::Tracing::Contrib::DelayedJob::Ext::TAG_OPERATION_RESERVE_JOB)
end

it 'has messaging system tag set correctly' do
expect(span.get_tag('messaging.system')).to eq('delayed_job')
end
end
end
end
18 changes: 18 additions & 0 deletions spec/datadog/tracing/contrib/kafka/patcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
expect(span).to_not have_error
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('kafka')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION)).to eq('connection.request')
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand All @@ -82,6 +83,7 @@
expect(span.get_tag('kafka.request_size')).to eq(request_size)
expect(span.get_tag('kafka.response_size')).to eq(response_size)
expect(span).to have_error
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand Down Expand Up @@ -138,6 +140,7 @@
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('kafka')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION)).to eq('consumer.process_batch')
expect(span.get_tag('span.kind')).to eq('consumer')
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand Down Expand Up @@ -169,6 +172,7 @@
expect(span.get_tag('kafka.offset_lag')).to eq(offset_lag)
expect(span).to have_error
expect(span.get_tag('span.kind')).to eq('consumer')
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand Down Expand Up @@ -225,6 +229,7 @@
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('kafka')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION)).to eq('consumer.process_message')
expect(span.get_tag('span.kind')).to eq('consumer')
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand Down Expand Up @@ -256,6 +261,7 @@
expect(span.get_tag('kafka.offset_lag')).to eq(offset_lag)
expect(span).to have_error
expect(span.get_tag('span.kind')).to eq('consumer')
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand Down Expand Up @@ -305,6 +311,7 @@
expect(span).to_not have_error
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('kafka')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION)).to eq('consumer.heartbeat')
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand Down Expand Up @@ -332,6 +339,7 @@
expect(span.get_tag('kafka.topic_partitions.foo')).to eq(topic_partitions['foo'].to_s)
expect(span.get_tag('kafka.topic_partitions.bar')).to eq(topic_partitions['bar'].to_s)
expect(span).to have_error
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand Down Expand Up @@ -372,6 +380,7 @@
expect(span).to_not have_error
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('kafka')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION)).to eq('consumer.join_group')
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand All @@ -397,6 +406,7 @@
expect(span.get_tag('kafka.client')).to eq(client_id)
expect(span.get_tag('kafka.group')).to eq(group_id)
expect(span).to have_error
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand Down Expand Up @@ -437,6 +447,7 @@
expect(span).to_not have_error
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('kafka')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION)).to eq('consumer.leave_group')
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand All @@ -462,6 +473,7 @@
expect(span.get_tag('kafka.client')).to eq(client_id)
expect(span.get_tag('kafka.group')).to eq(group_id)
expect(span).to have_error
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand Down Expand Up @@ -502,6 +514,7 @@
expect(span).to_not have_error
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('kafka')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION)).to eq('consumer.sync_group')
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand All @@ -527,6 +540,7 @@
expect(span.get_tag('kafka.client')).to eq(client_id)
expect(span.get_tag('kafka.group')).to eq(group_id)
expect(span).to have_error
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand Down Expand Up @@ -571,6 +585,7 @@
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('kafka')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION)).to eq('producer.send_messages')
expect(span.get_tag('span.kind')).to eq('producer')
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand Down Expand Up @@ -598,6 +613,7 @@
expect(span.get_tag('kafka.sent_message_count')).to eq(sent_message_count)
expect(span).to have_error
expect(span.get_tag('span.kind')).to eq('producer')
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand Down Expand Up @@ -645,6 +661,7 @@
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('kafka')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION)).to eq('producer.deliver_messages')
expect(span.get_tag('span.kind')).to eq('producer')
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand Down Expand Up @@ -673,6 +690,7 @@
expect(span.get_tag('kafka.delivered_message_count')).to eq(delivered_message_count)
expect(span).to have_error
expect(span.get_tag('span.kind')).to eq('producer')
expect(span.get_tag('messaging.system')).to eq('kafka')
end
end
end
Expand Down
Loading