Skip to content

Commit 456e775

Browse files
committed
feat(openai-java): propagate global dd_tags to LLMObs span tags
1 parent 879281a commit 456e775

File tree

1 file changed

+6
-0
lines changed
  • dd-java-agent/instrumentation/openai-java/openai-java-3.0/src/main/java/datadog/trace/instrumentation/openai_java

1 file changed

+6
-0
lines changed

dd-java-agent/instrumentation/openai-java/openai-java-3.0/src/main/java/datadog/trace/instrumentation/openai_java/OpenAiDecorator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString;
1414
import datadog.trace.bootstrap.instrumentation.decorator.ClientDecorator;
1515
import java.util.List;
16+
import java.util.Map;
1617

1718
public class OpenAiDecorator extends ClientDecorator {
1819
public static final OpenAiDecorator DECORATE = new OpenAiDecorator();
@@ -91,6 +92,11 @@ protected CharSequence component() {
9192
@Override
9293
public AgentSpan afterStart(AgentSpan span) {
9394
if (llmObsEnabled) {
95+
// set global dd_tags as base layer so UST and span-level tags can override them
96+
for (Map.Entry<String, String> entry : Config.get().getGlobalTags().entrySet()) {
97+
span.setTag(CommonTags.TAG_PREFIX + entry.getKey(), entry.getValue());
98+
}
99+
94100
// set UST (unified service tags, env, service, version)
95101
span.setTag(CommonTags.ENV, wellKnownTags.getEnv());
96102
span.setTag(CommonTags.SERVICE, wellKnownTags.getService());

0 commit comments

Comments
 (0)