Skip to content

Commit ad8e42a

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 49f7a64 commit ad8e42a

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
@@ -247,12 +247,14 @@ private void emitDataPointAttributes(
247247
}
248248

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

0 commit comments

Comments
 (0)