|
26 | 26 | import datadog.trace.api.config.GeneralConfig; |
27 | 27 | import datadog.trace.api.config.IastConfig; |
28 | 28 | import datadog.trace.api.config.JmxFetchConfig; |
| 29 | +import datadog.trace.api.config.LlmObsConfig; |
29 | 30 | import datadog.trace.api.config.ProfilingConfig; |
30 | 31 | import datadog.trace.api.config.RemoteConfigConfig; |
31 | 32 | import datadog.trace.api.config.TraceInstrumentationConfig; |
|
42 | 43 | import datadog.trace.bootstrap.instrumentation.api.AgentTracer; |
43 | 44 | import datadog.trace.bootstrap.instrumentation.api.AgentTracer.TracerAPI; |
44 | 45 | import datadog.trace.bootstrap.instrumentation.api.ProfilingContextIntegration; |
| 46 | +import datadog.trace.bootstrap.instrumentation.api.WriterConstants; |
45 | 47 | import datadog.trace.bootstrap.instrumentation.jfr.InstrumentationBasedProfiling; |
46 | 48 | import datadog.trace.util.AgentTaskScheduler; |
47 | 49 | import datadog.trace.util.AgentThreadFactory.AgentThread; |
@@ -109,7 +111,9 @@ private enum AgentFeature { |
109 | 111 | EXCEPTION_REPLAY(DebuggerConfig.EXCEPTION_REPLAY_ENABLED, false), |
110 | 112 | CODE_ORIGIN(TraceInstrumentationConfig.CODE_ORIGIN_FOR_SPANS_ENABLED, false), |
111 | 113 | DATA_JOBS(GeneralConfig.DATA_JOBS_ENABLED, false), |
112 | | - AGENTLESS_LOG_SUBMISSION(GeneralConfig.AGENTLESS_LOG_SUBMISSION_ENABLED, false); |
| 114 | + AGENTLESS_LOG_SUBMISSION(GeneralConfig.AGENTLESS_LOG_SUBMISSION_ENABLED, false), |
| 115 | + LLMOBS(LlmObsConfig.LLMOBS_ENABLED, false), |
| 116 | + LLMOBS_AGENTLESS(LlmObsConfig.LLMOBS_AGENTLESS_ENABLED, false); |
113 | 117 |
|
114 | 118 | private final String configKey; |
115 | 119 | private final String systemProp; |
@@ -156,6 +160,8 @@ public boolean isEnabledByDefault() { |
156 | 160 | private static boolean iastFullyDisabled; |
157 | 161 | private static boolean cwsEnabled = false; |
158 | 162 | private static boolean ciVisibilityEnabled = false; |
| 163 | + private static boolean llmObsEnabled = false; |
| 164 | + private static boolean llmObsAgentlessEnabled = false; |
159 | 165 | private static boolean usmEnabled = false; |
160 | 166 | private static boolean telemetryEnabled = true; |
161 | 167 | private static boolean dynamicInstrumentationEnabled = false; |
@@ -290,6 +296,25 @@ public static void start( |
290 | 296 | exceptionReplayEnabled = isFeatureEnabled(AgentFeature.EXCEPTION_REPLAY); |
291 | 297 | codeOriginEnabled = isFeatureEnabled(AgentFeature.CODE_ORIGIN); |
292 | 298 | agentlessLogSubmissionEnabled = isFeatureEnabled(AgentFeature.AGENTLESS_LOG_SUBMISSION); |
| 299 | + llmObsEnabled = isFeatureEnabled(AgentFeature.LLMOBS); |
| 300 | + |
| 301 | + // setup writers when llmobs is enabled to accomodate apm and llmobs |
| 302 | + if (llmObsEnabled) { |
| 303 | + // for llm obs spans, use agent proxy by default, apm spans will use agent writer |
| 304 | + setSystemPropertyDefault( |
| 305 | + propertyNameToSystemPropertyName(TracerConfig.WRITER_TYPE), |
| 306 | + WriterConstants.MULTI_WRITER_TYPE |
| 307 | + + ":" |
| 308 | + + WriterConstants.DD_INTAKE_WRITER_TYPE |
| 309 | + + "," |
| 310 | + + WriterConstants.DD_AGENT_WRITER_TYPE); |
| 311 | + if (llmObsAgentlessEnabled) { |
| 312 | + // use API writer only |
| 313 | + setSystemPropertyDefault( |
| 314 | + propertyNameToSystemPropertyName(TracerConfig.WRITER_TYPE), |
| 315 | + WriterConstants.DD_INTAKE_WRITER_TYPE); |
| 316 | + } |
| 317 | + } |
293 | 318 |
|
294 | 319 | if (profilingEnabled) { |
295 | 320 | if (!isOracleJDK8()) { |
@@ -578,6 +603,7 @@ public void execute() { |
578 | 603 |
|
579 | 604 | maybeStartAppSec(scoClass, sco); |
580 | 605 | maybeStartCiVisibility(instrumentation, scoClass, sco); |
| 606 | + maybeStartLLMObs(instrumentation, scoClass, sco); |
581 | 607 | // start debugger before remote config to subscribe to it before starting to poll |
582 | 608 | maybeStartDebugger(instrumentation, scoClass, sco); |
583 | 609 | maybeStartRemoteConfig(scoClass, sco); |
@@ -933,6 +959,24 @@ private static void maybeStartCiVisibility(Instrumentation inst, Class<?> scoCla |
933 | 959 | } |
934 | 960 | } |
935 | 961 |
|
| 962 | + private static void maybeStartLLMObs(Instrumentation inst, Class<?> scoClass, Object sco) { |
| 963 | + if (llmObsEnabled) { |
| 964 | + StaticEventLogger.begin("LLM Observability"); |
| 965 | + |
| 966 | + try { |
| 967 | + final Class<?> llmObsSysClass = |
| 968 | + AGENT_CLASSLOADER.loadClass("datadog.trace.llmobs.LLMObsSystem"); |
| 969 | + final Method llmObsInstallerMethod = |
| 970 | + llmObsSysClass.getMethod("start", Instrumentation.class, scoClass); |
| 971 | + llmObsInstallerMethod.invoke(null, inst, sco); |
| 972 | + } catch (final Throwable e) { |
| 973 | + log.warn("Not starting LLM Observability subsystem", e); |
| 974 | + } |
| 975 | + |
| 976 | + StaticEventLogger.end("LLM Observability"); |
| 977 | + } |
| 978 | + } |
| 979 | + |
936 | 980 | private static void maybeInstallLogsIntake(Class<?> scoClass, Object sco) { |
937 | 981 | if (agentlessLogSubmissionEnabled) { |
938 | 982 | StaticEventLogger.begin("Logs Intake"); |
|
0 commit comments