File tree Expand file tree Collapse file tree
packages/datadog-plugin-kafkajs Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
77const afterStartCh = dc . channel ( 'dd-trace:kafkajs:consumer:afterStart' )
88const beforeFinishCh = dc . channel ( 'dd-trace:kafkajs:consumer:beforeFinish' )
99
10+ const MESSAGING_DESTINATION_KEY = 'messaging.destination.name'
11+
1012class 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
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const { DsmPathwayCodec } = require('../../dd-trace/src/datastreams/pathway')
55const { getMessageSize } = require ( '../../dd-trace/src/datastreams/processor' )
66
77const BOOTSTRAP_SERVERS_KEY = 'messaging.kafka.bootstrap.servers'
8+ const MESSAGING_DESTINATION_KEY = 'messaging.destination.name'
89
910class 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
Original file line number Diff line number Diff 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 ,
You can’t perform that action at this time.
0 commit comments