Skip to content

Commit cb08250

Browse files
authored
Default LLM Observability ML Application to Service Name (#9415)
* config changes * config test changes
1 parent 8fe6484 commit cb08250

File tree

2 files changed

+46
-14
lines changed

2 files changed

+46
-14
lines changed

internal-api/src/main/java/datadog/trace/api/Config.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,9 @@ PROFILING_DATADOG_PROFILER_ENABLED, isDatadogProfilerSafeInCurrentEnvironment())
21402140

21412141
llmObsAgentlessEnabled =
21422142
configProvider.getBoolean(LLMOBS_AGENTLESS_ENABLED, DEFAULT_LLM_OBS_AGENTLESS_ENABLED);
2143-
llmObsMlApp = configProvider.getString(LLMOBS_ML_APP);
2143+
final String tempLlmObsMlApp = configProvider.getString(LLMOBS_ML_APP);
2144+
llmObsMlApp =
2145+
tempLlmObsMlApp == null || tempLlmObsMlApp.isEmpty() ? serviceName : tempLlmObsMlApp;
21442146

21452147
final String llmObsAgentlessUrlStr = getFinalLLMObsUrl();
21462148
URI parsedLLMObsUri = null;
@@ -2647,13 +2649,6 @@ PROFILING_DATADOG_PROFILER_ENABLED, isDatadogProfilerSafeInCurrentEnvironment())
26472649
TRACE_POST_PROCESSING_TIMEOUT, DEFAULT_TRACE_POST_PROCESSING_TIMEOUT);
26482650

26492651
if (isLlmObsEnabled()) {
2650-
log.debug("Attempting to enable LLM Observability");
2651-
if (llmObsMlApp == null || llmObsMlApp.isEmpty()) {
2652-
throw new IllegalArgumentException(
2653-
"Attempt to enable LLM Observability without ML app defined."
2654-
+ "Please ensure that the name of the ML app is provided through properties or env variable");
2655-
}
2656-
26572652
log.debug(
26582653
"LLM Observability enabled for ML app {}, agentless mode {}",
26592654
llmObsMlApp,

internal-api/src/test/groovy/datadog/trace/api/ConfigTest.groovy

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,27 +2332,64 @@ class ConfigTest extends DDSpecification {
23322332
!hostname.trim().isEmpty()
23332333
}
23342334

2335-
def "config instantiation should fail if llm obs is enabled via sys prop and ml app is not set"() {
2335+
def "config instantiation should NOT fail if llm obs is enabled via sys prop and ml app is not set"() {
23362336
setup:
23372337
Properties properties = new Properties()
23382338
properties.setProperty(LLMOBS_ENABLED, "true")
2339+
properties.setProperty(SERVICE, "test-service")
23392340

23402341
when:
2341-
new Config(ConfigProvider.withPropertiesOverride(properties))
2342+
def config = new Config(ConfigProvider.withPropertiesOverride(properties))
2343+
2344+
then:
2345+
noExceptionThrown()
2346+
config.isLlmObsEnabled()
2347+
config.llmObsMlApp == "test-service"
2348+
}
2349+
2350+
def "config instantiation should NOT fail if llm obs is enabled via sys prop and ml app is empty"() {
2351+
setup:
2352+
Properties properties = new Properties()
2353+
properties.setProperty(LLMOBS_ENABLED, "true")
2354+
properties.setProperty(SERVICE, "test-service")
2355+
properties.setProperty(LLMOBS_ML_APP, "")
2356+
2357+
when:
2358+
def config = new Config(ConfigProvider.withPropertiesOverride(properties))
23422359

23432360
then:
2344-
thrown IllegalArgumentException
2361+
noExceptionThrown()
2362+
config.isLlmObsEnabled()
2363+
config.llmObsMlApp == "test-service"
23452364
}
23462365

2347-
def "config instantiation should fail if llm obs is enabled via env var and ml app is not set"() {
2366+
def "config instantiation should NOT fail if llm obs is enabled via env var and ml app is not set"() {
23482367
setup:
23492368
environmentVariables.set(DD_LLMOBS_ENABLED_ENV, "true")
2369+
environmentVariables.set(DD_SERVICE_NAME_ENV, "test-service")
23502370

23512371
when:
2352-
new Config()
2372+
def config = new Config()
23532373

23542374
then:
2355-
thrown IllegalArgumentException
2375+
noExceptionThrown()
2376+
config.isLlmObsEnabled()
2377+
config.llmObsMlApp == "test-service"
2378+
}
2379+
2380+
def "config instantiation should NOT fail if llm obs is enabled via env var and ml app is empty"() {
2381+
setup:
2382+
environmentVariables.set(DD_LLMOBS_ENABLED_ENV, "true")
2383+
environmentVariables.set(DD_SERVICE_NAME_ENV, "test-service")
2384+
environmentVariables.set(DD_LLMOBS_ML_APP_ENV, "")
2385+
2386+
when:
2387+
def config = new Config()
2388+
2389+
then:
2390+
noExceptionThrown()
2391+
config.isLlmObsEnabled()
2392+
config.llmObsMlApp == "test-service"
23562393
}
23572394

23582395

0 commit comments

Comments
 (0)