Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ const testData = {
},
mapping: {
topic: 'test-topic',
payload: { '@path': '$.' }
payload: { '@path': '$.' },
batch_bytes: 1000000
}
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ const action: ActionDefinition<Settings, Payload> = {
required: false,
multiple: true,
default: ['topic', 'partition', 'default_partition']
},
batch_bytes: {
type: 'number',
label: 'Batch Bytes',
description:
'The number of bytes to batch together. Default is 1MB. Maximum value varies by kafka cluster. The less you batch, the more requests will be sent to your Kafka cluster.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'The number of bytes to batch together. Default is 1MB. Maximum value varies by kafka cluster. The less you batch, the more requests will be sent to your Kafka cluster.',
"Specifies the maximum number of bytes to batch before sending. The default is 1 MB, though the maximum allowed depends on the Kafka cluster. Smaller batch sizes result in more frequent requests to the cluster.",

default: 1000000, // 1MB,
required: false,
minimum: 1,
unsafe_hidden: false
}
},
dynamicFields: {
Expand Down
11 changes: 6 additions & 5 deletions packages/destination-actions/src/destinations/kafka/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,10 @@ export const sendData = async (
groupedPayloads[topic].push(p)
set.add(`${topic}-${partition}-${default_partition}`)
})
if (statsContext) {
const { statsClient, tags } = statsContext
statsClient?.histogram('kafka.configurable_batch_keys.unique_keys', set.size, tags)
// Add stats to track batch keys for kafka
}
const statsClient = statsContext?.statsClient
const tags = statsContext?.tags
statsClient?.histogram('kafka.configurable_batch_keys.unique_keys', set.size, tags)
// Add stats to track batch keys for kafka

const topicMessages: TopicMessages[] = Object.keys(groupedPayloads).map((topic) => ({
topic,
Expand Down Expand Up @@ -250,6 +249,8 @@ export const sendData = async (

for (const data of topicMessages) {
try {
const batch_bytes = Buffer.byteLength(JSON.stringify(data.messages), 'utf8')
statsClient?.histogram('kafka.batch_bytes', batch_bytes, tags)
await producer.send(data as ProducerRecord)
} catch (error) {
const kafkaError = getKafkaError(error as Error)
Expand Down
Loading