Skip to content

Comments

fix(confluent): add kafka_cluster_id to DSM backlog and checkpoints#7570

Draft
robcarlan-datadog wants to merge 1 commit intorob.carlan/DSMON-1226/kafkajs-dsm-backlog-cluster-idfrom
rob.carlan/DSMON-1226/confluent-dsm-backlog-cluster-id
Draft

fix(confluent): add kafka_cluster_id to DSM backlog and checkpoints#7570
robcarlan-datadog wants to merge 1 commit intorob.carlan/DSMON-1226/kafkajs-dsm-backlog-cluster-idfrom
rob.carlan/DSMON-1226/confluent-dsm-backlog-cluster-id

Conversation

@robcarlan-datadog
Copy link
Contributor

Summary

Builds on #7569 (kafkajs backlog cluster_id fix).

The @confluentinc/kafka-javascript instrumentation never called getKafkaClusterId, so kafka_cluster_id was missing from both DSM checkpoints (edge tags) and backlog offset tracking — a worse version of the kafkajs bug.

  • Extract getKafkaClusterId and isPromise to shared helpers/kafka.js (used by both kafkajs and confluent instrumentations)
  • Update kafkajs instrumentation to import from the shared helper (no behavior change)
  • Add cluster ID retrieval to confluent KafkaJS producer and consumer paths
  • Thread clusterId through producer ctx, consumer extractedArgs, and offset tracking (updateLatestOffset key now includes clusterId to prevent cross-cluster mixing)

Not addressed

The native module path (Producer/KafkaProducer/Consumer/KafkaConsumer classes) does not yet support cluster ID retrieval since it lacks a KafkaJS-style admin API. This could be added in a follow-up using librdkafka's getMetadata().

Test plan

  • Existing confluent DSM tests pass
  • Verify with multi-cluster setup that lag metrics and checkpoints include kafka_cluster_id

Depends on: #7569

🤖 Generated with Claude Code

The confluent-kafka-javascript instrumentation never called
getKafkaClusterId, so cluster_id was missing from both DSM checkpoints
(edge tags) and backlog offset tracking. This causes incorrect pathway
hashes and cross-cluster offset mixing for lag metrics.

Changes:
- Extract getKafkaClusterId/isPromise to shared helpers/kafka.js
- Update kafkajs instrumentation to use shared helper
- Add cluster ID retrieval to confluent KafkaJS producer and consumer
- Thread clusterId through producer ctx, consumer extractedArgs, and
  offset tracking (updateLatestOffset key includes clusterId)

Note: The native module path (Producer/Consumer classes) does not yet
support cluster ID retrieval as it lacks an admin API.

DSMON-1226

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@robcarlan-datadog robcarlan-datadog changed the title fix(confluent): add kafka_cluster_id to DSM backlog and checkpoints [DSMON-1226] fix(confluent): add kafka_cluster_id to DSM backlog and checkpoints Feb 18, 2026
@github-actions
Copy link
Contributor

Overall package size

Self size: 4.68 MB
Deduped: 5.52 MB
No deduping: 5.52 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.6 | 81.92 kB | 813.08 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

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

@datadog-official

This comment has been minimized.

@pr-commenter
Copy link

pr-commenter bot commented Feb 18, 2026

Benchmarks

Benchmark execution time: 2026-02-18 20:35:06

Comparing candidate commit 4919b10 in PR branch rob.carlan/DSMON-1226/confluent-dsm-backlog-cluster-id with baseline commit 2ac6efe in branch rob.carlan/DSMON-1226/kafkajs-dsm-backlog-cluster-id.

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

@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

❌ Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.36%. Comparing base (2ac6efe) to head (4919b10).

Files with missing lines Patch % Lines
...ages/datadog-instrumentations/src/helpers/kafka.js 81.25% 3 Missing ⚠️
Additional details and impacted files
@@                                   Coverage Diff                                    @@
##           rob.carlan/DSMON-1226/kafkajs-dsm-backlog-cluster-id    #7570      +/-   ##
========================================================================================
+ Coverage                                                 80.28%   80.36%   +0.08%     
========================================================================================
  Files                                                       732      732              
  Lines                                                     31477    31437      -40     
