Skip to content

Commit c894085

Browse files
authored
[DSM] Add messaging.destination tag to spans so they show up in queue pages (#5239)
1 parent 213cbe1 commit c894085

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

packages/datadog-plugin-kafkajs/src/consumer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
77
const afterStartCh = dc.channel('dd-trace:kafkajs:consumer:afterStart')
88
const beforeFinishCh = dc.channel('dd-trace:kafkajs:consumer:beforeFinish')
99

10+
const MESSAGING_DESTINATION_KEY = 'messaging.destination.name'
11+
1012
class KafkajsConsumerPlugin extends ConsumerPlugin {
1113
static get id () { return 'kafkajs' }
1214
static get operation () { return 'consume' }
@@ -72,7 +74,8 @@ class KafkajsConsumerPlugin extends ConsumerPlugin {
7274
component: 'kafkajs',
7375
'kafka.topic': topic,
7476
'kafka.message.offset': message.offset,
75-
'kafka.cluster_id': clusterId
77+
'kafka.cluster_id': clusterId,
78+
[MESSAGING_DESTINATION_KEY]: topic
7679
},
7780
metrics: {
7881
'kafka.partition': partition

packages/datadog-plugin-kafkajs/src/producer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const { DsmPathwayCodec } = require('../../dd-trace/src/datastreams/pathway')
55
const { getMessageSize } = require('../../dd-trace/src/datastreams/processor')
66

77
const BOOTSTRAP_SERVERS_KEY = 'messaging.kafka.bootstrap.servers'
8+
const MESSAGING_DESTINATION_KEY = 'messaging.destination.name'
89

910
class KafkajsProducerPlugin extends ProducerPlugin {
1011
static get id () { return 'kafkajs' }
@@ -72,7 +73,8 @@ class KafkajsProducerPlugin extends ProducerPlugin {
7273
meta: {
7374
component: 'kafkajs',
7475
'kafka.topic': topic,
75-
'kafka.cluster_id': clusterId
76+
'kafka.cluster_id': clusterId,
77+
[MESSAGING_DESTINATION_KEY]: topic
7678
},
7779
metrics: {
7880
'kafka.batch_size': messages.length

packages/datadog-plugin-kafkajs/test/index.spec.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ describe('Plugin', () => {
7373
const meta = {
7474
'span.kind': 'producer',
7575
component: 'kafkajs',
76-
'pathway.hash': expectedProducerHash.readBigUInt64BE(0).toString()
76+
'pathway.hash': expectedProducerHash.readBigUInt64BE(0).toString(),
77+
'messaging.destination.name': 'test-topic',
78+
'messaging.kafka.bootstrap.servers': '127.0.0.1:9092'
7779
}
7880
if (clusterIdAvailable) meta['kafka.cluster_id'] = testKafkaClusterId
7981

@@ -182,7 +184,8 @@ describe('Plugin', () => {
182184
meta: {
183185
'span.kind': 'consumer',
184186
component: 'kafkajs',
185-
'pathway.hash': expectedConsumerHash.readBigUInt64BE(0).toString()
187+
'pathway.hash': expectedConsumerHash.readBigUInt64BE(0).toString(),
188+
'messaging.destination.name': 'test-topic'
186189
},
187190
resource: testTopic,
188191
error: 0,

0 commit comments

Comments
 (0)