Skip to content

Commit 49d370d

Browse files
dougqhclaude
andcommitted
Assert empty additional-tag value is emitted as key="" in OTLP
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent f7244cc commit 49d370d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

dd-trace-core/src/test/java/datadog/trace/core/otlp/metrics/OtlpStatsMetricWriterTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,11 @@ void additionalMetricTagsEmittedInOtelSemanticsMode() throws IOException {
486486
}
487487

488488
@Test
489-
void malformedAdditionalTagsAreSkipped() throws IOException {
490-
// Defensive: a slot with no ':', an empty key, or an empty value is dropped rather than emitted
491-
// as a malformed attribute.
489+
void emptyValueEmittedButMalformedSlotsSkipped() throws IOException {
490+
// A slot with no ':' or an empty key is dropped as malformed. An empty value ("key:") is NOT
491+
// malformed -- aggregation treats an explicitly-empty tag as a distinct dimension from an
492+
// absent
493+
// one, so it is emitted as key="" to keep the OTLP attributes faithful to the aggregate key.
492494
AggregateEntry e =
493495
AggregateEntryTestUtils.of(
494496
"GET /users",
@@ -516,7 +518,8 @@ void malformedAdditionalTagsAreSkipped() throws IOException {
516518
assertEquals("us-east-1", attrs.get("region"), "well-formed tag still emitted");
517519
assertFalse(attrs.containsKey("noseparator"), "no-separator slot skipped");
518520
assertFalse(attrs.containsKey(""), "empty-key slot skipped");
519-
assertFalse(attrs.containsKey("emptyvalue"), "empty-value slot skipped");
521+
assertTrue(attrs.containsKey("emptyvalue"), "empty-value slot emitted");
522+
assertEquals("", attrs.get("emptyvalue"), "empty value emitted as empty string");
520523
}
521524

522525
@Test

0 commit comments

Comments
 (0)