-
Notifications
You must be signed in to change notification settings - Fork 349
Add in LLM Observability Span Processor API #12112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
sabrenner
wants to merge
12
commits into
master
Choose a base branch
from
sabrenner/llmobs-span-processor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1e94d01
add in llmobs user span processor
sabrenner 9f02ef6
Merge branch 'master' of github.com:DataDog/dd-trace-java into sabren…
sabrenner 9266b45
llmobsspandataadapter test coverage
sabrenner 113074b
add llmobsinternal to internal-api build.gradle.kts
sabrenner a6c3dfe
self review fixes
sabrenner 321245e
handle proper io type for null values of input/output
sabrenner edca622
Merge branch 'master' into sabrenner/llmobs-span-processor
sabrenner 7d89086
address retrieval doc serialization
sabrenner e649223
further guards
sabrenner 6998e51
apply further codex updates - clearing i/o, null error tags
sabrenner f07c0f9
Merge branch 'master' into sabrenner/llmobs-span-processor
sabrenner f02ee92
Apply suggestion from @sabrenner
sabrenner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
13 changes: 0 additions & 13 deletions
13
dd-java-agent/agent-llmobs/src/main/java/datadog/trace/llmobs/domain/LLMObsInternal.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
61 changes: 61 additions & 0 deletions
61
dd-trace-api/src/main/java/datadog/trace/api/llmobs/LLMObsSpanData.java
This file contains hidden or 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,61 @@ | ||
| package datadog.trace.api.llmobs; | ||
|
|
||
| import java.util.List; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| /** | ||
| * Mutable view of an LLM Observability span passed to a registered {@link LLMObsSpanProcessor}. | ||
| * | ||
| * <p>Changes to the input and output are applied immediately before the span is sent to LLM | ||
| * Observability. | ||
| */ | ||
| public interface LLMObsSpanData { | ||
|
|
||
| /** | ||
| * Gets the LLM Observability span kind. | ||
| * | ||
| * @return the span kind | ||
| */ | ||
| String getKind(); | ||
|
|
||
| /** | ||
| * Gets the input content associated with the span. | ||
| * | ||
| * @return the input represented as messages | ||
| */ | ||
| List<LLMObs.LLMMessage> getInput(); | ||
|
|
||
| /** | ||
| * Replaces the input content associated with the span. | ||
| * | ||
| * <p>Other input metadata, including prompt tracking information, is preserved. | ||
| * | ||
| * @param input the new input represented as messages | ||
| * @throws NullPointerException if {@code input} is {@code null} | ||
| */ | ||
| void setInput(List<LLMObs.LLMMessage> input); | ||
|
|
||
| /** | ||
| * Gets the output content associated with the span. | ||
| * | ||
| * @return the output represented as messages | ||
| */ | ||
| List<LLMObs.LLMMessage> getOutput(); | ||
|
|
||
| /** | ||
| * Replaces the output content associated with the span. | ||
| * | ||
| * @param output the new output represented as messages | ||
| * @throws NullPointerException if {@code output} is {@code null} | ||
| */ | ||
| void setOutput(List<LLMObs.LLMMessage> output); | ||
|
|
||
| /** | ||
| * Gets an LLM Observability tag from the span. | ||
| * | ||
| * @param key the unprefixed tag name | ||
| * @return the tag value, or {@code null} when the tag is not present | ||
| */ | ||
| @Nullable | ||
| String getTag(String key); | ||
| } |
20 changes: 20 additions & 0 deletions
20
dd-trace-api/src/main/java/datadog/trace/api/llmobs/LLMObsSpanProcessor.java
This file contains hidden or 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,20 @@ | ||
| package datadog.trace.api.llmobs; | ||
|
|
||
| import javax.annotation.Nullable; | ||
|
|
||
| /** Processes LLM Observability spans before they are sent. */ | ||
| @FunctionalInterface | ||
| public interface LLMObsSpanProcessor { | ||
|
|
||
| /** | ||
| * Processes an LLM Observability span. | ||
| * | ||
| * <p>The processor may mutate and return {@code span}, or return {@code null} to omit the span | ||
| * from LLM Observability. | ||
| * | ||
| * @param span the span being processed | ||
| * @return the span to send, or {@code null} to omit it | ||
| */ | ||
| @Nullable | ||
| LLMObsSpanData process(LLMObsSpanData span); | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added this to help with knowing when mapping is retried for our LLMObsSpanMapper, as we do not want to re-trigger the user span-proessor in that case. I think I've set it up so that it's backwards compatible and CI seems to agree, but let me know if this is an issue!