Skip to content

Commit 0d55088

Browse files
committed
Fix LLMObsSpanMapper.MetaWriter.accept to avoid writing a key when there is no value
1 parent ee0fcf7 commit 0d55088

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

dd-trace-core/src/main/java/datadog/trace/llmobs/writer/ddintake/LLMObsSpanMapper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,14 @@ public void accept(Metadata metadata) {
308308
String key = tag.getKey().substring(LLMOBS_TAG_PREFIX.length());
309309
Object val = tag.getValue();
310310
if (key.equals(INPUT) || key.equals(OUTPUT)) {
311-
writable.writeString(key, null);
312311
if (spanKind.equals(Tags.LLMOBS_LLM_SPAN_KIND)) {
313312
if (!(val instanceof List)) {
314313
LOGGER.warn(
315314
"unexpectedly found incorrect type for LLM span IO {}, expecting list",
316315
val.getClass().getName());
317316
continue;
318317
}
318+
writable.writeString(key, null);
319319
writable.startMap(1);
320320
// llm span kind must have llm objects
321321
List<LLMObs.LLMMessage> messages = (List<LLMObs.LLMMessage>) val;
@@ -380,6 +380,7 @@ public void accept(Metadata metadata) {
380380
val.getClass().getName());
381381
continue;
382382
}
383+
writable.writeString(key, null);
383384
writable.startMap(1);
384385
List<LLMObs.Document> documents = (List<LLMObs.Document>) val;
385386
writable.writeString("documents", null);
@@ -390,6 +391,7 @@ public void accept(Metadata metadata) {
390391
writable.writeString(document.getText(), null);
391392
}
392393
} else {
394+
writable.writeString(key, null);
393395
writable.startMap(1);
394396
writable.writeString("value", null);
395397
writable.writeObject(val, null);

0 commit comments

Comments
 (0)