Skip to content

fix(kafkajs): skip header injection on brokers below Produce v3#8390

Merged
BridgeAR merged 2 commits into
masterfrom
BridgeAR/2026-05-09-kafka-skip-injection-pre-v3
May 19, 2026
Merged

fix(kafkajs): skip header injection on brokers below Produce v3#8390
BridgeAR merged 2 commits into
masterfrom
BridgeAR/2026-05-09-kafka-skip-injection-pre-v3

Conversation

@BridgeAR

@BridgeAR BridgeAR commented May 9, 2026

Copy link
Copy Markdown
Member

Summary

The Produce request didn't carry headers until v3 (Kafka 0.11), so injecting on older brokers either wastes work or trips UNKNOWN_SERVER_ERROR on a per-leader version mismatch in mixed-version clusters.

  1. Read cluster.brokerPool.versions[0].maxVersion once on first send and disable injection proactively when the broker negotiated <v3.
  2. The reactive KafkaJSProtocolError UNKNOWN handler stays as the safety net for mixed-version clusters where the seed broker advertised v3+ but the leader couldn't parse the headers.
  3. refreshHeaderSupport is a let that swaps to module-level noop at both disable sites, so subsequent sends skip the helper call entirely. The reactive disableHeaderInjection moves from the module-level disabledHeaderWeakSet to a per-producer closure so the lifetime matches the producer it describes.

Test plan

  • ./node_modules/.bin/mocha packages/datadog-instrumentations/test/helpers/kafka.spec.js — unit tests for brokerSupportsMessageHeaders (boundary at maxVersion 2 / 3 / 9 / undefined).
  • PLUGINS=kafkajs SPEC=index npm run test:plugins — pins that downgrading the broker pool's negotiated Produce version to 2 trips the proactive disable path; the cloned messages reach the channel without headers: {} seeding.

Stacked on top of #8389.

Refs: #8253

@github-actions

github-actions Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 5.88 MB
Deduped: 6.72 MB
No deduping: 6.72 MB

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

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

@codecov

codecov Bot commented May 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.69%. Comparing base (bcab75c) to head (5a1d7ce).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
...ages/datadog-instrumentations/src/helpers/kafka.js 80.00% 1 Missing ⚠️
packages/datadog-instrumentations/src/kafkajs.js 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8390      +/-   ##
==========================================
+ Coverage   89.66%   89.69%   +0.02%     
==========================================
  Files         844      844              
  Lines       45644    45658      +14     
  Branches     8518     8521       +3     
