Skip to content

Commit cd72321

Browse files
committed
added retrieval and embedding span methods
1 parent 938e591 commit cd72321

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,21 @@ public LLMObsSpan startWorkflowSpan(
189189
Tags.LLMOBS_WORKFLOW_SPAN_KIND, spanName, getMLApp(mlApp), sessionId, serviceName);
190190
}
191191

192+
@Override
193+
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);
197+
}
198+
199+
public LLMObsSpan startRetrievalSpan(
200+
String spanName,
201+
@javax.annotation.Nullable String mlApp,
202+
@javax.annotation.Nullable String sessionId) {
203+
return new DDLLMObsSpan(
204+
Tags.LLMOBS_RETRIEVAL_SPAN_KIND, spanName, getMLApp(mlApp), sessionId, serviceName);
205+
}
206+
192207
private String getMLApp(String mlApp) {
193208
if (mlApp == null || mlApp.isEmpty()) {
194209
return defaultMLApp;

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ public static LLMObsSpan startWorkflowSpan(
4646
return SPAN_FACTORY.startWorkflowSpan(spanName, mlApp, sessionId);
4747
}
4848

49+
public LLMObsSpan startEmbeddingSpan(
50+
String spanName, @Nullable String mlApp, @Nullable String sessionId) {
51+
return SPAN_FACTORY.startEmbeddingSpan(spanName, mlApp, sessionId);
52+
}
53+
54+
public LLMObsSpan startRetrievalSpan(
55+
String spanName, @Nullable String mlApp, @Nullable String sessionId) {
56+
return SPAN_FACTORY.startRetrievalSpan(spanName, mlApp, sessionId);
57+
}
58+
4959
public static void SubmitEvaluation(
5060
LLMObsSpan llmObsSpan, String label, String categoricalValue, Map<String, Object> tags) {
5161
EVAL_PROCESSOR.SubmitEvaluation(llmObsSpan, label, categoricalValue, tags);
@@ -90,6 +100,12 @@ LLMObsSpan startLLMSpan(
90100

91101
LLMObsSpan startWorkflowSpan(
92102
String spanName, @Nullable String mlApp, @Nullable String sessionId);
103+
104+
LLMObsSpan startEmbeddingSpan(
105+
String spanName, @Nullable String mlApp, @Nullable String sessionId);
106+
107+
LLMObsSpan startRetrievalSpan(
108+
String spanName, @Nullable String mlApp, @Nullable String sessionId);
93109
}
94110

95111
public interface LLMObsEvalProcessor {

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,14 @@ public LLMObsSpan startWorkflowSpan(
3535
String spanName, @Nullable String mlApp, @Nullable String sessionId) {
3636
return NoOpLLMObsSpan.INSTANCE;
3737
}
38+
39+
public LLMObsSpan startEmbeddingSpan(
40+
String spanName, @Nullable String mlApp, @Nullable String sessionId) {
41+
return NoOpLLMObsSpan.INSTANCE;
42+
}
43+
44+
public LLMObsSpan startRetrievalSpan(
45+
String spanName, @Nullable String mlApp, @Nullable String sessionId) {
46+
return NoOpLLMObsSpan.INSTANCE;
47+
}
3848
}

internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/Tags.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,6 @@ public class Tags {
166166
public static final String LLMOBS_TASK_SPAN_KIND = "task";
167167
public static final String LLMOBS_AGENT_SPAN_KIND = "agent";
168168
public static final String LLMOBS_TOOL_SPAN_KIND = "tool";
169+
public static final String LLMOBS_EMBEDDING_SPAN_KIND = "embedding";
170+
public static final String LLMOBS_RETRIEVAL_SPAN_KIND = "retrieval";
169171
}

0 commit comments

Comments
 (0)