Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions internal-api/src/main/java/datadog/trace/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -2135,7 +2135,9 @@ PROFILING_DATADOG_PROFILER_ENABLED, isDatadogProfilerSafeInCurrentEnvironment())

llmObsAgentlessEnabled =
configProvider.getBoolean(LLMOBS_AGENTLESS_ENABLED, DEFAULT_LLM_OBS_AGENTLESS_ENABLED);
llmObsMlApp = configProvider.getString(LLMOBS_ML_APP);
final String tempLlmObsMlApp = configProvider.getString(LLMOBS_ML_APP);
llmObsMlApp =
tempLlmObsMlApp == null || tempLlmObsMlApp.isEmpty() ? serviceName : tempLlmObsMlApp;

final String llmObsAgentlessUrlStr = getFinalLLMObsUrl();
URI parsedLLMObsUri = null;
Expand Down Expand Up @@ -2642,13 +2644,6 @@ PROFILING_DATADOG_PROFILER_ENABLED, isDatadogProfilerSafeInCurrentEnvironment())
TRACE_POST_PROCESSING_TIMEOUT, DEFAULT_TRACE_POST_PROCESSING_TIMEOUT);

if (isLlmObsEnabled()) {
log.debug("Attempting to enable LLM Observability");
if (llmObsMlApp == null || llmObsMlApp.isEmpty()) {
throw new IllegalArgumentException(
"Attempt to enable LLM Observability without ML app defined."
+ "Please ensure that the name of the ML app is provided through properties or env variable");
}

log.debug(
"LLM Observability enabled for ML app {}, agentless mode {}",
llmObsMlApp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2332,27 +2332,64 @@ class ConfigTest extends DDSpecification {
!hostname.trim().isEmpty()
}

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

when:
new Config(ConfigProvider.withPropertiesOverride(properties))
def config = new Config(ConfigProvider.withPropertiesOverride(properties))

then:
noExceptionThrown()
config.isLlmObsEnabled()
config.llmObsMlApp == "test-service"
}

def "config instantiation should NOT fail if llm obs is enabled via sys prop and ml app is empty"() {
setup:
Properties properties = new Properties()
properties.setProperty(LLMOBS_ENABLED, "true")
properties.setProperty(SERVICE, "test-service")
properties.setProperty(LLMOBS_ML_APP, "")

when:
def config = new Config(ConfigProvider.withPropertiesOverride(properties))

then:
thrown IllegalArgumentException
noExceptionThrown()
config.isLlmObsEnabled()
config.llmObsMlApp == "test-service"
}

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

when:
new Config()
def config = new Config()

then:
thrown IllegalArgumentException
noExceptionThrown()
config.isLlmObsEnabled()
config.llmObsMlApp == "test-service"
}

def "config instantiation should NOT fail if llm obs is enabled via env var and ml app is empty"() {
setup:
environmentVariables.set(DD_LLMOBS_ENABLED_ENV, "true")
environmentVariables.set(DD_SERVICE_NAME_ENV, "test-service")
environmentVariables.set(DD_LLMOBS_ML_APP_ENV, "")

when:
def config = new Config()

then:
noExceptionThrown()
config.isLlmObsEnabled()
config.llmObsMlApp == "test-service"
}


Expand Down