==========================================
+ Hits        40928    40954      +26     
+ Misses       4716     4704      -12     
Flag Coverage Δ
aiguard-integration-active 41.16% <ø> (ø)
aiguard-integration-latest 41.11% <ø> (ø)
aiguard-integration-maintenance 41.16% <ø> (ø)
aiguard-macos 35.32% <ø> (-0.09%) ⬇️
aiguard-ubuntu 35.42% <ø> (-0.09%) ⬇️
aiguard-windows 35.22% <ø> (-0.09%) ⬇️
apm-capabilities-tracing-macos 49.05% <ø> (+0.04%) ⬆️
apm-capabilities-tracing-ubuntu-active 49.25% <ø> (-0.01%) ⬇️
apm-capabilities-tracing-ubuntu-latest 49.05% <ø> (+<0.01%) ⬆️
apm-capabilities-tracing-ubuntu-maintenance 49.26% <ø> (+0.17%) ⬆️
apm-capabilities-tracing-ubuntu-oldest 49.25% <ø> (ø)
apm-capabilities-tracing-windows 48.87% <ø> (-0.18%) ⬇️
apm-integrations-aerospike-18-gte.5.2.0 34.40% <ø> (-0.09%) ⬇️
apm-integrations-aerospike-20-gte.5.5.0 34.41% <ø> (-0.09%) ⬇️
apm-integrations-aerospike-22-gte.5.12.1 34.41% <ø> (-0.09%) ⬇️
apm-integrations-aerospike-22-gte.6.0.0 34.41% <ø> (-0.09%) ⬇️
apm-integrations-aerospike-eol- 34.32% <ø> (-0.09%) ⬇️
apm-integrations-child-process 35.38% <ø> (-0.09%) ⬇️
apm-integrations-confluentinc-kafka-javascript-18 41.27% <50.00%> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript-20 41.29% <50.00%> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript-22 41.29% <50.00%> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript-24 41.22% <50.00%> (-0.08%) ⬇️
apm-integrations-couchbase-18 34.57% <ø> (-0.09%) ⬇️
apm-integrations-couchbase-eol 34.68% <ø> (+0.10%) ⬆️
apm-integrations-dns 34.27% <ø> (-0.09%) ⬇️
apm-integrations-elasticsearch 35.04% <ø> (-0.08%) ⬇️
apm-integrations-http-latest 42.20% <ø> (-0.08%) ⬇️
apm-integrations-http-maintenance 42.25% <ø> (-0.08%) ⬇️
apm-integrations-http-oldest 42.26% <ø> (-0.08%) ⬇️
apm-integrations-http2 39.68% <ø> (-0.09%) ⬇️
apm-integrations-kafkajs-latest 41.16% <100.00%> (-0.04%) ⬇️
apm-integrations-kafkajs-oldest 41.22% <100.00%> (-0.03%) ⬇️
apm-integrations-net 34.98% <ø> (-0.09%) ⬇️
apm-integrations-next-11.1.4 29.09% <ø> (-0.10%) ⬇️
apm-integrations-next-12.3.7 30.76% <ø> (-0.08%) ⬇️
apm-integrations-next-13.0.0 30.76% <ø> (-0.08%) ⬇️
apm-integrations-next-13.2.0 30.75% <ø> (-0.08%) ⬇️
apm-integrations-next-13.5.11 30.89% <ø> (-0.08%) ⬇️
apm-integrations-next-14.0.0 30.82% <ø> (-0.08%) ⬇️
apm-integrations-next-14.2.35 30.82% <ø> (-0.08%) ⬇️
apm-integrations-next-14.2.6 30.82% <ø> (-0.11%) ⬇️
apm-integrations-next-14.2.7 30.82% <ø> (-0.08%) ⬇️
apm-integrations-next-15.0.0 30.82% <ø> (-0.08%) ⬇️
apm-integrations-next-15.4.0 30.89% <ø> (-0.08%) ⬇️
apm-integrations-oracledb 34.68% <ø> (-0.08%) ⬇️
apm-integrations-prisma-18-gte.6.16.0.and.lt.7.0.0 36.66% <ø> (-0.08%) ⬇️
apm-integrations-prisma-latest-all 35.50% <ø> (-0.08%) ⬇️
apm-integrations-restify 36.56% <ø> (-0.08%) ⬇️
apm-integrations-sharedb 33.96% <ø> (-0.09%) ⬇️
apm-integrations-tedious 34.48% <ø> (-0.08%) ⬇️
appsec-express 51.93% <ø> (-0.05%) ⬇️
appsec-fastify 48.63% <ø> (-0.07%) ⬇️
appsec-graphql 48.84% <ø> (-0.17%) ⬇️
appsec-integration-active 36.56% <16.66%> (-0.02%) ⬇️
appsec-integration-latest 36.53% <16.66%> (-0.02%) ⬇️
appsec-integration-maintenance 36.55% <16.66%> (-0.02%) ⬇️
appsec-integration-oldest 36.55% <16.66%> (-0.02%) ⬇️
appsec-kafka 41.54% <62.50%> (-0.11%) ⬇️
appsec-ldapjs 40.72% <ø> (-0.07%) ⬇️
appsec-lodash 40.83% <ø> (-0.07%) ⬇️
appsec-macos 55.31% <ø> (-0.06%) ⬇️
appsec-mongodb-core 45.14% <ø> (-0.08%) ⬇️
appsec-mongoose 45.97% <ø> (-0.06%) ⬇️
appsec-mysql 48.03% <ø> (-0.07%) ⬇️
appsec-next-latest-11.1.4 29.22% <ø> (-0.08%) ⬇️
appsec-next-latest-12.3.7 30.89% <ø> (-0.09%) ⬇️
appsec-next-latest-13.0.0 30.89% <ø> (-0.09%) ⬇️
appsec-next-latest-13.2.0 30.91% <ø> (-0.09%) ⬇️
appsec-next-latest-13.5.11 30.99% <ø> (-0.08%) ⬇️
appsec-next-latest-14.0.0 30.92% <ø> (-0.09%) ⬇️
appsec-next-latest-14.2.35 30.92% <ø> (-0.09%) ⬇️
appsec-next-latest-14.2.6 30.92% <ø> (-0.09%) ⬇️
appsec-next-latest-14.2.7 30.92% <ø> (-0.09%) ⬇️
appsec-next-latest-15.0.0 30.92% <ø> (-0.09%) ⬇️
appsec-next-latest-latest 30.93% <ø> (-0.08%) ⬇️
appsec-next-oldest-11.1.4 29.23% <ø> (-0.07%) ⬇️
appsec-next-oldest-12.3.7 30.91% <ø> (-0.09%) ⬇️
appsec-next-oldest-13.0.0 30.91% <ø> (-0.09%) ⬇️
appsec-next-oldest-13.2.0 31.19% <ø> (-0.09%) ⬇️
appsec-next-oldest-13.5.11 31.28% <ø> (-0.08%) ⬇️
appsec-next-oldest-14.0.0 31.22% <ø> (-0.09%) ⬇️
appsec-next-oldest-14.2.35 31.22% <ø> (-0.09%) ⬇️
appsec-next-oldest-14.2.6 31.22% <ø> (-0.09%) ⬇️
appsec-next-oldest-14.2.7 31.22% <ø> (-0.09%) ⬇️
appsec-next-oldest-15.0.0 31.22% <ø> (-0.09%) ⬇️
appsec-next-oldest-latest 29.31% <ø> (ø)
appsec-node-serialize 40.05% <ø> (-0.07%) ⬇️
appsec-passport 43.75% <ø> (-0.08%) ⬇️
appsec-postgres 47.61% <ø> (-0.09%) ⬇️
appsec-sourcing 39.40% <ø> (-0.07%) ⬇️
appsec-stripe 41.55% <ø> (-0.08%) ⬇️
appsec-template 40.21% <ø> (-0.07%) ⬇️
appsec-ubuntu 55.38% <ø> (-0.06%) ⬇️
appsec-windows 55.23% <ø> (-0.06%) ⬇️
debugger-ubuntu-active 43.21% <ø> (ø)
debugger-ubuntu-latest 43.16% <ø> (ø)
debugger-ubuntu-maintenance 43.23% <ø> (ø)
debugger-ubuntu-oldest 43.66% <ø> (ø)
instrumentations-instrumentation-bluebird 29.31% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-body-parser 36.99% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-child_process 34.87% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-cookie-parser 31.13% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-express 31.34% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 31.25% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-express-session 36.68% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-fs 29.00% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-generic-pool 28.60% <ø> (ø)
instrumentations-instrumentation-http 36.32% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-knex 29.29% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-light-my-request 36.62% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-mongoose 30.48% <ø> (+<0.01%) ⬆️
instrumentations-instrumentation-multer 36.78% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-mysql2 34.89% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-passport 40.42% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-passport-http 40.19% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-passport-local 40.68% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-pg 34.49% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-promise 29.25% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-promise-js 29.26% <ø> (?)
instrumentations-instrumentation-q 29.29% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-url 29.26% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-when 29.27% <ø> (-0.09%) ⬇️
instrumentations-integration-esbuild-0.16.12-active 19.20% <16.66%> (-0.01%) ⬇️
instrumentations-integration-esbuild-0.16.12-latest 19.18% <16.66%> (-0.01%) ⬇️
instrumentations-integration-esbuild-0.16.12-maintenance 19.20% <16.66%> (-0.01%) ⬇️
instrumentations-integration-esbuild-0.16.12-oldest 19.19% <16.66%> (-0.01%) ⬇️
instrumentations-integration-esbuild-latest-active 19.20% <16.66%> (-0.01%) ⬇️
instrumentations-integration-esbuild-latest-latest 19.18% <16.66%> (-0.01%) ⬇️
instrumentations-integration-esbuild-latest-maintenance 19.20% <16.66%> (-0.01%) ⬇️
instrumentations-integration-esbuild-latest-oldest 19.19% <16.66%> (-0.01%) ⬇️
llmobs-ai 37.79% <ø> (-0.08%) ⬇️
llmobs-anthropic 37.83% <ø> (-0.08%) ⬇️
llmobs-bedrock 36.57% <ø> (-0.08%) ⬇️
llmobs-google-genai 36.86% <ø> (-0.08%) ⬇️
llmobs-langchain 38.14% <ø> (-0.07%) ⬇️
llmobs-openai-latest 40.51% <ø> (-0.08%) ⬇️
llmobs-openai-oldest 40.55% <ø> (-0.08%) ⬇️
llmobs-sdk-active 45.41% <ø> (-0.09%) ⬇️
llmobs-sdk-latest 45.34% <ø> (-0.09%) ⬇️
llmobs-sdk-maintenance 45.41% <ø> (-0.09%) ⬇️
llmobs-sdk-oldest 45.39% <ø> (-0.09%) ⬇️
llmobs-vertex-ai 37.01% <ø> (-0.08%) ⬇️
openfeature-macos 37.99% <ø> (ø)
openfeature-ubuntu 38.07% <ø> (ø)
openfeature-unit-active 49.26% <ø> (ø)
openfeature-unit-latest 49.11% <ø> (ø)
openfeature-unit-maintenance 49.26% <ø> (ø)
openfeature-unit-oldest 49.26% <ø> (ø)
openfeature-windows 37.86% <ø> (ø)
platform-core 36.45% <ø> (ø)
platform-esbuild 39.82% <ø> (ø)
platform-instrumentations-misc 30.86% <100.00%> (+0.02%) ⬆️
platform-integration-active 47.02% <ø> (+0.05%) ⬆️
platform-integration-latest 46.92% <ø> (-0.05%) ⬇️
platform-integration-maintenance 46.97% <ø> (-0.05%) ⬇️
platform-integration-oldest 47.18% <ø> (ø)
platform-shimmer 41.62% <ø> (ø)
platform-unit-guardrails 35.54% <ø> (ø)
platform-webpack 20.33% <18.75%> (-0.01%) ⬇️
plugins-azure-durable-functions 36.96% <ø> (-0.03%) ⬇️
plugins-azure-event-hubs 34.84% <ø> (ø)
plugins-azure-service-bus 35.29% <ø> (ø)
plugins-bullmq 40.11% <ø> (-0.20%) ⬇️
plugins-cassandra 34.69% <ø> (-0.21%) ⬇️
plugins-cookie 28.74% <ø> (ø)
plugins-cookie-parser 28.55% <ø> (ø)
plugins-crypto 27.24% <ø> (ø)
plugins-dd-trace-api 34.76% <ø> (-0.09%) ⬇️
plugins-express-mongo-sanitize 28.66% <ø> (ø)
plugins-express-session 28.51% <ø> (ø)
plugins-fastify 38.74% <ø> (-0.08%) ⬇️
plugins-fetch 35.06% <ø> (-0.08%) ⬇️
plugins-fs 35.15% <ø> (-0.09%) ⬇️
plugins-generic-pool 27.71% <ø> (ø)
plugins-google-cloud-pubsub 42.24% <ø> (-0.12%) ⬇️
plugins-grpc 37.54% <ø> (-0.08%) ⬇️
plugins-handlebars 28.70% <ø> (ø)
plugins-hapi 36.66% <ø> (-0.09%) ⬇️
plugins-hono 36.94% <ø> (-0.08%) ⬇️
plugins-ioredis 35.26% <ø> (-0.09%) ⬇️
plugins-knex 28.31% <ø> (ø)
plugins-langgraph 34.50% <ø> (-0.09%) ⬇️
plugins-ldapjs 26.32% <ø> (ø)
plugins-light-my-request 28.11% <ø> (ø)
plugins-limitd-client 29.55% <ø> (-0.09%) ⬇️
plugins-lodash 27.80% <ø> (ø)
plugins-mariadb 36.12% <ø> (-0.15%) ⬇️
plugins-memcached 34.88% <ø> (-0.09%) ⬇️
plugins-microgateway-core 35.79% <ø> (-0.09%) ⬇️
plugins-modelcontextprotocol-sdk 33.80% <ø> (-0.09%) ⬇️
plugins-moleculer 37.57% <ø> (-0.08%) ⬇️
plugins-mongodb 36.14% <ø> (-0.08%) ⬇️
plugins-mongodb-core 35.86% <ø> (-0.09%) ⬇️
plugins-mongoose 35.58% <ø> (-0.08%) ⬇️
plugins-multer 28.51% <ø> (ø)
plugins-mysql 35.90% <ø> (-0.09%) ⬇️
plugins-mysql2 35.98% <ø> (-0.09%) ⬇️
plugins-node-serialize 28.78% <ø> (ø)
plugins-opensearch 34.57% <ø> (-0.08%) ⬇️
plugins-passport-http 28.53% <ø> (ø)
plugins-pino 31.24% <ø> (-0.09%) ⬇️
plugins-postgres 33.71% <ø> (-0.08%) ⬇️
plugins-process 27.24% <ø> (ø)
plugins-pug 28.74% <ø> (ø)
plugins-redis 35.31% <ø> (-0.03%) ⬇️
plugins-router 39.08% <ø> (-0.21%) ⬇️
plugins-sequelize 27.50% <ø> (ø)
plugins-test-and-upstream-amqp10 35.12% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-amqplib 40.27% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-apollo 36.05% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-avsc 34.48% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-bunyan 30.62% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-connect 37.33% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-graphql 37.09% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-koa 36.92% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-protobufjs 34.68% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-rhea 40.29% <ø> (-0.09%) ⬇️
plugins-undici 35.78% <ø> (-0.08%) ⬇️
plugins-url 27.24% <ø> (ø)
plugins-valkey 34.90% <ø> (-0.09%) ⬇️
plugins-vm 27.24% <ø> (ø)
plugins-winston 31.25% <ø> (+0.04%) ⬆️
plugins-ws 38.26% <ø> (-0.08%) ⬇️
profiling-macos 42.69% <ø> (-0.07%) ⬇️
profiling-ubuntu 43.09% <ø> (-0.07%) ⬇️
profiling-windows 40.00% <ø> (-0.07%) ⬇️
serverless-aws-sdk-latest-aws-sdk 34.44% <ø> (-0.07%) ⬇️
serverless-aws-sdk-latest-bedrockruntime 33.13% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-client 24.39% <ø> (ø)
serverless-aws-sdk-latest-dynamodb 35.72% <ø> (-0.03%) ⬇️
serverless-aws-sdk-latest-eventbridge 28.51% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-kinesis 38.59% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-lambda 35.90% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-s3 33.88% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-serverless-peer-service 39.96% <ø> (-0.09%) ⬇️
serverless-aws-sdk-latest-sns 39.70% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-sqs 38.98% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-stepfunctions 34.50% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-util 48.33% <ø> (ø)
serverless-aws-sdk-oldest-aws-sdk 34.53% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-bedrockruntime 33.40% <ø> (?)
serverless-aws-sdk-oldest-client 24.73% <ø> (ø)
serverless-aws-sdk-oldest-dynamodb 35.79% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-eventbridge 28.55% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-kinesis 38.72% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-lambda 35.98% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-s3 33.94% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-serverless-peer-service 40.01% <ø> (-0.09%) ⬇️
serverless-aws-sdk-oldest-sns 39.90% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-sqs 38.88% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-stepfunctions 34.57% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-util 48.63% <ø> (ø)
serverless-azure-functions-eventhubs 38.47% <ø> (ø)
serverless-azure-functions-servicebus 38.53% <ø> (ø)
serverless-lambda 34.45% <ø> (-0.09%) ⬇️
test-optimization-cucumber-latest-7.0.0 50.25% <ø> (+0.01%) ⬆️
test-optimization-cucumber-latest-latest 53.14% <ø> (+0.12%) ⬆️
test-optimization-cucumber-oldest-7.0.0 50.29% <ø> (+0.12%) ⬆️
test-optimization-cypress-latest-12.0.0-commonJS 48.72% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-12.0.0-esm 48.76% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-14.5.4-commonJS 48.57% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-14.5.4-esm 48.60% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-latest-commonJS 49.06% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-latest-esm 49.10% <ø> (+0.07%) ⬆️
test-optimization-cypress-oldest-12.0.0-commonJS 48.76% <ø> (+0.07%) ⬆️
test-optimization-cypress-oldest-12.0.0-esm 48.79% <ø> (+0.07%) ⬆️
test-optimization-cypress-oldest-14.5.4-commonJS 48.61% <ø> (+3.46%) ⬆️
test-optimization-cypress-oldest-14.5.4-esm 48.64% <ø> (+0.16%) ⬆️
test-optimization-jest-latest-latest 54.77% <ø> (-0.02%) ⬇️
test-optimization-jest-latest-oldest 53.56% <ø> (+0.05%) ⬆️
test-optimization-jest-oldest-latest 54.78% <ø> (+0.08%) ⬆️
test-optimization-jest-oldest-oldest 53.53% <ø> (+0.08%) ⬆️
test-optimization-mocha-latest-latest 53.57% <ø> (+0.08%) ⬆️
test-optimization-mocha-latest-oldest 51.23% <ø> (+0.08%) ⬆️
test-optimization-mocha-oldest-latest 53.64% <ø> (+0.08%) ⬆️
test-optimization-mocha-oldest-oldest 51.17% <ø> (+0.06%) ⬆️
test-optimization-playwright-latest-latest-playwright-active-test-span 44.27% <ø> (+0.28%) ⬆️
test-optimization-playwright-latest-latest-playwright-atr 43.05% <ø> (+0.11%) ⬆️
test-optimization-playwright-latest-latest-playwright-efd 43.47% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-latest-playwright-final-status 43.52% <ø> (?)
test-optimization-playwright-latest-latest-playwright-impacted-tests 42.98% <ø> (ø)
test-optimization-playwright-latest-latest-playwright-reporting 42.96% <ø> (+0.11%) ⬆️
test-optimization-playwright-latest-latest-playwright-test-management 44.71% <ø> (+0.10%) ⬆️
test-optimization-playwright-latest-oldest-playwright-active-test-span 44.34% <ø> (+0.28%) ⬆️
test-optimization-playwright-latest-oldest-playwright-atr 43.26% <ø> (+0.11%) ⬆️
test-optimization-playwright-latest-oldest-playwright-efd 43.52% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-oldest-playwright-final-status 43.58% <ø> (+0.13%) ⬆️
test-optimization-playwright-latest-oldest-playwright-impacted-tests 43.02% <ø> (ø)
test-optimization-playwright-latest-oldest-playwright-reporting 43.00% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-oldest-playwright-test-management 44.78% <ø> (+0.10%) ⬆️
test-optimization-playwright-oldest-latest-playwright-active-test-span 44.29% <ø> (+0.25%) ⬆️
test-optimization-playwright-oldest-latest-playwright-atr 43.08% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-latest-playwright-efd 43.48% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-latest-playwright-final-status 43.54% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-latest-playwright-impacted-tests 43.01% <ø> (ø)
test-optimization-playwright-oldest-latest-playwright-reporting 42.94% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-latest-playwright-test-management 44.72% <ø> (+0.10%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-active-test-span 44.37% <ø> (+0.28%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-atr 43.30% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-efd 43.54% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-final-status 43.59% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-impacted-tests 43.06% <ø> (ø)
test-optimization-playwright-oldest-oldest-playwright-reporting 43.02% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-test-management 44.79% <ø> (+0.10%) ⬆️
test-optimization-selenium-latest 45.29% <ø> (-0.15%) ⬇️
test-optimization-selenium-oldest 45.07% <ø> (+0.07%) ⬆️
test-optimization-testopt-active 46.90% <ø> (+0.13%) ⬆️
test-optimization-testopt-latest 46.86% <ø> (+0.13%) ⬆️
test-optimization-testopt-maintenance 46.90% <ø> (+0.13%) ⬆️
test-optimization-testopt-oldest 47.77% <ø> (+0.14%) ⬆️
test-optimization-vitest-latest 51.06% <ø> (+0.10%) ⬆️
test-optimization-vitest-oldest 48.14% <ø> (+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.

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented May 9, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 86.41% (+0.00%)

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

@pr-commenter

pr-commenter Bot commented May 9, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-05-18 19:20:59

Comparing candidate commit 5a1d7ce in PR branch BridgeAR/2026-05-09-kafka-skip-injection-pre-v3 with baseline commit bcab75c in branch master.

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

@BridgeAR
BridgeAR force-pushed the BridgeAR/2026-05-09-kafka-read-clusterid-from-metadata branch from a1ae644 to 0d852ca Compare May 11, 2026 22:22
Base automatically changed from BridgeAR/2026-05-09-kafka-read-clusterid-from-metadata to master May 12, 2026 13:49
The Produce request didn't carry headers until v3 (Kafka 0.11), so
injecting on older brokers either wastes work or trips
`UNKNOWN_SERVER_ERROR` on a per-leader version mismatch in mixed-version
clusters. Read `cluster.brokerPool.versions[0].maxVersion` once on first
send and disable injection proactively when the broker negotiated <v3;
the existing `KafkaJSProtocolError UNKNOWN` handler stays as the safety
net for mixed-version clusters where the seed broker advertised v3+ but
the leader couldn't parse the headers.

`refreshHeaderSupport` is a `let` that swaps to module-level `noop` at
both disable sites, so subsequent sends skip the helper call entirely.
The reactive `disableHeaderInjection` moves from the module-level
`disabledHeaderWeakSet` to a per-producer closure so the lifetime
matches the producer it describes.

Refs: #8253
@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
@BridgeAR
BridgeAR marked this pull request as ready for review May 12, 2026 14:38
@BridgeAR
BridgeAR requested a review from a team as a code owner May 12, 2026 14:38
// be <0.11; lying locally is enough to drive the proactive
// header-support check.
const cluster = clientToCluster.get(producer)
cluster.brokerPool.versions[0].maxVersion = 2

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't we actually spin up a Docker container with an old version of Kafka to verify it works as expected instead of just mocking this value?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think the mock is better, since such old Kafka brokers are from 2017 :D

So having the mock here seems the best approach, no?

@BridgeAR
BridgeAR merged commit 7b5b32c into master May 19, 2026
952 of 953 checks passed
@BridgeAR
BridgeAR deleted the BridgeAR/2026-05-09-kafka-skip-injection-pre-v3 branch May 19, 2026 00:10
@dd-octo-sts dd-octo-sts Bot mentioned this pull request May 19, 2026
dd-octo-sts Bot pushed a commit that referenced this pull request May 19, 2026
The Produce request didn't carry headers until v3 (Kafka 0.11), so
injecting on older brokers either wastes work or trips
`UNKNOWN_SERVER_ERROR` on a per-leader version mismatch in mixed-version
clusters. Read `cluster.brokerPool.versions[0].maxVersion` once on first
send and disable injection proactively when the broker negotiated <v3;
the existing `KafkaJSProtocolError UNKNOWN` handler stays as the safety
net for mixed-version clusters where the seed broker advertised v3+ but
the leader couldn't parse the headers.

`refreshHeaderSupport` is a `let` that swaps to module-level `noop` at
both disable sites, so subsequent sends skip the helper call entirely.
The reactive `disableHeaderInjection` moves from the module-level
`disabledHeaderWeakSet` to a per-producer closure so the lifetime
matches the producer it describes.
BridgeAR added a commit that referenced this pull request May 19, 2026
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
BridgeAR added a commit that referenced this pull request May 19, 2026
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
pabloerhard pushed a commit that referenced this pull request May 20, 2026
The Produce request didn't carry headers until v3 (Kafka 0.11), so
injecting on older brokers either wastes work or trips
`UNKNOWN_SERVER_ERROR` on a per-leader version mismatch in mixed-version
clusters. Read `cluster.brokerPool.versions[0].maxVersion` once on first
send and disable injection proactively when the broker negotiated <v3;
the existing `KafkaJSProtocolError UNKNOWN` handler stays as the safety
net for mixed-version clusters where the seed broker advertised v3+ but
the leader couldn't parse the headers.

`refreshHeaderSupport` is a `let` that swaps to module-level `noop` at
both disable sites, so subsequent sends skip the helper call entirely.
The reactive `disableHeaderInjection` moves from the module-level
`disabledHeaderWeakSet` to a per-producer closure so the lifetime
matches the producer it describes.
BridgeAR added a commit that referenced this pull request May 22, 2026
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
BridgeAR added a commit that referenced this pull request May 26, 2026
* feat(kafkajs): instrument producer.sendBatch

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

* test(kafkajs): cover producer-boundary slow path and disable arms

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

* ci(kafkajs): run the datadog-instrumentations spec in CI

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.
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.

2 participants