|
25 | 25 | import datadog.trace.api.config.GeneralConfig;
|
26 | 26 | import datadog.trace.api.config.IastConfig;
|
27 | 27 | import datadog.trace.api.config.JmxFetchConfig;
|
| 28 | +import datadog.trace.api.config.LlmObsConfig; |
28 | 29 | import datadog.trace.api.config.ProfilingConfig;
|
29 | 30 | import datadog.trace.api.config.RemoteConfigConfig;
|
30 | 31 | import datadog.trace.api.config.TraceInstrumentationConfig;
|
|
41 | 42 | import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
|
42 | 43 | import datadog.trace.bootstrap.instrumentation.api.AgentTracer.TracerAPI;
|
43 | 44 | import datadog.trace.bootstrap.instrumentation.api.ProfilingContextIntegration;
|
| 45 | +import datadog.trace.bootstrap.instrumentation.api.WriterConstants; |
44 | 46 | import datadog.trace.bootstrap.instrumentation.jfr.InstrumentationBasedProfiling;
|
45 | 47 | import datadog.trace.util.AgentTaskScheduler;
|
46 | 48 | 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 | patchJPSAccess(inst);
|
295 | 320 |
|
@@ -597,6 +622,7 @@ public void execute() {
|
597 | 622 |
|
598 | 623 | maybeStartAppSec(scoClass, sco);
|
599 | 624 | maybeStartCiVisibility(instrumentation, scoClass, sco);
|
| 625 | + maybeStartLLMObs(instrumentation, scoClass, sco); |
600 | 626 | // start debugger before remote config to subscribe to it before starting to poll
|
601 | 627 | maybeStartDebugger(instrumentation, scoClass, sco);
|
602 | 628 | maybeStartRemoteConfig(scoClass, sco);
|
@@ -952,6 +978,24 @@ private static void maybeStartCiVisibility(Instrumentation inst, Class<?> scoCla
|
952 | 978 | }
|
953 | 979 | }
|
954 | 980 |
|
| 981 | + private static void maybeStartLLMObs(Instrumentation inst, Class<?> scoClass, Object sco) { |
| 982 | + if (llmObsEnabled) { |
| 983 | + StaticEventLogger.begin("LLM Observability"); |
| 984 | + |
| 985 | + try { |
| 986 | + final Class<?> llmObsSysClass = |
| 987 | + AGENT_CLASSLOADER.loadClass("datadog.trace.llmobs.LLMObsSystem"); |
| 988 | + final Method llmObsInstallerMethod = |
| 989 | + llmObsSysClass.getMethod("start", Instrumentation.class, scoClass); |
| 990 | + llmObsInstallerMethod.invoke(null, inst, sco); |
| 991 | + } catch (final Throwable e) { |
| 992 | + log.warn("Not starting LLM Observability subsystem", e); |
| 993 | + } |
| 994 | + |
| 995 | + StaticEventLogger.end("LLM Observability"); |
| 996 | + } |
| 997 | + } |
| 998 | + |
955 | 999 | private static void maybeInstallLogsIntake(Class<?> scoClass, Object sco) {
|
956 | 1000 | if (agentlessLogSubmissionEnabled) {
|
957 | 1001 | StaticEventLogger.begin("Logs Intake");
|
|
0 commit comments