@@ -3,12 +3,14 @@ package datadog.trace.llmobs.domain
33import datadog.trace.agent.tooling.TracerInstaller
44import datadog.trace.api.DDTags
55import datadog.trace.api.IdGenerationStrategy
6+ import datadog.trace.api.WellKnownTags
67import datadog.trace.api.llmobs.LLMObs
78import datadog.trace.api.llmobs.LLMObsSpan
89import datadog.trace.api.llmobs.LLMObsTags
910import datadog.trace.bootstrap.instrumentation.api.AgentSpan
1011import datadog.trace.bootstrap.instrumentation.api.AgentTracer
1112import datadog.trace.bootstrap.instrumentation.api.Tags
13+ import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString
1214import datadog.trace.core.CoreTracer
1315import datadog.trace.test.util.DDSpecification
1416import org.apache.groovy.util.Maps
@@ -114,6 +116,21 @@ class DDLLMObsSpanTest extends DDSpecification{
114116 assert innerSpan. isError()
115117 assert innerSpan. getTag(DDTags . ERROR_MSG ) instanceof String
116118 assert errMsg. equals(innerSpan. getTag(DDTags . ERROR_MSG ))
119+
120+ assert null == innerSpan. getTag(" env" )
121+ def tagEnv = innerSpan. getTag(LLMOBS_TAG_PREFIX + " env" )
122+ assert tagEnv instanceof UTF8BytesString
123+ assert " test-env" == tagEnv. toString()
124+
125+ assert null == innerSpan. getTag(" service" )
126+ def tagSvc = innerSpan. getTag(LLMOBS_TAG_PREFIX + " service" )
127+ assert tagSvc instanceof UTF8BytesString
128+ assert " test-svc" == tagSvc. toString()
129+
130+ assert null == innerSpan. getTag(" version" )
131+ def tagVersion = innerSpan. getTag(LLMOBS_TAG_PREFIX + " version" )
132+ assert tagVersion instanceof UTF8BytesString
133+ assert " v1" == tagVersion. toString()
117134 }
118135
119136 def " test span with overwrites" () {
@@ -183,6 +200,22 @@ class DDLLMObsSpanTest extends DDSpecification{
183200 assert throwableMsg. equals(innerSpan. getTag(DDTags . ERROR_MSG ))
184201 assert innerSpan. getTag(DDTags . ERROR_STACK ) instanceof String
185202 assert ((String )innerSpan. getTag(DDTags . ERROR_STACK )). contains(throwableMsg)
203+
204+
205+ assert null == innerSpan. getTag(" env" )
206+ def tagEnv = innerSpan. getTag(LLMOBS_TAG_PREFIX + " env" )
207+ assert tagEnv instanceof UTF8BytesString
208+ assert " test-env" == tagEnv. toString()
209+
210+ assert null == innerSpan. getTag(" service" )
211+ def tagSvc = innerSpan. getTag(LLMOBS_TAG_PREFIX + " service" )
212+ assert tagSvc instanceof UTF8BytesString
213+ assert " test-svc" == tagSvc. toString()
214+
215+ assert null == innerSpan. getTag(" version" )
216+ def tagVersion = innerSpan. getTag(LLMOBS_TAG_PREFIX + " version" )
217+ assert tagVersion instanceof UTF8BytesString
218+ assert " v1" == tagVersion. toString()
186219 }
187220
188221 def " test llm span string input formatted to messages" () {
@@ -218,6 +251,22 @@ class DDLLMObsSpanTest extends DDSpecification{
218251 assert expectedOutputMsg. getContent(). equals(output)
219252 assert expectedOutputMsg. getRole(). equals(" unknown" )
220253 assert expectedOutputMsg. getToolCalls(). equals(null )
254+
255+
256+ assert null == innerSpan. getTag(" env" )
257+ def tagEnv = innerSpan. getTag(LLMOBS_TAG_PREFIX + " env" )
258+ assert tagEnv instanceof UTF8BytesString
259+ assert " test-env" == tagEnv. toString()
260+
261+ assert null == innerSpan. getTag(" service" )
262+ def tagSvc = innerSpan. getTag(LLMOBS_TAG_PREFIX + " service" )
263+ assert tagSvc instanceof UTF8BytesString
264+ assert " test-svc" == tagSvc. toString()
265+
266+ assert null == innerSpan. getTag(" version" )
267+ def tagVersion = innerSpan. getTag(LLMOBS_TAG_PREFIX + " version" )
268+ assert tagVersion instanceof UTF8BytesString
269+ assert " v1" == tagVersion. toString()
221270 }
222271
223272 def " test llm span with messages" () {
@@ -259,9 +308,24 @@ class DDLLMObsSpanTest extends DDSpecification{
259308 assert toolCall. getToolId(). equals(" 6176241000" )
260309 def expectedToolArgs = Maps . of(" location" , " paris" )
261310 assert toolCall. getArguments(). equals(expectedToolArgs)
311+
312+ assert null == innerSpan. getTag(" env" )
313+ def tagEnv = innerSpan. getTag(LLMOBS_TAG_PREFIX + " env" )
314+ assert tagEnv instanceof UTF8BytesString
315+ assert " test-env" == tagEnv. toString()
316+
317+ assert null == innerSpan. getTag(" service" )
318+ def tagSvc = innerSpan. getTag(LLMOBS_TAG_PREFIX + " service" )
319+ assert tagSvc instanceof UTF8BytesString
320+ assert " test-svc" == tagSvc. toString()
321+
322+ assert null == innerSpan. getTag(" version" )
323+ def tagVersion = innerSpan. getTag(LLMOBS_TAG_PREFIX + " version" )
324+ assert tagVersion instanceof UTF8BytesString
325+ assert " v1" == tagVersion. toString()
262326 }
263327
264328 private LLMObsSpan givenALLMObsSpan (String kind , name ){
265- new DDLLMObsSpan (kind, name, " test-ml-app" , null , " test-svc" )
329+ new DDLLMObsSpan (kind, name, " test-ml-app" , null , " test-svc" , new WellKnownTags ( " test-runtime-1 " , " host-1 " , " test-env " , " test-svc " , " v1 " , " java " ) )
266330 }
267331}
0 commit comments