========================================================================================
- Hits                                                      25270    25264       -6     
+ Misses                                                     6207     6173      -34     
Flag Coverage Δ
aiguard-macos 39.01% <ø> (ø)
aiguard-ubuntu 39.13% <ø> (ø)
aiguard-windows 38.87% <ø> (ø)
apm-capabilities-tracing-macos 48.37% <ø> (-0.01%) ⬇️
apm-capabilities-tracing-ubuntu 48.41% <ø> (ø)
apm-capabilities-tracing-windows 48.10% <ø> (ø)
apm-integrations-child-process 38.58% <ø> (ø)
apm-integrations-couchbase-18 37.33% <ø> (ø)
apm-integrations-couchbase-eol 37.97% <ø> (ø)
apm-integrations-oracledb 37.81% <ø> (ø)
appsec-express 55.66% <ø> (-0.01%) ⬇️
appsec-fastify 51.97% <ø> (ø)
appsec-graphql 52.14% <ø> (ø)
appsec-kafka 44.57% <82.35%> (+<0.01%) ⬆️
appsec-ldapjs 44.18% <ø> (ø)
appsec-lodash 43.86% <ø> (ø)
appsec-macos ?
appsec-mongodb-core 48.97% <ø> (-0.12%) ⬇️
appsec-mongoose 49.77% <ø> (ø)
appsec-mysql 51.14% <ø> (ø)
appsec-node-serialize 43.37% <ø> (ø)
appsec-passport 47.89% <ø> (ø)
appsec-postgres 50.90% <ø> (ø)
appsec-sourcing 42.72% <ø> (ø)
appsec-template 43.54% <ø> (ø)
appsec-ubuntu 58.83% <ø> (ø)
appsec-windows 58.60% <ø> (-0.02%) ⬇️
instrumentations-instrumentation-bluebird 32.28% <ø> (ø)
instrumentations-instrumentation-body-parser 40.59% <ø> (ø)
instrumentations-instrumentation-child_process 37.89% <ø> (ø)
instrumentations-instrumentation-cookie-parser 34.33% <ø> (ø)
instrumentations-instrumentation-express 34.67% <ø> (ø)
instrumentations-instrumentation-express-mongo-sanitize 34.46% <ø> (ø)
instrumentations-instrumentation-express-session 40.21% <ø> (ø)
instrumentations-instrumentation-fs 31.88% <ø> (ø)
instrumentations-instrumentation-generic-pool 29.76% <ø> (ø)
instrumentations-instrumentation-http 39.93% <ø> (ø)
instrumentations-instrumentation-knex 32.28% <ø> (ø)
instrumentations-instrumentation-mongoose 33.46% <ø> (ø)
instrumentations-instrumentation-multer 40.33% <ø> (ø)
instrumentations-instrumentation-mysql2 38.38% <ø> (ø)
instrumentations-instrumentation-passport 44.18% <ø> (ø)
instrumentations-instrumentation-passport-http 43.85% <ø> (ø)
instrumentations-instrumentation-passport-local 44.40% <ø> (ø)
instrumentations-instrumentation-pg 37.79% <ø> (ø)
instrumentations-instrumentation-promise 32.21% <ø> (ø)
instrumentations-instrumentation-promise-js 32.21% <ø> (ø)
instrumentations-instrumentation-q 32.26% <ø> (ø)
instrumentations-instrumentation-url 32.18% <ø> (ø)
instrumentations-instrumentation-when 32.23% <ø> (ø)
llmobs-ai 41.42% <ø> (ø)
llmobs-anthropic 40.40% <ø> (ø)
llmobs-bedrock 39.32% <ø> (ø)
llmobs-google-genai 39.91% <ø> (ø)
llmobs-langchain 39.49% <ø> (ø)
llmobs-openai 44.23% <ø> (ø)
llmobs-vertex-ai 40.19% <ø> (ø)
platform-core 29.71% <ø> (ø)
platform-esbuild 32.89% <ø> (ø)
platform-instrumentations-misc 40.53% <ø> (ø)
platform-shimmer 36.14% <ø> (ø)
platform-unit-guardrails 31.27% <ø> (ø)
plugins-azure-event-hubs 24.02% <ø> (ø)
plugins-azure-service-bus ?
plugins-bullmq 43.71% <ø> (ø)
plugins-cassandra 37.85% <ø> (ø)
plugins-cookie 25.08% <ø> (ø)
plugins-cookie-parser 24.87% <ø> (ø)
plugins-crypto 24.72% <ø> (ø)
plugins-dd-trace-api 38.43% <ø> (ø)
plugins-express-mongo-sanitize 25.04% <ø> (ø)
plugins-express-session 24.83% <ø> (ø)
plugins-fastify 42.36% <ø> (ø)
plugins-fetch 38.39% <ø> (ø)
plugins-fs 38.68% <ø> (ø)
plugins-generic-pool 24.06% <ø> (ø)
plugins-google-cloud-pubsub 45.51% <ø> (ø)
plugins-grpc 41.05% <ø> (ø)
plugins-handlebars 25.08% <ø> (ø)
plugins-hapi 40.22% <ø> (ø)
plugins-hono 40.49% <ø> (ø)
plugins-ioredis 38.49% <ø> (ø)
plugins-knex 24.80% <ø> (ø)
plugins-ldapjs 22.61% <ø> (ø)
plugins-light-my-request 24.48% <ø> (ø)
plugins-limitd-client 32.58% <ø> (ø)
plugins-lodash 24.13% <ø> (ø)
plugins-mariadb 39.64% <ø> (+0.04%) ⬆️
plugins-memcached 38.22% <ø> (ø)
plugins-microgateway-core 39.25% <ø> (ø)
plugins-moleculer 40.61% <ø> (ø)
plugins-mongodb 39.26% <ø> (ø)
plugins-mongodb-core 39.09% <ø> (ø)
plugins-mongoose 38.94% <ø> (ø)
plugins-multer 24.83% <ø> (ø)
plugins-mysql 39.20% <ø> (-0.04%) ⬇️
plugins-mysql2 39.33% <ø> (ø)
plugins-node-serialize 25.12% <ø> (ø)
plugins-opensearch 37.68% <ø> (ø)
plugins-passport-http 24.91% <ø> (ø)
plugins-postgres 35.73% <ø> (ø)
plugins-process 24.72% <ø> (ø)
plugins-pug 25.08% <ø> (ø)
plugins-redis 38.96% <ø> (ø)
plugins-router 43.12% <ø> (ø)
plugins-sequelize 23.66% <ø> (ø)
plugins-test-and-upstream-amqp10 38.56% <ø> (+0.14%) ⬆️
plugins-test-and-upstream-amqplib 43.90% <ø> (+0.14%) ⬆️
plugins-test-and-upstream-apollo 39.09% <ø> (ø)
plugins-test-and-upstream-avsc 38.82% <ø> (ø)
plugins-test-and-upstream-bunyan 33.89% <ø> (ø)
plugins-test-and-upstream-connect 40.90% <ø> (ø)
plugins-test-and-upstream-graphql 40.23% <ø> (ø)
plugins-test-and-upstream-koa 40.47% <ø> (ø)
plugins-test-and-upstream-protobufjs 39.06% <ø> (ø)
plugins-test-and-upstream-rhea 44.18% <ø> (+0.02%) ⬆️
plugins-undici 39.18% <ø> (ø)
plugins-url 24.72% <ø> (ø)
plugins-valkey 38.11% <ø> (-0.04%) ⬇️
plugins-vm 24.72% <ø> (ø)
plugins-winston 34.08% <ø> (ø)
plugins-ws 42.01% <ø> (ø)
profiling-macos 39.98% <ø> (ø)
profiling-ubuntu 40.11% <ø> (ø)
profiling-windows 41.34% <ø> (ø)
serverless-azure-functions-client 23.75% <ø> (ø)
serverless-azure-functions-eventhubs 23.75% <ø> (ø)
serverless-azure-functions-servicebus 23.75% <ø> (ø)

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.

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.

1 participant