-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(kafka): add datastreams monitoring support for kafkajs batches (#…
…4645) * Add DSM support for KafkaJS batch consume operation
- Loading branch information
1 parent
13243fc
commit fbcb8b6
Showing
4 changed files
with
107 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer') | ||
const { getMessageSize } = require('../../dd-trace/src/datastreams/processor') | ||
const { DsmPathwayCodec } = require('../../dd-trace/src/datastreams/pathway') | ||
|
||
class KafkajsBatchConsumerPlugin extends ConsumerPlugin { | ||
static get id () { return 'kafkajs' } | ||
static get operation () { return 'consume-batch' } | ||
|
||
start ({ topic, partition, messages, groupId }) { | ||
if (!this.config.dsmEnabled) return | ||
for (const message of messages) { | ||
if (!message || !message.headers || !DsmPathwayCodec.contextExists(message.headers)) continue | ||
const payloadSize = getMessageSize(message) | ||
this.tracer.decodeDataStreamsContext(message.headers) | ||
this.tracer | ||
.setCheckpoint(['direction:in', `group:${groupId}`, `topic:${topic}`, 'type:kafka'], null, payloadSize) | ||
} | ||
} | ||
} | ||
|
||
module.exports = KafkajsBatchConsumerPlugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters