Fix missing consumer_group and topic tags in DSM Kafka 3.8+ metrics by johannbotha · Pull Request #10464 · DataDog/dd-trace-java

dougqh

@johannbotha @claude

The kafka-clients-3.8 instrumentation was calling Optional.get() without
checking isPresent(), causing NoSuchElementException when consumer group
is null. This resulted in missing consumer_group and topic tags in
data_streams.kafka.lag_seconds metrics.

Changes:
- Replace .get() with .orElse(null) in DDOffsetCommitCallback and
  ConsumerCoordinatorAdvice to safely handle empty Optionals
- Fix incorrect null checks in ConstructorAdvice and LegacyConstructorAdvice
  to use isPresent() instead of checking if the Optional object itself is null

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

@johannbotha @claude

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

@johannbotha johannbotha deleted the jj.botha/fix-kafka-38-dsm-missing-consumer-group-tags branch

January 29, 2026 15:10