Skip to content

Commit e079290

Browse files
committed
applied fixes from comments
1 parent cd72321 commit e079290

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

dd-java-agent/agent-llmobs/src/main/java/datadog/trace/llmobs/LLMObsSystem.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.lang.instrument.Instrumentation;
1313
import java.util.Map;
1414
import java.util.concurrent.TimeUnit;
15-
import org.jetbrains.annotations.Nullable;
15+
import javax.annotation.Nullable;
1616
import org.slf4j.Logger;
1717
import org.slf4j.LoggerFactory;
1818

@@ -191,15 +191,22 @@ public LLMObsSpan startWorkflowSpan(
191191

192192
@Override
193193
public LLMObsSpan startEmbeddingSpan(
194-
String spanName, @Nullable String mlApp, @Nullable String sessionId) {
195-
return new DDLLMObsSpan(
196-
Tags.LLMOBS_EMBEDDING_SPAN_KIND, spanName, getMLApp(mlApp), sessionId, serviceName);
194+
String spanName,
195+
@Nullable String mlApp,
196+
@Nullable String mlProvider,
197+
@Nullable String sessionId) {
198+
if (mlProvider == null) {
199+
mlProvider = "custom";
200+
}
201+
DDLLMObsSpan embeddingSpan =
202+
new DDLLMObsSpan(
203+
Tags.LLMOBS_EMBEDDING_SPAN_KIND, spanName, getMLApp(mlApp), sessionId, serviceName);
204+
embeddingSpan.setTag("ml.provider", mlProvider);
205+
return embeddingSpan;
197206
}
198207

199208
public LLMObsSpan startRetrievalSpan(
200-
String spanName,
201-
@javax.annotation.Nullable String mlApp,
202-
@javax.annotation.Nullable String sessionId) {
209+
String spanName, @Nullable String mlApp, @Nullable String sessionId) {
203210
return new DDLLMObsSpan(
204211
Tags.LLMOBS_RETRIEVAL_SPAN_KIND, spanName, getMLApp(mlApp), sessionId, serviceName);
205212
}

dd-trace-api/src/main/java/datadog/trace/api/llmobs/LLMObs.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ public static LLMObsSpan startWorkflowSpan(
4747
}
4848

4949
public LLMObsSpan startEmbeddingSpan(
50-
String spanName, @Nullable String mlApp, @Nullable String sessionId) {
51-
return SPAN_FACTORY.startEmbeddingSpan(spanName, mlApp, sessionId);
50+
String spanName,
51+
@Nullable String mlApp,
52+
@Nullable String mlProvider,
53+
@Nullable String sessionId) {
54+
return SPAN_FACTORY.startEmbeddingSpan(spanName, mlApp, mlProvider, sessionId);
5255
}
5356

5457
public LLMObsSpan startRetrievalSpan(
@@ -102,7 +105,10 @@ LLMObsSpan startWorkflowSpan(
102105
String spanName, @Nullable String mlApp, @Nullable String sessionId);
103106

104107
LLMObsSpan startEmbeddingSpan(
105-
String spanName, @Nullable String mlApp, @Nullable String sessionId);
108+
String spanName,
109+
@Nullable String mlApp,
110+
@Nullable String mlProvider,
111+
@Nullable String sessionId);
106112

107113
LLMObsSpan startRetrievalSpan(
108114
String spanName, @Nullable String mlApp, @Nullable String sessionId);

dd-trace-api/src/main/java/datadog/trace/api/llmobs/noop/NoOpLLMObsSpanFactory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ public LLMObsSpan startWorkflowSpan(
3737
}
3838

3939
public LLMObsSpan startEmbeddingSpan(
40-
String spanName, @Nullable String mlApp, @Nullable String sessionId) {
40+
String spanName,
41+
@Nullable String mlApp,
42+
@Nullable String mlProvider,
43+
@Nullable String sessionId) {
4144
return NoOpLLMObsSpan.INSTANCE;
4245
}
4346

0 commit comments

Comments
 (0)