Skip to content

Commit f7244cc

Browse files
dougqhclaude
andcommitted
Emit empty additional-tag values on the OTLP stats export path
Aggregation treats an explicitly-empty configured tag ("key:") as a distinct dimension from an absent one, so it forms a separate aggregate row. The OTLP writer dropped the empty-value slot, which meant an absent-tag row and an empty-value row exported identical attribute sets -- two separately-aggregated points indistinguishable to the backend. Emit the empty value as key="" so the OTLP attributes stay faithful to the aggregate key; only truly-malformed slots (no ':' or empty key) are still skipped. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 763cf32 commit f7244cc

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

dd-trace-core/src/main/java/datadog/trace/core/otlp/metrics/OtlpStatsMetricWriter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,14 @@ private void emitDataPointAttributes(
243243
}
244244

245245
// Splits a packed "key:value" additional-tag string at the first ':' (keys cannot contain ':',
246-
// values may) and emits it as an OTLP string attribute. Skips malformed slots (no ':', empty key
247-
// or empty value) defensively.
246+
// values may) and emits it as an OTLP string attribute. Skips only malformed slots with no ':' or
247+
// an empty key. An empty value ("key:") is emitted as key="": the aggregation path treats an
248+
// explicitly-empty tag as a distinct dimension from an absent one, so dropping it here would
249+
// export two separately-aggregated rows with identical OTLP attribute sets.
248250
private static void emitAdditionalTag(OtlpMetricVisitor metric, UTF8BytesString additionalTag) {
249251
String packed = additionalTag.toString();
250252
int separator = packed.indexOf(':');
251-
if (separator <= 0 || separator == packed.length() - 1) {
253+
if (separator <= 0) {
252254
return;
253255
}
254256
metric.visitAttribute(

0 commit comments

Comments
 (0)