Skip to content

fix(kafkajs): read clusterId from existing metadata#8389

Merged
BridgeAR merged 2 commits into
masterfrom
BridgeAR/2026-05-09-kafka-read-clusterid-from-metadata
May 12, 2026
Merged

fix(kafkajs): read clusterId from existing metadata#8389
BridgeAR merged 2 commits into
masterfrom
BridgeAR/2026-05-09-kafka-read-clusterid-from-metadata

Conversation

@BridgeAR
Copy link
Copy Markdown
Member

@BridgeAR BridgeAR commented May 9, 2026

Summary

The cluster id discovery used a separate kafka.admin() connection whose describeCluster() rejection wasn't awaited, surfacing as process.unhandledRejection whenever the admin handshake failed (auth, broker restart, network blip).

  1. The boundary now reads cluster.brokerPool.metadata.clusterId instead, priming it on first send via cluster.refreshMetadataIfNecessary(). kafkajs's sharedPromiseTo collapses our call with its internal one, so total latency is unchanged.
  2. The cluster reference for each producer/consumer is captured at creation time via two new addHook entries on src/producer/index.js / src/consumer/index.js and stored in a WeakMap exported from helpers/kafka. The kafkajs object stays untouched — no Symbol-keyed property to leak through Reflect.ownKeys, no string-keyed underscore for user serializers to pick up.

The DSM spec drops its clusterIdAvailable = semver.intersects(version, '>=1.13') flag because the metadata path works on every kafkajs version this integration targets (>=1.4); the admin-based discovery only worked on >=1.13.

Test plan

  • PLUGINS=kafkajs SPEC=index npm run test:plugins — pins that no kafka.admin() connection is opened during normal send (regression test for the unhandled-rejection failure mode).
  • PLUGINS=kafkajs SPEC=dsm npm run test:plugins — pins the kafka_cluster_id tag is set across the entire kafkajs version matrix.

Stacked on top of #8388.

Refs: #5270
Refs: #8253

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

Overall package size

Self size: 5.82 MB
Deduped: 6.66 MB
No deduping: 6.66 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
Copy link
Copy Markdown

codecov Bot commented May 9, 2026

Codecov Report

❌ Patch coverage is 81.52174% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.71%. Comparing base (4ab60e2) to head (de9ab75).

Files with missing lines Patch % Lines
packages/datadog-instrumentations/src/kafkajs.js 81.31% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8389      +/-   ##
==========================================
- Coverage   90.01%   88.71%   -1.30%     
==========================================
  Files         838      837       -1     
  Lines       45046    45020      -26     
  Branches     8394     8392       -2     
