Skip to content

feat(kafkajs): instrument producer.sendBatch#8403

Merged
BridgeAR merged 6 commits into
masterfrom
BridgeAR/2026-05-10-kafkajs-send-batch
May 26, 2026
Merged

feat(kafkajs): instrument producer.sendBatch#8403
BridgeAR merged 6 commits into
masterfrom
BridgeAR/2026-05-10-kafkajs-send-batch

Conversation

@BridgeAR

Copy link
Copy Markdown
Member

Summary

The kafkajs producer.sendBatch API was uninstrumented — calls produced no spans, propagated no trace context, and emitted no DSM checkpoints. This adds tracing, header injection, and DSM checkpoints, modeled as one kafka.produce span per topicMessages[] entry (mirrors what producer.send already emits for the single-topic case and how kafkajs decomposes send into sendBatch internally).

Fixes: #1711

@github-actions

github-actions Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 5.86 MB
Deduped: 6.9 MB
No deduping: 6.9 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.1 | 82.56 kB | 817.39 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@datadog-official

datadog-official Bot commented May 10, 2026

Copy link
Copy Markdown

Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

❄️ 1 New flaky test detected

Plugin kafkajs with kafkajs >=1.4 (2.2.4) without configuration producer (sendBatch) when broker rejects headers with UNKNOWN_SERVER_ERROR disables header injection for later sendBatch calls from when broker rejects headers with UNKNOWN_SERVER_ERROR   View in Datadog (Fix with Cursor)
This server is not the leader for that topic-partition

KafkaJSNonRetriableError
  Caused by: KafkaJSProtocolError: This server is not the leader for that topic-partition
    at createErrorFromCode (versions/kafkajs@>=1.4/node_modules/kafkajs/src/protocol/error.js:581:10)
    at Object.parse (versions/kafkajs@>=1.4/node_modules/kafkajs/src/protocol/requests/produce/v3/response.js:45:11)
    at Connection.send (versions/kafkajs@>=1.4/node_modules/kafkajs/src/network/connection.js:433:35)
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
    at async [private:Broker:sendRequest] (versions/kafkajs@>=1.4/node_modules/kafkajs/src/broker/index.js:904:14)
    at async Broker.produce (versions/kafkajs@>=1.4/node_modules/kafkajs/src/broker/index.js:241:12)
...

New test introduced in this PR is flaky.

View in Flaky Test Management

ℹ️ Info

No other issues found (see more)

🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 86.39% (+0.03%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: a3841e8 | Docs | Datadog PR Page | Give us feedback!

@codecov

codecov Bot commented May 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.08%. Comparing base (4b3a0f0) to head (a3841e8).
⚠️ Report is 16 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8403      +/-   ##
==========================================
+ Coverage   93.06%   93.08%   +0.01%     
==========================================
  Files         847      847              
  Lines       47193    47247      +54     
  Branches     8518     8526       +8     
==========================================
+ Hits        43921    43978      +57     
+ Misses       3272     3269       -3     
Flag Coverage Δ
aiguard-integration-active 41.25% <ø> (ø)
aiguard-integration-latest 41.20% <ø> (ø)
aiguard-integration-maintenance 41.25% <ø> (ø)
aiguard-macos 33.56% <ø> (-0.08%) ⬇️
aiguard-ubuntu ?
aiguard-windows 33.37% <ø> (-0.08%) ⬇️
apm-capabilities-tracing-macos 47.98% <0.00%> (?)
apm-capabilities-tracing-ubuntu-active 48.19% <0.00%> (-0.01%) ⬇️
apm-capabilities-tracing-ubuntu-latest 47.98% <0.00%> (-0.01%) ⬇️
apm-capabilities-tracing-ubuntu-maintenance 48.00% <0.00%> (-0.01%) ⬇️
apm-capabilities-tracing-ubuntu-oldest 48.00% <0.00%> (-0.01%) ⬇️
apm-capabilities-tracing-windows 47.97% <0.00%> (+0.04%) ⬆️
apm-integrations-aerospike-18-gte.5.2.0 33.26% <ø> (-0.08%) ⬇️
apm-integrations-aerospike-20-gte.5.5.0 33.29% <ø> (-0.08%) ⬇️
apm-integrations-aerospike-22-gte.5.12.1 33.29% <ø> (-0.08%) ⬇️
apm-integrations-aerospike-22-gte.6.0.0 33.29% <ø> (-0.08%) ⬇️
apm-integrations-aerospike-eol- 33.19% <ø> (-0.08%) ⬇️
apm-integrations-child-process 34.13% <ø> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript-18 40.36% <100.00%> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript-20 40.38% <100.00%> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript-22 40.38% <100.00%> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript-24 40.33% <100.00%> (-0.08%) ⬇️
apm-integrations-couchbase-18 33.28% <ø> (-0.08%) ⬇️
apm-integrations-couchbase-eol 33.29% <ø> (-0.08%) ⬇️
apm-integrations-dns 32.99% <ø> (-0.08%) ⬇️
apm-integrations-elasticsearch 34.20% <ø> (-0.08%) ⬇️
apm-integrations-http-latest 41.47% <ø> (-0.07%) ⬇️
apm-integrations-http-maintenance 41.51% <ø> (-0.07%) ⬇️
apm-integrations-http-oldest 41.52% <ø> (-0.07%) ⬇️
apm-integrations-http2 38.57% <ø> (-0.08%) ⬇️
apm-integrations-kafkajs-latest 40.33% <88.52%> (+0.12%) ⬆️
apm-integrations-kafkajs-oldest 40.37% <88.52%> (-0.02%) ⬇️
apm-integrations-net 33.90% <ø> (-0.08%) ⬇️
apm-integrations-next-11.1.4 27.94% <ø> (-0.07%) ⬇️
apm-integrations-next-12.3.7 29.50% <ø> (-0.08%) ⬇️
apm-integrations-next-13.0.0 29.46% <ø> (-0.08%) ⬇️
apm-integrations-next-13.2.0 29.46% <ø> (-0.08%) ⬇️
apm-integrations-next-13.5.11 29.60% <ø> (-0.08%) ⬇️
apm-integrations-next-14.0.0 29.53% <ø> (-0.12%) ⬇️
apm-integrations-next-14.2.35 29.53% <ø> (-0.08%) ⬇️
apm-integrations-next-14.2.6 29.53% <ø> (-0.08%) ⬇️
apm-integrations-next-14.2.7 29.53% <ø> (-0.08%) ⬇️
apm-integrations-next-15.0.0 29.53% <ø> (-0.08%) ⬇️
apm-integrations-next-15.4.0 29.60% <ø> (-0.08%) ⬇️
apm-integrations-oracledb 33.67% <ø> (-0.08%) ⬇️
apm-integrations-prisma-18-gte.6.16.0.and.lt.7.0.0 ?
apm-integrations-prisma-latest-all 34.55% <ø> (-0.08%) ⬇️
apm-integrations-restify 35.43% <ø> (-0.08%) ⬇️
apm-integrations-sharedb 32.66% <ø> (-0.08%) ⬇️
apm-integrations-tedious 33.48% <ø> (-0.08%) ⬇️
appsec-express 51.60% <ø> (-0.05%) ⬇️
appsec-fastify 48.23% <ø> (-0.06%) ⬇️
appsec-graphql 48.23% <ø> (-0.06%) ⬇️
appsec-integration-active 37.01% <0.00%> (-0.07%) ⬇️
appsec-integration-latest 36.99% <0.00%> (-0.07%) ⬇️
appsec-integration-maintenance 37.02% <0.00%> (-0.07%) ⬇️
appsec-integration-oldest 37.02% <0.00%> (-0.07%) ⬇️
appsec-kafka 40.75% <13.11%> (-0.17%) ⬇️
appsec-ldapjs 40.03% <ø> (-0.07%) ⬇️
appsec-lodash 40.13% <ø> (-0.07%) ⬇️
appsec-macos 57.70% <ø> (-0.06%) ⬇️
appsec-mongodb-core 44.74% <ø> (-0.07%) ⬇️
appsec-mongoose 45.60% <ø> (-0.06%) ⬇️
appsec-mysql 47.53% <ø> (-0.11%) ⬇️
appsec-next-latest-11.1.4 27.95% <ø> (-0.08%) ⬇️
appsec-next-latest-12.3.7 29.51% <ø> (-0.08%) ⬇️
appsec-next-latest-13.0.0 29.51% <ø> (-0.08%) ⬇️
appsec-next-latest-13.2.0 29.54% <ø> (-0.08%) ⬇️
appsec-next-latest-13.5.11 29.64% <ø> (-0.08%) ⬇️
appsec-next-latest-14.0.0 29.56% <ø> (-0.08%) ⬇️
appsec-next-latest-14.2.35 29.56% <ø> (-0.08%) ⬇️
appsec-next-latest-14.2.6 29.56% <ø> (-0.08%) ⬇️
appsec-next-latest-14.2.7 29.56% <ø> (-0.08%) ⬇️
appsec-next-latest-15.0.0 29.56% <ø> (-0.08%) ⬇️
appsec-next-latest-latest 29.57% <ø> (-0.08%) ⬇️
appsec-next-oldest-11.1.4 27.95% <ø> (-0.08%) ⬇️
appsec-next-oldest-12.3.7 29.51% <ø> (-0.08%) ⬇️
appsec-next-oldest-13.0.0 29.51% <ø> (-0.08%) ⬇️
appsec-next-oldest-13.2.0 29.79% <ø> (-0.08%) ⬇️
appsec-next-oldest-13.5.11 29.89% <ø> (-0.08%) ⬇️
appsec-next-oldest-14.0.0 29.82% <ø> (-0.08%) ⬇️
appsec-next-oldest-14.2.35 29.82% <ø> (-0.08%) ⬇️
appsec-next-oldest-14.2.6 29.82% <ø> (-0.08%) ⬇️
appsec-next-oldest-14.2.7 29.82% <ø> (-0.08%) ⬇️
appsec-next-oldest-15.0.0 29.82% <ø> (-0.08%) ⬇️
appsec-next-oldest-latest 27.78% <ø> (ø)
appsec-node-serialize 39.35% <ø> (-0.07%) ⬇️
appsec-passport 43.08% <ø> (-0.07%) ⬇️
appsec-postgres 47.44% <ø> (+0.18%) ⬆️
appsec-sourcing 38.74% <ø> (-0.07%) ⬇️
appsec-stripe 40.82% <ø> (-0.05%) ⬇️
appsec-template 39.59% <ø> (-0.07%) ⬇️
appsec-ubuntu 57.77% <ø> (-0.06%) ⬇️
appsec-windows 57.62% <ø> (-0.05%) ⬇️
debugger-ubuntu-active 43.98% <ø> (-0.39%) ⬇️
debugger-ubuntu-latest 43.88% <ø> (ø)
debugger-ubuntu-maintenance 43.95% <ø> (ø)
debugger-ubuntu-oldest 44.39% <ø> (-0.05%) ⬇️
instrumentations-instrumentation-ai 36.24% <ø> (ø)
instrumentations-instrumentation-aws-sdk 35.20% <ø> (ø)
instrumentations-instrumentation-bluebird 27.82% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-body-parser 36.02% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-child_process 33.52% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-cookie-parser 29.82% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-couchbase-18 36.41% <ø> (ø)
instrumentations-instrumentation-couchbase-eol 36.41% <ø> (ø)
instrumentations-instrumentation-crypto 27.90% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-express 30.01% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 29.93% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-express-multi-version 21.17% <ø> (ø)
instrumentations-instrumentation-express-session 35.73% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-fetch 33.27% <ø> (ø)
instrumentations-instrumentation-fs 27.54% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-generic-pool 27.44% <ø> (ø)
instrumentations-instrumentation-hono 28.96% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-http 35.25% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-http-client-options 37.75% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-kafkajs 48.71% <100.00%> (?)
instrumentations-instrumentation-knex 27.81% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-light-my-request 35.55% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-mongoose 29.17% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-multer 35.68% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-mysql2 33.58% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-otel-sdk-trace 25.35% <ø> (ø)
instrumentations-instrumentation-passport 39.48% <ø> (-0.07%) ⬇️
instrumentations-instrumentation-passport-http 39.17% <ø> (-0.07%) ⬇️
instrumentations-instrumentation-passport-local 39.64% <ø> (-0.07%) ⬇️
instrumentations-instrumentation-pg 33.17% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-promise 27.77% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-promise-js 27.77% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-q 27.80% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-stripe 28.31% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-url 27.73% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-when 27.78% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-zlib 27.78% <ø> (-0.08%) ⬇️
instrumentations-integration-esbuild-0.16.12-active 19.19% <0.00%> (-0.05%) ⬇️
instrumentations-integration-esbuild-0.16.12-latest 19.18% <0.00%> (-0.05%) ⬇️
instrumentations-integration-esbuild-0.16.12-maintenance 19.19% <0.00%> (-0.05%) ⬇️
instrumentations-integration-esbuild-0.16.12-oldest 19.18% <0.00%> (-0.05%) ⬇️
instrumentations-integration-esbuild-latest-active 19.19% <0.00%> (-0.05%) ⬇️
instrumentations-integration-esbuild-latest-latest 19.18% <0.00%> (-0.05%) ⬇️
instrumentations-integration-esbuild-latest-maintenance 19.19% <0.00%> (-0.05%) ⬇️
instrumentations-integration-esbuild-latest-oldest 19.18% <0.00%> (-0.05%) ⬇️
llmobs-ai 36.51% <ø> (-0.08%) ⬇️
llmobs-anthropic 36.70% <ø> (-0.08%) ⬇️
llmobs-bedrock 35.43% <ø> (-0.07%) ⬇️
llmobs-google-genai 35.77% <ø> (-0.08%) ⬇️
llmobs-langchain 36.90% <ø> (+0.07%) ⬆️
llmobs-openai-latest 39.67% <ø> (-0.07%) ⬇️
llmobs-openai-oldest 39.70% <ø> (-0.07%) ⬇️
llmobs-sdk-active 43.77% <ø> (-0.08%) ⬇️
llmobs-sdk-latest 43.71% <ø> (-0.08%) ⬇️
llmobs-sdk-maintenance 43.76% <ø> (-0.08%) ⬇️
llmobs-sdk-oldest 43.75% <ø> (-0.08%) ⬇️
llmobs-vertex-ai 35.77% <ø> (-0.08%) ⬇️
master-coverage 93.08% <100.00%> (?)
openfeature-macos 38.10% <ø> (+<0.01%) ⬆️
openfeature-ubuntu 38.17% <ø> (ø)
openfeature-unit-active 47.81% <ø> (ø)
openfeature-unit-latest 47.68% <ø> (ø)
openfeature-unit-maintenance 47.81% <ø> (ø)
openfeature-unit-oldest 47.81% <ø> (ø)
openfeature-windows 37.96% <ø> (ø)
platform-core 32.21% <ø> (ø)
platform-esbuild 36.77% <ø> (ø)
platform-instrumentations-misc 30.17% <ø> (ø)
platform-integration-active 47.25% <ø> (+0.04%) ⬆️
platform-integration-latest 47.21% <ø> (ø)
platform-integration-maintenance 47.26% <ø> (-0.02%) ⬇️
platform-integration-oldest 47.43% <ø> (-0.02%) ⬇️
platform-shimmer 39.58% <ø> (ø)
platform-unit-guardrails 32.99% <ø> (ø)
platform-webpack 18.69% <0.00%> (-0.05%) ⬇️
plugins-axios 35.54% <ø> (ø)
plugins-azure-cosmos 35.95% <ø> (-0.08%) ⬇️
plugins-azure-event-hubs 34.88% <ø> (ø)
plugins-azure-service-bus 35.37% <ø> (ø)
plugins-body-parser 36.71% <ø> (ø)
plugins-bullmq 39.19% <ø> (-0.08%) ⬇️
plugins-cassandra 33.70% <ø> (-0.08%) ⬇️
plugins-cookie 25.20% <ø> (ø)
plugins-cookie-parser 24.95% <ø> (ø)
plugins-crypto 24.94% <ø> (ø)
plugins-dd-trace-api 33.54% <ø> (-0.08%) ⬇️
plugins-express-mongo-sanitize 25.20% <ø> (ø)
plugins-express-session 24.87% <ø> (ø)
plugins-fastify 37.83% <ø> (-0.08%) ⬇️
plugins-fetch 34.18% <ø> (-0.08%) ⬇️
plugins-fs 33.86% <ø> (-0.08%) ⬇️
plugins-generic-pool 23.89% <ø> (ø)
plugins-google-cloud-pubsub 41.49% <ø> (-0.08%) ⬇️
plugins-grpc 36.70% <ø> (-0.08%) ⬇️
plugins-handlebars 25.16% <ø> (ø)
plugins-hapi 35.70% <ø> (-0.08%) ⬇️
plugins-hono 35.98% <ø> (-0.08%) ⬇️
plugins-ioredis 34.27% <ø> (-0.08%) ⬇️
plugins-jest 28.09% <ø> (ø)
plugins-knex 24.88% <ø> (ø)
plugins-langgraph 33.11% <ø> (-0.08%) ⬇️
plugins-ldapjs 22.48% <ø> (ø)
plugins-light-my-request 24.60% <ø> (ø)
plugins-limitd-client 28.14% <ø> (-0.08%) ⬇️
plugins-lodash 24.08% <ø> (ø)
plugins-mariadb 35.17% <ø> (-0.08%) ⬇️
plugins-memcached 33.77% <ø> (-0.08%) ⬇️
plugins-microgateway-core 34.80% <ø> (-0.08%) ⬇️
plugins-modelcontextprotocol-sdk 32.44% <ø> (-0.08%) ⬇️
plugins-moleculer 36.73% <ø> (-0.08%) ⬇️
plugins-mongodb 35.28% <ø> (-0.07%) ⬇️
plugins-mongodb-core 34.84% <ø> (-0.08%) ⬇️
plugins-mongoose 34.61% <ø> (-0.08%) ⬇️
plugins-multer 24.91% <ø> (ø)
plugins-mysql 34.66% <ø> (-0.08%) ⬇️
plugins-mysql2 34.90% <ø> (-0.08%) ⬇️
plugins-node-serialize 25.25% <ø> (ø)
plugins-opensearch 33.63% <ø> (-0.08%) ⬇️
plugins-passport-http 24.83% <ø> (ø)
plugins-pino 30.07% <ø> (-0.08%) ⬇️
plugins-postgres 34.48% <ø> (-0.08%) ⬇️
plugins-process 24.94% <ø> (ø)
plugins-pug 25.20% <ø> (ø)
plugins-redis 34.11% <ø> (-0.31%) ⬇️
plugins-router 38.51% <ø> (+0.08%) ⬆️
plugins-sequelize 23.77% <ø> (ø)
plugins-test-and-upstream-amqp10 33.92% <ø> (+0.09%) ⬆️
plugins-test-and-upstream-amqplib 39.21% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-apollo 34.96% <ø> (-0.07%) ⬇️
plugins-test-and-upstream-avsc 33.97% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-bunyan 29.39% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-connect 36.37% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-graphql 36.00% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-koa 35.93% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-protobufjs 34.17% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-rhea 39.31% <ø> (-0.08%) ⬇️
plugins-undici 34.69% <ø> (-0.08%) ⬇️
plugins-url 24.94% <ø> (ø)
plugins-valkey 33.88% <ø> (-0.08%) ⬇️
plugins-vm 24.94% <ø> (ø)
plugins-winston 29.94% <ø> (-0.08%) ⬇️
plugins-ws 37.21% <ø> (-0.08%) ⬇️
profiling-macos 43.41% <ø> (-0.07%) ⬇️
profiling-ubuntu 43.80% <ø> (-0.07%) ⬇️
profiling-windows 41.17% <ø> (-0.07%) ⬇️
serverless-aws-sdk-latest-aws-sdk 33.54% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-bedrockruntime 31.80% <ø> (-0.07%) ⬇️
serverless-aws-sdk-latest-client 20.21% <ø> (ø)
serverless-aws-sdk-latest-dynamodb 34.30% <ø> (-0.07%) ⬇️
serverless-aws-sdk-latest-eventbridge 27.43% <ø> (-0.07%) ⬇️
serverless-aws-sdk-latest-kinesis 37.53% <ø> (-0.07%) ⬇️
serverless-aws-sdk-latest-lambda 34.93% <ø> (-0.07%) ⬇️
serverless-aws-sdk-latest-s3 32.74% <ø> (-0.07%) ⬇️
serverless-aws-sdk-latest-serverless-peer-service 39.78% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-sns 38.68% <ø> (-0.07%) ⬇️
serverless-aws-sdk-latest-sqs 38.22% <ø> (-0.07%) ⬇️
serverless-aws-sdk-latest-stepfunctions 33.48% <ø> (-0.07%) ⬇️
serverless-aws-sdk-latest-util 47.12% <ø> (ø)
serverless-aws-sdk-oldest-aws-sdk 33.62% <ø> (-0.07%) ⬇️
serverless-aws-sdk-oldest-bedrockruntime 32.07% <ø> (-0.07%) ⬇️
serverless-aws-sdk-oldest-client 20.61% <ø> (ø)
serverless-aws-sdk-oldest-dynamodb 34.41% <ø> (-0.07%) ⬇️
serverless-aws-sdk-oldest-eventbridge 27.46% <ø> (-0.07%) ⬇️
serverless-aws-sdk-oldest-kinesis 37.66% <ø> (-0.07%) ⬇️
serverless-aws-sdk-oldest-lambda 34.99% <ø> (-0.07%) ⬇️
serverless-aws-sdk-oldest-s3 32.79% <ø> (-0.07%) ⬇️
serverless-aws-sdk-oldest-serverless-peer-service 39.82% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-sns 38.74% <ø> (-0.20%) ⬇️
serverless-aws-sdk-oldest-sqs 38.06% <ø> (-0.07%) ⬇️
serverless-aws-sdk-oldest-stepfunctions 33.54% <ø> (-0.07%) ⬇️
serverless-aws-sdk-oldest-util 47.38% <ø> (ø)
serverless-azure-durable-functions 36.89% <ø> (-0.17%) ⬇️
serverless-azure-functions-eventhubs 38.52% <ø> (ø)
serverless-azure-functions-servicebus 38.58% <ø> (ø)
serverless-lambda 34.83% <ø> (-0.10%) ⬇️
test-optimization-cucumber-latest-7.0.0 50.32% <ø> (+0.01%) ⬆️
test-optimization-cucumber-latest-latest 53.19% <ø> (+0.12%) ⬆️
test-optimization-cucumber-oldest-7.0.0 50.36% <ø> (+0.12%) ⬆️
test-optimization-cypress-latest-12.0.0-commonJS 48.79% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-12.0.0-esm 48.73% <ø> (-0.02%) ⬇️
test-optimization-cypress-latest-14.5.4-commonJS 48.58% <ø> (+0.01%) ⬆️
test-optimization-cypress-latest-14.5.4-esm 48.67% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-latest-commonJS 48.61% <ø> (-0.45%) ⬇️
test-optimization-cypress-latest-latest-esm 49.16% <ø> (+0.07%) ⬆️
test-optimization-cypress-oldest-12.0.0-commonJS 48.83% <ø> (+0.07%) ⬆️
test-optimization-cypress-oldest-12.0.0-esm 48.86% <ø> (+0.07%) ⬆️
test-optimization-cypress-oldest-14.5.4-commonJS 48.67% <ø> (+0.16%) ⬆️
test-optimization-cypress-oldest-14.5.4-esm 48.71% <ø> (+0.07%) ⬆️
test-optimization-jest-latest-latest 54.77% <ø> (+0.08%) ⬆️
test-optimization-jest-latest-oldest 53.57% <ø> (+0.01%) ⬆️
test-optimization-jest-oldest-latest 54.77% <ø> (+0.08%) ⬆️
test-optimization-jest-oldest-oldest 53.57% <ø> (+0.08%) ⬆️
test-optimization-mocha-latest-latest 53.59% <ø> (+0.02%) ⬆️
test-optimization-mocha-latest-oldest 51.28% <ø> (+0.08%) ⬆️
test-optimization-mocha-oldest-latest 53.68% <ø> (+0.08%) ⬆️
test-optimization-mocha-oldest-oldest 51.22% <ø> (+0.08%) ⬆️
test-optimization-playwright-latest-latest-playwright-active-test-span 44.34% <ø> (+0.28%) ⬆️
test-optimization-playwright-latest-latest-playwright-atr 43.12% <ø> (+0.11%) ⬆️
test-optimization-playwright-latest-latest-playwright-efd 43.54% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-latest-playwright-final-status 43.61% <ø> (+0.11%) ⬆️
test-optimization-playwright-latest-latest-playwright-impacted-tests 43.05% <ø> (ø)
test-optimization-playwright-latest-latest-playwright-reporting 43.02% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-latest-playwright-test-management 44.78% <ø> (+0.10%) ⬆️
test-optimization-playwright-latest-oldest-playwright-active-test-span 44.40% <ø> (+0.28%) ⬆️
test-optimization-playwright-latest-oldest-playwright-atr 43.33% <ø> (+0.11%) ⬆️
test-optimization-playwright-latest-oldest-playwright-efd 43.59% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-oldest-playwright-final-status 43.64% <ø> (+0.11%) ⬆️
test-optimization-playwright-latest-oldest-playwright-impacted-tests 43.10% <ø> (ø)
test-optimization-playwright-latest-oldest-playwright-reporting 43.09% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-oldest-playwright-test-management 44.86% <ø> (+0.10%) ⬆️
test-optimization-playwright-oldest-latest-playwright-active-test-span ?
test-optimization-playwright-oldest-latest-playwright-atr 43.15% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-latest-playwright-efd 43.55% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-latest-playwright-final-status 43.62% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-latest-playwright-impacted-tests 43.09% <ø> (ø)
test-optimization-playwright-oldest-latest-playwright-reporting 43.03% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-latest-playwright-test-management 44.80% <ø> (-0.14%) ⬇️
test-optimization-playwright-oldest-oldest-playwright-active-test-span 44.44% <ø> (+0.28%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-atr 43.37% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-efd 43.61% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-final-status 43.68% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-impacted-tests 43.14% <ø> (ø)
test-optimization-playwright-oldest-oldest-playwright-reporting 43.10% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-test-management 44.87% <ø> (+0.10%) ⬆️
test-optimization-selenium-latest 45.54% <ø> (+0.07%) ⬆️
test-optimization-selenium-oldest 45.10% <ø> (+0.07%) ⬆️
test-optimization-testopt-active 46.94% <ø> (+0.13%) ⬆️
test-optimization-testopt-latest 46.90% <ø> (+0.13%) ⬆️
test-optimization-testopt-maintenance 46.94% <ø> (+0.13%) ⬆️
test-optimization-testopt-oldest 47.81% <ø> (+0.14%) ⬆️
test-optimization-vitest-latest 51.19% <ø> (+0.10%) ⬆️
test-optimization-vitest-oldest 48.28% <ø> (+0.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pr-commenter

pr-commenter Bot commented May 10, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-05-23 07:17:45

Comparing candidate commit a3841e8 in PR branch BridgeAR/2026-05-10-kafkajs-send-batch with baseline commit 4b3a0f0 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1495 metrics, 98 unstable metrics.

@BridgeAR
BridgeAR force-pushed the BridgeAR/2026-05-09-kafka-skip-injection-pre-v3 branch from 681b6c4 to 9792e32 Compare May 12, 2026 14:37
Base automatically changed from BridgeAR/2026-05-09-kafka-skip-injection-pre-v3 to master May 19, 2026 00:10
@BridgeAR
BridgeAR force-pushed the BridgeAR/2026-05-10-kafkajs-send-batch branch 2 times, most recently from 9858515 to 97dc21c Compare May 19, 2026 23:50
@BridgeAR

BridgeAR commented May 20, 2026

Copy link
Copy Markdown
Member Author

This is blocked on a fix to instanbuljs for generating the coverage properly. See istanbuljs/istanbuljs#845

@BridgeAR
BridgeAR marked this pull request as ready for review May 20, 2026 11:56
@BridgeAR
BridgeAR requested review from a team as code owners May 20, 2026 11:56
@BridgeAR
BridgeAR requested review from crysmags and removed request for a team May 20, 2026 11:56
@watson

watson commented May 21, 2026

Copy link
Copy Markdown
Collaborator

A new linting rule just landed in master that will fail this PR if merged as-is. I'll merge in master so that it's more clear - sorry for the inconvenience.

BridgeAR added 5 commits May 22, 2026 15:47
This adds tracing, header injection, and DSM checkpoints for the
kafkajs producer.sendBatch API, which was previously uninstrumented:
calls produced no spans and propagated no trace or DSM context.

One kafka.produce span per topicMessages[] entry matches what
producer.send already emits for the single-topic case and mirrors
how kafkajs implements send internally (producer/messageProducer.js
delegates send to a single-entry sendBatch). Per-entry granularity
keeps DSM checkpoints correct on multi-topic batches. The broker
response is one aggregated array covering every topic, so the
plugin's finish filters by ctx.topic before tagging
kafka.messages.offsets; otherwise each per-topic span would carry
every other topic's offsets.

Fixes: #1711
Refs: #8468
The integration spec in `packages/datadog-plugin-kafkajs/test/index.spec.js`
needs Docker Kafka and always connects the producer before sending, so
the slow-path branch through `cluster.refreshMetadataIfNecessary().then(...)`
and its `refreshMetadataIfNecessary`-missing fallback never ran outside
that one CI flag. This adds an instrumentation-level spec that drives
the boundary with a faked cluster, pinning the resolve / reject / missing
arms of the slow path, the proactive and reactive `refreshHeaderSupport`
disable, and the `producerStartCh.hasSubscribers` fast skip without
spinning a broker.

Refs: #8390
The instrumentation-level spec at
`packages/datadog-instrumentations/test/kafkajs.spec.js` is matched
by `test:instrumentations`'s `PLUGINS=kafkajs` glob, but no
workflow runs it. Without a job, codecov sees no session for the
producer-boundary slow path or the `refreshHeaderSupport` disable
arms.
The previous instrumentation-level spec only exercised
`producer.send`. The integration spec needs Docker Kafka, so the
sendBatch boundary's empty-batch fast skip, non-array messages
else arm, sync-throw catch, and `KafkaJSProtocolError UNKNOWN`
disable branch stay uncovered without faked-cluster unit tests.
Two of the new sendBatch cases duplicate branches the existing spec
already pins:

1. The `empty topicMessages` case hit the same length-0 fast skip
   as the `missing topicMessages` case from a different ternary
   arm whose true side every multi-entry test already exercises.
2. The `clusterId after refreshMetadataIfNecessary resolves` case
   re-ran `withClusterId`'s resolve arm through sendBatch when the
   send-side slow-path test already covers all three withClusterId
   arms and every fast-path sendBatch test wires the boundary
   through L116.
@BridgeAR
BridgeAR force-pushed the BridgeAR/2026-05-10-kafkajs-send-batch branch from cec38d6 to 774b242 Compare May 22, 2026 13:47
@BridgeAR
BridgeAR merged commit dd068f1 into master May 26, 2026
1348 of 1355 checks passed
@BridgeAR
BridgeAR deleted the BridgeAR/2026-05-10-kafkajs-send-batch branch May 26, 2026 18:25
This was referenced May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add trace support for kafkajs sendBatch

3 participants