Commit e307e2c
authored
fix(llmobs): openai-java payload mapping for responses, tool metadata, and prompt tracking (#10644)
llmobs: set model tag even when llmobs disabled
Set metadata.stream tag no matter it's true or false
Set chat/completion CACHE_READ_INPUT_TOKENS tag
Set error nad error_type tags
Use "" instead of null for the role in CompletionDecorator to comply wthTestOpenAiLlmInteractions::test_completion
Use "" instead of null for the content to comply with TestOpenAiLlmInteractions::test_chat_completion_tool_call
Add missing metatadata.tool_choice
Add missing tool_definitions
Add source:integration tag
Add missing _dd attribute to the llmobs span event
Add missing error tags
Remove error from the llmobs span event. It must be part of meta block
Add missing meta.text.verbosity
Add summaryText and encrypted_content
Add missing tool_calls and tool_results for responses
Always set stream param to produce the same request body to be aligned with python openai instrumentation and system-tests
Add OpenAI prompt-tracking reconstruction for responses (input.prompt with variables + chat_template, longest-first overlap handling) and support map-based LLM input serialization (messages + prompt) in LLMObs mapper. Also filter empty instruction messages to match system-test expectations.
Fix OpenAI Responses prompt tracking to use response instructions first and return [image] (not empty) when stripped input_image URLs are missing, aligning mixed-input chat_template output with expected behavior.
Set LLMObs error-path defaults in Java to always emit model_name and output.messages from request params so existing error-span tests pass.
Add OpenAI Responses tool definition extraction to populate LLMObs tool_definitions tags
Fix ChatCompletionServiceTest
Extract JsonValueUtils
Refactor OpenAI responses instrumentation to reuse ToolCallExtractor JSON argument parsing and remove duplicate manual parsing logic from ResponseDecorator.
Fix test assertions
Add integration tag
Add ddtrace.verion
Improve test assertions
Merge branch 'master' into ygree/llmobs-systest-fixes
Fix format
Include input messages when instructions are present in prompt tracking
Fix instructions role to system in prompt tracking
Merge branch 'master' into ygree/llmobs-systest-fixes
fix LLMObsSpanMapperTest
Catch exception not throwable
Add JsonValueUtilsTest
Test that on HTTP error, the OpenAI response span retains model_name and placeholder output set by withResponseCreateParams.
Add "create response with prompt tracking" test to improve coverage of enrichInputWithPromptTracking(), extractChatTemplate(), extractPromptFromParams(), and normalizePromptVariable()
Add "create response with custom tool call" test to improve coverage of getToolCall
Prevent NPE when tag value is null
Replace catch Throwable with catch Exception
responseCreateParamsWithPromptTracking support both known and unknown format. Test cover extractPromptFromParams and related methods
Use safe accessors throughout OpenAI Java decorators
Simplify OpenAI decorator fallbacks without dropping raw JSON support
clean up dead code
improve coverage for chat/completion test with raw tool definition
improve coverage for extractFunctionToolDefinition
improve coverage for extractFunctionToolDefinition
improve coverage for mcp tool call
improve coverage for tool choice
Fix latestDepTest
Co-authored-by: yury.gribkov <yury.gribkov@datadoghq.com>1 parent 65b8d53 commit e307e2c
32 files changed
Lines changed: 3235 additions & 370 deletions
File tree
- dd-java-agent
- agent-llmobs/src
- main/java/datadog/trace/llmobs/domain
- test/groovy/datadog/trace/llmobs/domain
- instrumentation/openai-java/openai-java-3.0
- src
- main/java/datadog/trace/instrumentation/openai_java
- test
- groovy
- java/datadog/trace/instrumentation/openai_java
- resources/http-records
- chat/completions
- responses
- testing/src/main/groovy/datadog/trace/agent/test/asserts
- dd-trace-api/src/main/java/datadog/trace/api/llmobs
- dd-trace-core/src
- main/java/datadog/trace/llmobs/writer/ddintake
- test/groovy/datadog/trace/llmobs/writer/ddintake
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| |||
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
| 81 | + | |
79 | 82 | | |
80 | 83 | | |
81 | 84 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
| 138 | + | |
| 139 | + | |
137 | 140 | | |
138 | 141 | | |
139 | 142 | | |
| |||
219 | 222 | | |
220 | 223 | | |
221 | 224 | | |
| 225 | + | |
| 226 | + | |
222 | 227 | | |
223 | 228 | | |
224 | 229 | | |
| |||
270 | 275 | | |
271 | 276 | | |
272 | 277 | | |
| 278 | + | |
| 279 | + | |
273 | 280 | | |
274 | 281 | | |
275 | 282 | | |
| |||
326 | 333 | | |
327 | 334 | | |
328 | 335 | | |
| 336 | + | |
| 337 | + | |
329 | 338 | | |
330 | 339 | | |
331 | 340 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
Lines changed: 149 additions & 38 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
3 | 7 | | |
| 8 | + | |
4 | 9 | | |
5 | 10 | | |
6 | 11 | | |
| 12 | + | |
7 | 13 | | |
8 | 14 | | |
9 | 15 | | |
| 16 | + | |
10 | 17 | | |
11 | 18 | | |
12 | 19 | | |
| |||
17 | 24 | | |
18 | 25 | | |
19 | 26 | | |
| 27 | + | |
20 | 28 | | |
21 | 29 | | |
22 | 30 | | |
| |||
31 | 39 | | |
32 | 40 | | |
33 | 41 | | |
34 | | - | |
| 42 | + | |
35 | 43 | | |
36 | 44 | | |
| 45 | + | |
| 46 | + | |
37 | 47 | | |
38 | | - | |
39 | | - | |
| 48 | + | |
40 | 49 | | |
41 | 50 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
47 | 60 | | |
48 | 61 | | |
49 | 62 | | |
50 | 63 | | |
51 | 64 | | |
| 65 | + | |
52 | 66 | | |
53 | 67 | | |
54 | 68 | | |
55 | 69 | | |
56 | 70 | | |
57 | 71 | | |
58 | | - | |
59 | | - | |
60 | | - | |
| 72 | + | |
61 | 73 | | |
62 | 74 | | |
63 | 75 | | |
| |||
72 | 84 | | |
73 | 85 | | |
74 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
75 | 179 | | |
76 | 180 | | |
77 | 181 | | |
78 | | - | |
79 | | - | |
80 | 182 | | |
81 | | - | |
82 | | - | |
| 183 | + | |
| 184 | + | |
83 | 185 | | |
84 | | - | |
85 | | - | |
| 186 | + | |
86 | 187 | | |
87 | | - | |
88 | | - | |
| 188 | + | |
89 | 189 | | |
90 | | - | |
91 | | - | |
| 190 | + | |
92 | 191 | | |
93 | | - | |
94 | | - | |
| 192 | + | |
95 | 193 | | |
96 | | - | |
| 194 | + | |
97 | 195 | | |
98 | 196 | | |
99 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
100 | 202 | | |
101 | 203 | | |
102 | 204 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | 205 | | |
107 | 206 | | |
108 | | - | |
| 207 | + | |
109 | 208 | | |
| 209 | + | |
110 | 210 | | |
111 | 211 | | |
112 | 212 | | |
113 | 213 | | |
114 | | - | |
| 214 | + | |
| 215 | + | |
115 | 216 | | |
116 | 217 | | |
117 | 218 | | |
118 | 219 | | |
119 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
120 | 225 | | |
121 | 226 | | |
122 | 227 | | |
123 | 228 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
129 | 238 | | |
130 | | - | |
| 239 | + | |
| 240 | + | |
131 | 241 | | |
132 | | - | |
133 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
134 | 245 | | |
135 | | - | |
| 246 | + | |
136 | 247 | | |
137 | 248 | | |
138 | 249 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
23 | 29 | | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
| 34 | + | |
| 35 | + | |
28 | 36 | | |
29 | 37 | | |
30 | 38 | | |
| |||
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
| 44 | + | |
36 | 45 | | |
0 commit comments