-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8108c6
commit 85d0946
Showing
4 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
dd-trace-api/src/main/java/datadog/trace/api/llmobs/LLMObs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package datadog.trace.api.llmobs; | ||
|
||
import datadog.trace.api.llmobs.noop.NoOpLLMObsSpanFactory; | ||
import javax.annotation.Nullable; | ||
|
||
public class LLMObs { | ||
private static LLMObsSpanFactory SPAN_FACTORY = NoOpLLMObsSpanFactory.INSTANCE; | ||
|
||
/** | ||
* This a hook for injecting SpanFactory implementation. It should only be used internally by | ||
* the tracer logic | ||
* | ||
* @param spanFactory span factory instance | ||
*/ | ||
public static void registerSpanFactory(LLMObsSpanFactory spanFactory) { | ||
SPAN_FACTORY = spanFactory; | ||
} | ||
|
||
public static LLMObsSpan startLLMSpan( | ||
String spanName,String modelName, String modelProvider, @Nullable String mlApp, @Nullable String sessionID) { | ||
|
||
return SPAN_FACTORY.startLLMSpan(spanName, modelName, modelProvider, sessionID, mlApp); | ||
} | ||
|
||
public static LLMObsSpan startAgentSpan( | ||
String spanName, @Nullable String mlApp, @Nullable String sessionID) { | ||
|
||
return SPAN_FACTORY.startAgentSpan(spanName, sessionID, mlApp); | ||
} | ||
|
||
public static LLMObsSpan startToolSpan( | ||
String spanName, @Nullable String mlApp, @Nullable String sessionID) { | ||
|
||
return SPAN_FACTORY.startToolSpan(spanName, sessionID, mlApp); | ||
} | ||
|
||
public static LLMObsSpan startTaskSpan( | ||
String spanName, @Nullable String mlApp, @Nullable String sessionID) { | ||
|
||
return SPAN_FACTORY.startTaskSpan(spanName, sessionID, mlApp); | ||
} | ||
|
||
public static LLMObsSpan startWorkflowSpan( | ||
String spanName, @Nullable String mlApp, @Nullable String sessionID) { | ||
|
||
return SPAN_FACTORY.startWorkflowSpan(spanName, sessionID, mlApp); | ||
} | ||
|
||
public interface LLMObsSpanFactory { | ||
LLMObsSpan startLLMSpan(String spanName, String modelName, String modelProvider, @Nullable String mlApp, @Nullable String sessionID); | ||
LLMObsSpan startAgentSpan(String spanName, @Nullable String mlApp, @Nullable String sessionID); | ||
LLMObsSpan startToolSpan(String spanName, @Nullable String mlApp, @Nullable String sessionID); | ||
LLMObsSpan startTaskSpan(String spanName, @Nullable String mlApp, @Nullable String sessionID); | ||
LLMObsSpan startWorkflowSpan(String spanName, @Nullable String mlApp, @Nullable String sessionID); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
dd-trace-api/src/main/java/datadog/trace/api/llmobs/LLMObsSpan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package datadog.trace.api.llmobs; | ||
|
||
/** | ||
* This interface represent an individual LLM Obs span. | ||
*/ | ||
public interface LLMObsSpan { | ||
|
||
/** | ||
* Annotate spans with inputs, outputs, and metadata. | ||
* | ||
* @param key The name of the tag | ||
* @param value The value of the tag | ||
*/ | ||
void annotate(String key, Object value); | ||
} |
10 changes: 10 additions & 0 deletions
10
dd-trace-api/src/main/java/datadog/trace/api/llmobs/noop/NoOpLLMObsSpan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package datadog.trace.api.llmobs.noop; | ||
|
||
import datadog.trace.api.llmobs.LLMObsSpan; | ||
|
||
public class NoOpLLMObsSpan implements LLMObsSpan { | ||
public static final LLMObsSpan INSTANCE = new NoOpLLMObsSpan(); | ||
|
||
@Override | ||
public void annotate(String key, Object value) {} | ||
} |
26 changes: 26 additions & 0 deletions
26
dd-trace-api/src/main/java/datadog/trace/api/llmobs/noop/NoOpLLMObsSpanFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package datadog.trace.api.llmobs.noop; | ||
|
||
import datadog.trace.api.llmobs.LLMObs; | ||
import datadog.trace.api.llmobs.LLMObsSpan; | ||
import javax.annotation.Nullable; | ||
|
||
public class NoOpLLMObsSpanFactory implements LLMObs.LLMObsSpanFactory { | ||
public static final NoOpLLMObsSpanFactory INSTANCE = new NoOpLLMObsSpanFactory(); | ||
|
||
public LLMObsSpan startLLMSpan(String spanName, String modelName, String modelProvider, @Nullable String mlApp, @Nullable String sessionID) { | ||
return NoOpLLMObsSpan.INSTANCE; | ||
} | ||
public LLMObsSpan startAgentSpan(String spanName, @Nullable String mlApp, @Nullable String sessionID) { | ||
return NoOpLLMObsSpan.INSTANCE; | ||
} | ||
public LLMObsSpan startToolSpan(String spanName, @Nullable String mlApp, @Nullable String sessionID) { | ||
return NoOpLLMObsSpan.INSTANCE; | ||
} | ||
public LLMObsSpan startTaskSpan(String spanName, @Nullable String mlApp, @Nullable String sessionID) { | ||
return NoOpLLMObsSpan.INSTANCE; | ||
} | ||
public LLMObsSpan startWorkflowSpan(String spanName, @Nullable String mlApp, @Nullable String sessionID){ | ||
return NoOpLLMObsSpan.INSTANCE; | ||
} | ||
} | ||
|