==========================================
- Hits        40547    39941     -606     
- Misses       4499     5079     +580     
Flag Coverage Δ
aiguard-integration-active 40.67% <ø> (ø)
aiguard-integration-latest 40.62% <ø> (ø)
aiguard-integration-maintenance 40.67% <ø> (ø)
aiguard-macos 35.39% <ø> (-0.09%) ⬇️
aiguard-ubuntu 35.49% <ø> (-0.09%) ⬇️
aiguard-windows 35.30% <ø> (-0.09%) ⬇️
apm-capabilities-tracing-macos 49.01% <ø> (-0.06%) ⬇️
apm-capabilities-tracing-ubuntu-active 49.08% <ø> (-0.18%) ⬇️
apm-capabilities-tracing-ubuntu-latest 49.05% <ø> (ø)
apm-capabilities-tracing-ubuntu-maintenance 49.08% <ø> (-0.18%) ⬇️
apm-capabilities-tracing-ubuntu-oldest 49.07% <ø> (-0.18%) ⬇️
apm-capabilities-tracing-windows ?
apm-integrations-aerospike-18-gte.5.2.0 34.46% <ø> (-0.09%) ⬇️
apm-integrations-aerospike-20-gte.5.5.0 34.48% <ø> (-0.09%) ⬇️
apm-integrations-aerospike-22-gte.5.12.1 34.48% <ø> (-0.09%) ⬇️
apm-integrations-aerospike-22-gte.6.0.0 34.48% <ø> (-0.09%) ⬇️
apm-integrations-aerospike-eol- 34.39% <ø> (-0.09%) ⬇️
apm-integrations-child-process 35.45% <ø> (-0.09%) ⬇️
apm-integrations-confluentinc-kafka-javascript-18 41.27% <100.00%> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript-20 41.29% <100.00%> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript-22 41.29% <100.00%> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript-24 41.23% <100.00%> (-0.08%) ⬇️
apm-integrations-couchbase-18 34.64% <ø> (-0.09%) ⬇️
apm-integrations-couchbase-eol 34.64% <ø> (-0.11%) ⬇️
apm-integrations-dns 34.33% <ø> (-0.09%) ⬇️
apm-integrations-elasticsearch 35.11% <ø> (-0.08%) ⬇️
apm-integrations-http-latest 42.26% <ø> (-0.08%) ⬇️
apm-integrations-http-maintenance 42.32% <ø> (-0.08%) ⬇️
apm-integrations-http-oldest 42.32% <ø> (-0.08%) ⬇️
apm-integrations-http2 39.62% <ø> (-0.20%) ⬇️
apm-integrations-kafkajs-latest ?
apm-integrations-kafkajs-oldest 41.19% <87.20%> (-0.10%) ⬇️
apm-integrations-net 35.02% <ø> (-0.09%) ⬇️
apm-integrations-next-11.1.4 29.13% <ø> (-0.08%) ⬇️
apm-integrations-next-13.2.0 30.82% <ø> (-0.08%) ⬇️
apm-integrations-next-gte.10.2.0.and.lt.11 25.41% <ø> (ø)
apm-integrations-next-gte.11.0.0.and.lt.13 30.83% <ø> (-0.08%) ⬇️
apm-integrations-next-gte.13.0.0.and.lt.14 31.07% <ø> (-0.08%) ⬇️
apm-integrations-next-gte.14.0.0.and.lte.14.2.6 30.89% <ø> (-0.08%) ⬇️
apm-integrations-next-gte.14.2.7.and.lt.15 30.89% <ø> (-0.08%) ⬇️
apm-integrations-next-gte.15.0.0 30.96% <ø> (-0.08%) ⬇️
apm-integrations-oracledb ?
apm-integrations-prisma-18-gte.6.16.0.and.lt.7.0.0 36.73% <ø> (-0.08%) ⬇️
apm-integrations-prisma-latest-all 35.54% <ø> (-0.08%) ⬇️
apm-integrations-restify 36.51% <ø> (-0.08%) ⬇️
apm-integrations-sharedb 34.01% <ø> (-0.09%) ⬇️
apm-integrations-tedious 34.56% <ø> (-0.09%) ⬇️
appsec-express 51.99% <ø> (-0.09%) ⬇️
appsec-fastify 48.70% <ø> (-0.07%) ⬇️
appsec-graphql 48.93% <ø> (-0.06%) ⬇️
appsec-integration-active 36.98% <5.43%> (+0.01%) ⬆️
appsec-integration-latest 36.96% <5.43%> (+0.01%) ⬆️
appsec-integration-maintenance 36.98% <5.43%> (+0.01%) ⬆️
appsec-integration-oldest 36.97% <5.43%> (+0.01%) ⬆️
appsec-kafka 41.58% <68.60%> (-0.05%) ⬇️
appsec-ldapjs 40.77% <ø> (-0.07%) ⬇️
appsec-lodash 40.88% <ø> (-0.07%) ⬇️
appsec-macos 55.82% <ø> (-0.06%) ⬇️
appsec-mongodb-core 45.19% <ø> (-0.07%) ⬇️
appsec-mongoose 46.04% <ø> (-0.07%) ⬇️
appsec-mysql 48.07% <ø> (-0.07%) ⬇️
appsec-next-latest-11.1.4 29.25% <ø> (-0.08%) ⬇️
appsec-next-latest-13.2.0 30.96% <ø> (-0.09%) ⬇️
appsec-next-latest-gte.10.2.0.and.lt.11 29.46% <ø> (ø)
appsec-next-latest-gte.11.0.0.and.lt.13 30.95% <ø> (-0.09%) ⬇️
appsec-next-latest-gte.13.0.0.and.lt.14 31.19% <ø> (-0.09%) ⬇️
appsec-next-latest-gte.14.0.0.and.lte.14.2.6 31.04% <ø> (-0.09%) ⬇️
appsec-next-latest-gte.14.2.7.and.lt.15 31.04% <ø> (-0.09%) ⬇️
appsec-next-latest-gte.15.0.0 31.04% <ø> (-0.09%) ⬇️
appsec-next-oldest-11.1.4 29.26% <ø> (-0.09%) ⬇️
appsec-next-oldest-13.2.0 31.24% <ø> (-0.09%) ⬇️
appsec-next-oldest-gte.10.2.0.and.lt.11 29.58% <ø> (ø)
appsec-next-oldest-gte.11.0.0.and.lt.13 30.96% <ø> (-0.09%) ⬇️
appsec-next-oldest-gte.13.0.0.and.lt.14 31.43% <ø> (-0.08%) ⬇️
appsec-next-oldest-gte.14.0.0.and.lte.14.2.6 31.28% <ø> (-0.09%) ⬇️
appsec-next-oldest-gte.14.2.7.and.lt.15 31.28% <ø> (-0.09%) ⬇️
appsec-next-oldest-gte.15.0.0 31.28% <ø> (-0.09%) ⬇️
appsec-node-serialize 40.09% <ø> (-0.07%) ⬇️
appsec-passport 43.81% <ø> (-0.08%) ⬇️
appsec-postgres 47.64% <ø> (-0.07%) ⬇️
appsec-sourcing 39.44% <ø> (-0.07%) ⬇️
appsec-stripe 41.61% <ø> (-0.06%) ⬇️
appsec-template 40.25% <ø> (-0.07%) ⬇️
appsec-ubuntu 55.89% <ø> (-0.06%) ⬇️
appsec-windows 55.76% <ø> (-0.05%) ⬇️
debugger-ubuntu-active 43.31% <ø> (ø)
debugger-ubuntu-latest 43.26% <ø> (ø)
debugger-ubuntu-maintenance 43.32% <ø> (ø)
debugger-ubuntu-oldest 43.75% <ø> (ø)
instrumentations-instrumentation-bluebird 29.37% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-body-parser 37.04% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-child_process 34.94% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-cookie-parser 31.20% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-express 31.41% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize ?
instrumentations-instrumentation-express-session 36.73% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-fs 29.05% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-generic-pool 30.22% <ø> (ø)
instrumentations-instrumentation-http 36.40% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-knex 29.34% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-light-my-request 36.66% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-mongoose 30.45% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-multer 36.82% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-mysql2 34.97% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-passport 40.47% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-passport-http 40.24% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-passport-local 40.73% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-pg 34.54% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-promise 29.30% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-promise-js 29.31% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-q 29.34% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-url 29.31% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-when 29.32% <ø> (-0.09%) ⬇️
instrumentations-integration-esbuild-active 19.50% <5.43%> (+0.01%) ⬆️
instrumentations-integration-esbuild-latest 19.49% <5.43%> (+0.01%) ⬆️
instrumentations-integration-esbuild-maintenance 19.50% <5.43%> (+0.01%) ⬆️
instrumentations-integration-esbuild-oldest 19.49% <5.43%> (+0.01%) ⬆️
llmobs-ai ?
llmobs-anthropic 37.91% <ø> (-0.08%) ⬇️
llmobs-bedrock 36.62% <ø> (-0.08%) ⬇️
llmobs-google-genai 36.93% <ø> (-0.08%) ⬇️
llmobs-langchain ?
llmobs-openai 40.66% <ø> (-0.08%) ⬇️
llmobs-sdk-active 45.50% <ø> (-0.09%) ⬇️
llmobs-sdk-latest 45.44% <ø> (-0.09%) ⬇️
llmobs-sdk-maintenance 45.50% <ø> (-0.09%) ⬇️
llmobs-sdk-oldest 45.49% <ø> (-0.09%) ⬇️
llmobs-vertex-ai 37.08% <ø> (-0.08%) ⬇️
openfeature-macos 38.08% <ø> (-0.01%) ⬇️
openfeature-ubuntu 38.16% <ø> (ø)
openfeature-unit-active 49.12% <ø> (ø)
openfeature-unit-latest 48.96% <ø> (ø)
openfeature-unit-maintenance 49.12% <ø> (ø)
openfeature-unit-oldest 49.12% <ø> (ø)
openfeature-windows 37.96% <ø> (ø)
platform-core 37.27% <ø> (ø)
platform-esbuild 40.61% <ø> (ø)
platform-instrumentations-misc 30.84% <100.00%> (+<0.01%) ⬆️
platform-integration-active 47.12% <ø> (ø)
platform-integration-latest ?
platform-integration-maintenance 47.13% <ø> (ø)
platform-integration-oldest ?
platform-shimmer ?
platform-unit-guardrails 36.12% <ø> (ø)
platform-webpack 20.63% <5.81%> (+0.01%) ⬆️
plugins-azure-durable-functions 37.08% <ø> (ø)
plugins-azure-event-hubs ?
plugins-azure-service-bus 35.41% <ø> (ø)
plugins-bullmq 40.17% <ø> (-0.09%) ⬇️
plugins-cassandra 34.77% <ø> (-0.21%) ⬇️
plugins-cookie 29.37% <ø> (ø)
plugins-cookie-parser 29.17% <ø> (ø)
plugins-crypto 27.69% <ø> (ø)
plugins-dd-trace-api 34.87% <ø> (-0.09%) ⬇️
plugins-express-mongo-sanitize 29.28% <ø> (ø)
plugins-express-session 29.13% <ø> (ø)
plugins-fastify 38.80% <ø> (-0.08%) ⬇️
plugins-fetch 35.13% <ø> (-0.08%) ⬇️
plugins-fs 35.22% <ø> (-0.09%) ⬇️
plugins-generic-pool 28.31% <ø> (ø)
plugins-google-cloud-pubsub 42.50% <ø> (-0.08%) ⬇️
plugins-grpc 37.57% <ø> (-0.08%) ⬇️
plugins-handlebars 29.32% <ø> (ø)
plugins-hapi 36.71% <ø> (-0.09%) ⬇️
plugins-hono 36.99% <ø> (-0.08%) ⬇️
plugins-ioredis ?
plugins-knex 28.89% <ø> (ø)
plugins-langgraph 34.57% <ø> (-0.09%) ⬇️
plugins-ldapjs 26.86% <ø> (ø)
plugins-light-my-request 28.70% <ø> (ø)
plugins-limitd-client 29.60% <ø> (-0.09%) ⬇️
plugins-lodash 28.41% <ø> (ø)
plugins-mariadb 36.25% <ø> (-0.03%) ⬇️
plugins-memcached 34.95% <ø> (-0.09%) ⬇️
plugins-microgateway-core 35.83% <ø> (-0.09%) ⬇️
plugins-modelcontextprotocol-sdk 33.86% <ø> (-0.09%) ⬇️
plugins-moleculer 37.65% <ø> (-0.09%) ⬇️
plugins-mongodb 36.17% <ø> (-0.08%) ⬇️
plugins-mongodb-core 35.90% <ø> (-0.09%) ⬇️
plugins-mongoose 35.65% <ø> (-0.19%) ⬇️
plugins-multer 29.13% <ø> (ø)
plugins-mysql 35.97% <ø> (+0.05%) ⬆️
plugins-mysql2 36.05% <ø> (-0.09%) ⬇️
plugins-node-serialize 29.42% <ø> (ø)
plugins-opensearch 34.65% <ø> (-0.08%) ⬇️
plugins-passport-http 29.14% <ø> (ø)
plugins-pino 31.30% <ø> (-0.09%) ⬇️
plugins-postgres 34.09% <ø> (-0.08%) ⬇️
plugins-process 27.69% <ø> (ø)
plugins-pug 29.37% <ø> (ø)
plugins-redis 35.39% <ø> (-0.09%) ⬇️
plugins-router 39.26% <ø> (+0.04%) ⬆️
plugins-sequelize ?
plugins-test-and-upstream-amqp10 35.19% <ø> (+0.05%) ⬆️
plugins-test-and-upstream-amqplib 40.36% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-apollo 36.04% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-avsc 34.54% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-bunyan 30.68% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-connect 37.37% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-graphql ?
plugins-test-and-upstream-koa 36.96% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-protobufjs 34.74% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-rhea 40.38% <ø> (-0.09%) ⬇️
plugins-undici 35.73% <ø> (-0.20%) ⬇️
plugins-url 27.69% <ø> (ø)
plugins-valkey 34.97% <ø> (-0.09%) ⬇️
plugins-vm 27.69% <ø> (ø)
plugins-winston 31.19% <ø> (-0.09%) ⬇️
plugins-ws 38.47% <ø> (-0.08%) ⬇️
profiling-macos 42.78% <ø> (-0.07%) ⬇️
profiling-ubuntu 43.19% <ø> (-0.07%) ⬇️
profiling-windows 40.10% <ø> (-0.07%) ⬇️
serverless-aws-sdk-latest-aws-sdk ?
serverless-aws-sdk-latest-bedrockruntime ?
serverless-aws-sdk-latest-client 24.82% <ø> (ø)
serverless-aws-sdk-latest-dynamodb 35.78% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-eventbridge 28.86% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-kinesis 38.68% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-lambda ?
serverless-aws-sdk-latest-s3 33.94% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-serverless-peer-service ?
serverless-aws-sdk-latest-sns ?
serverless-aws-sdk-latest-sqs 39.06% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-stepfunctions 34.54% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-util ?
serverless-aws-sdk-oldest-aws-sdk 34.90% <ø> (-0.07%) ⬇️
serverless-aws-sdk-oldest-bedrockruntime 33.45% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-client 25.17% <ø> (ø)
serverless-aws-sdk-oldest-dynamodb 35.86% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-eventbridge 28.90% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-kinesis 38.81% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-lambda 36.04% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-s3 34.00% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-serverless-peer-service 40.10% <ø> (-0.09%) ⬇️
serverless-aws-sdk-oldest-sns 39.97% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-sqs 38.95% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-stepfunctions ?
serverless-aws-sdk-oldest-util ?
serverless-azure-functions-eventhubs 38.56% <ø> (ø)
serverless-azure-functions-servicebus 38.62% <ø> (ø)
serverless-lambda 34.52% <ø> (-0.09%) ⬇️
test-optimization-cucumber-latest-7.0.0 50.36% <ø> (+0.12%) ⬆️
test-optimization-cucumber-latest-latest 53.07% <ø> (+0.12%) ⬆️
test-optimization-cucumber-oldest-7.0.0 50.40% <ø> (+0.12%) ⬆️
test-optimization-cypress-latest-12.0.0-commonJS 48.22% <ø> (-0.46%) ⬇️
test-optimization-cypress-latest-12.0.0-esm 48.62% <ø> (-0.09%) ⬇️
test-optimization-cypress-latest-14.5.4-commonJS 48.07% <ø> (-0.45%) ⬇️
test-optimization-cypress-latest-14.5.4-esm 48.63% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-latest-commonJS 48.37% <ø> (-0.65%) ⬇️
test-optimization-cypress-latest-latest-esm 48.60% <ø> (-0.45%) ⬇️
test-optimization-cypress-oldest-12.0.0-commonJS 48.00% <ø> (-0.72%) ⬇️
test-optimization-cypress-oldest-12.0.0-esm 48.43% <ø> (-0.32%) ⬇️
test-optimization-cypress-oldest-14.5.4-commonJS 48.41% <ø> (-0.15%) ⬇️
test-optimization-cypress-oldest-14.5.4-esm 48.67% <ø> (+0.07%) ⬆️
test-optimization-jest-latest-latest 52.42% <ø> (-2.32%) ⬇️
test-optimization-jest-latest-oldest 53.60% <ø> (+0.05%) ⬆️
test-optimization-jest-oldest-latest 54.82% <ø> (+0.08%) ⬆️
test-optimization-jest-oldest-oldest 51.37% <ø> (-2.12%) ⬇️
test-optimization-mocha-latest-latest 53.36% <ø> (+0.08%) ⬆️
test-optimization-mocha-latest-oldest ?
test-optimization-mocha-oldest-latest 53.45% <ø> (+0.11%) ⬆️
test-optimization-mocha-oldest-oldest 50.92% <ø> (+0.08%) ⬆️
test-optimization-playwright-latest-latest-playwright-active-test-span 44.29% <ø> (+0.28%) ⬆️
test-optimization-playwright-latest-latest-playwright-atr 43.06% <ø> (+0.11%) ⬆️
test-optimization-playwright-latest-latest-playwright-efd 43.49% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-latest-playwright-final-status 43.53% <ø> (+0.13%) ⬆️
test-optimization-playwright-latest-latest-playwright-impacted-tests 42.99% <ø> (ø)
test-optimization-playwright-latest-latest-playwright-reporting 42.94% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-latest-playwright-test-management 44.72% <ø> (+0.10%) ⬆️
test-optimization-playwright-latest-oldest-playwright-active-test-span 44.36% <ø> (+0.28%) ⬆️
test-optimization-playwright-latest-oldest-playwright-atr 43.28% <ø> (+0.11%) ⬆️
test-optimization-playwright-latest-oldest-playwright-efd ?
test-optimization-playwright-latest-oldest-playwright-final-status 43.56% <ø> (+0.08%) ⬆️
test-optimization-playwright-latest-oldest-playwright-impacted-tests 43.04% <ø> (ø)
test-optimization-playwright-latest-oldest-playwright-reporting 43.01% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-oldest-playwright-test-management 44.79% <ø> (+0.10%) ⬆️
test-optimization-playwright-oldest-latest-playwright-active-test-span ?
test-optimization-playwright-oldest-latest-playwright-atr 43.10% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-latest-playwright-efd 43.50% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-latest-playwright-final-status 43.54% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-latest-playwright-impacted-tests 43.03% <ø> (ø)
test-optimization-playwright-oldest-latest-playwright-reporting 42.95% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-latest-playwright-test-management 44.73% <ø> (+0.10%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-active-test-span 44.40% <ø> (+0.28%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-atr 43.31% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-efd ?
test-optimization-playwright-oldest-oldest-playwright-final-status 43.60% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-impacted-tests ?
test-optimization-playwright-oldest-oldest-playwright-reporting 43.02% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-test-management 44.80% <ø> (+0.10%) ⬆️
test-optimization-selenium-latest 45.67% <ø> (+0.07%) ⬆️
test-optimization-selenium-oldest 45.17% <ø> (+0.07%) ⬆️
test-optimization-testopt-active 46.98% <ø> (+0.13%) ⬆️
test-optimization-testopt-latest 46.94% <ø> (+0.13%) ⬆️
test-optimization-testopt-maintenance 46.98% <ø> (+0.13%) ⬆️
test-optimization-testopt-oldest 47.84% <ø> (+0.14%) ⬆️
test-optimization-vitest-latest 51.03% <ø> (+0.10%) ⬆️
test-optimization-vitest-oldest 47.40% <ø> (-0.30%) ⬇️

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-prod-us1-5
Copy link
Copy Markdown

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

🎯 Code Coverage (details)
Patch Coverage: 80.23%
Overall Coverage: 86.80% (-0.03%)

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

@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented May 9, 2026

Benchmarks

Benchmark execution time: 2026-05-12 12:24:07

Comparing candidate commit de9ab75 in PR branch BridgeAR/2026-05-09-kafka-read-clusterid-from-metadata with baseline commit 4ab60e2 in branch master.

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

Comment on lines +31 to +49
addHook({ name: 'kafkajs', file: 'src/producer/index.js', versions: ['>=1.4'] }, (createProducer) =>
shimmer.wrapFunction(createProducer, original => function wrappedCreateProducer (params) {
const producer = original(params)
if (params?.cluster) {
clientToCluster.set(producer, params.cluster)
}
return producer
})
)

addHook({ name: 'kafkajs', file: 'src/consumer/index.js', versions: ['>=1.4'] }, (createConsumer) =>
shimmer.wrapFunction(createConsumer, original => function wrappedCreateConsumer (params) {
const consumer = original(params)
if (params?.cluster) {
clientToCluster.set(consumer, params.cluster)
}
return consumer
})
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why the need for wrapping the same functions that we already wrap below?

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.

These are different functions from different files. The one here receives the cluster property that is created inside of the method that we instrument below. It is the easiest and cleanest to get access to the cluster that way.

Base automatically changed from BridgeAR/2026-05-09-kafka-clone-headers to master May 11, 2026 21:41
The cluster id discovery used a separate `kafka.admin()` connection whose
`describeCluster()` rejection wasn't awaited, surfacing as
`process.unhandledRejection` whenever the admin handshake failed (auth,
broker restart, network blip). Read
`cluster.brokerPool.metadata.clusterId` instead, priming it on first send
via `cluster.refreshMetadataIfNecessary()`; kafkajs's `sharedPromiseTo`
collapses our call with its internal one, so total latency is unchanged.

The cluster reference for each producer/consumer is captured at creation
time via two new `addHook` entries on `src/producer/index.js` /
`src/consumer/index.js` and stored in a `WeakMap` exported from
`helpers/kafka`. The kafkajs object stays untouched — no Symbol-keyed
property to leak through `Reflect.ownKeys`, no string-keyed underscore
for user serializers to pick up, and the entry drops as soon as the
producer is GC'd.

Refs: #5270
Refs: #8253
@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
@BridgeAR BridgeAR marked this pull request as ready for review May 11, 2026 22:22
@BridgeAR BridgeAR requested review from a team as code owners May 11, 2026 22:22
@BridgeAR BridgeAR enabled auto-merge (squash) May 12, 2026 13:44
@BridgeAR BridgeAR merged commit 0402d97 into master May 12, 2026
1168 of 1170 checks passed
@BridgeAR BridgeAR deleted the BridgeAR/2026-05-09-kafka-read-clusterid-from-metadata branch May 12, 2026 13:49
dd-octo-sts Bot pushed a commit that referenced this pull request May 13, 2026
The cluster id discovery used a separate `kafka.admin()` connection whose
`describeCluster()` rejection wasn't awaited, surfacing as
`process.unhandledRejection` whenever the admin handshake failed (auth,
broker restart, network blip). Read
`cluster.brokerPool.metadata.clusterId` instead, priming it on first send
via `cluster.refreshMetadataIfNecessary()`; kafkajs's `sharedPromiseTo`
collapses our call with its internal one, so total latency is unchanged.

The cluster reference for each producer/consumer is captured at creation
time via two new `addHook` entries on `src/producer/index.js` /
`src/consumer/index.js` and stored in a `WeakMap` exported from
`helpers/kafka`. The kafkajs object stays untouched — no Symbol-keyed
property to leak through `Reflect.ownKeys`, no string-keyed underscore
for user serializers to pick up, and the entry drops as soon as the
producer is GC'd.

Refs: #5270
Refs: #8253
@dd-octo-sts dd-octo-sts Bot mentioned this pull request May 13, 2026
rochdev pushed a commit that referenced this pull request May 13, 2026
The cluster id discovery used a separate `kafka.admin()` connection whose
`describeCluster()` rejection wasn't awaited, surfacing as
`process.unhandledRejection` whenever the admin handshake failed (auth,
broker restart, network blip). Read
`cluster.brokerPool.metadata.clusterId` instead, priming it on first send
via `cluster.refreshMetadataIfNecessary()`; kafkajs's `sharedPromiseTo`
collapses our call with its internal one, so total latency is unchanged.

The cluster reference for each producer/consumer is captured at creation
time via two new `addHook` entries on `src/producer/index.js` /
`src/consumer/index.js` and stored in a `WeakMap` exported from
`helpers/kafka`. The kafkajs object stays untouched — no Symbol-keyed
property to leak through `Reflect.ownKeys`, no string-keyed underscore
for user serializers to pick up, and the entry drops as soon as the
producer is GC'd.

Refs: #5270
Refs: #8253
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.

3 participants