diff --git a/custom/src/main/java/com/solarwinds/opentelemetry/extensions/initialize/ConfigurationLoader.java b/custom/src/main/java/com/solarwinds/opentelemetry/extensions/initialize/ConfigurationLoader.java index 8231eaec..d3b5b032 100644 --- a/custom/src/main/java/com/solarwinds/opentelemetry/extensions/initialize/ConfigurationLoader.java +++ b/custom/src/main/java/com/solarwinds/opentelemetry/extensions/initialize/ConfigurationLoader.java @@ -196,14 +196,14 @@ private static void maybeFollowOtelConfigProperties(ConfigContainer configs) { static void configOtelLogExport(ConfigContainer container) { Boolean exportLog = (Boolean) container.get(ConfigProperty.AGENT_EXPORT_LOGS_ENABLED); - String collectorEndpoint = (String) container.get(ConfigProperty.AGENT_COLLECTOR); - - if (exportLog == null || exportLog) { + if (exportLog != null && exportLog) { String serviceKey = (String) container.get(ConfigProperty.AGENT_SERVICE_KEY); String apiKey = ServiceKeyUtils.getApiKey(serviceKey); String dataCell = "na-01"; String env = "cloud"; + String collectorEndpoint = (String) container.get(ConfigProperty.AGENT_COLLECTOR); + if (collectorEndpoint != null) { String[] fragments = collectorEndpoint.split("\\."); if (fragments.length > 2) { diff --git a/custom/src/test/java/com/solarwinds/opentelemetry/extensions/initialize/ConfigurationLoaderTest.java b/custom/src/test/java/com/solarwinds/opentelemetry/extensions/initialize/ConfigurationLoaderTest.java index 9f76593c..a4b61b19 100644 --- a/custom/src/test/java/com/solarwinds/opentelemetry/extensions/initialize/ConfigurationLoaderTest.java +++ b/custom/src/test/java/com/solarwinds/opentelemetry/extensions/initialize/ConfigurationLoaderTest.java @@ -181,10 +181,9 @@ void verifySettingOtelLogExportSystemVariablesWhenEnabled() throws InvalidConfig @ClearSystemProperty(key = "otel.exporter.otlp.protocol") @ClearSystemProperty(key = "otel.exporter.otlp.logs.headers") @ClearSystemProperty(key = "otel.exporter.otlp.logs.endpoint") - void verifyOtelLogExportSystemVariablesAreNotSetWhenDisabled() throws InvalidConfigException { + void verifyOtelLogExportSystemVariablesAreNotSetWhenNotEnabled() throws InvalidConfigException { ConfigContainer configContainer = new ConfigContainer(); configContainer.putByStringValue(ConfigProperty.AGENT_SERVICE_KEY, "token:service"); - configContainer.putByStringValue(ConfigProperty.AGENT_EXPORT_LOGS_ENABLED, "false"); configContainer.putByStringValue( ConfigProperty.AGENT_COLLECTOR, "apm.collector.na-02.cloud.solarwinds.com"); @@ -208,6 +207,7 @@ void verifyOtelLogExportEndpointIsProperlyFormed() throws InvalidConfigException configContainer.putByStringValue( ConfigProperty.AGENT_COLLECTOR, "apm.collector.na-02.staging.solarwinds.com"); + configContainer.putByStringValue(ConfigProperty.AGENT_EXPORT_LOGS_ENABLED, "true"); ConfigurationLoader.configOtelLogExport(configContainer); assertEquals( @@ -223,6 +223,8 @@ void verifyOtelLogExportEndpointIsProperlyFormed() throws InvalidConfigException void verifyDefaultEndpointIsUsed() throws InvalidConfigException { ConfigContainer configContainer = new ConfigContainer(); configContainer.putByStringValue(ConfigProperty.AGENT_SERVICE_KEY, "token:service"); + + configContainer.putByStringValue(ConfigProperty.AGENT_EXPORT_LOGS_ENABLED, "true"); ConfigurationLoader.configOtelLogExport(configContainer); assertEquals( diff --git a/smoke-tests/src/test/java/com/solarwinds/containers/PetClinicRestContainer.java b/smoke-tests/src/test/java/com/solarwinds/containers/PetClinicRestContainer.java index 0e2a6233..09ea97a0 100644 --- a/smoke-tests/src/test/java/com/solarwinds/containers/PetClinicRestContainer.java +++ b/smoke-tests/src/test/java/com/solarwinds/containers/PetClinicRestContainer.java @@ -85,6 +85,7 @@ public GenericContainer build() { String.format("authorization=Bearer %s", System.getenv("SW_APM_SERVICE_KEY"))) .withEnv("OTEL_SERVICE_NAME", "lambda-e2e") .withEnv("SW_APM_TRANSACTION_NAME", "lambda-test-txn") + .withEnv("SW_APM_EXPORT_LOGS_ENABLED", "true") .withStartupTimeout(Duration.ofMinutes(5)) .withCopyFileToContainer( MountableFile.forHostPath(agentPath), @@ -115,6 +116,7 @@ public GenericContainer build() { .withEnv("SW_APM_SQL_TAG", "true") .withEnv("SW_APM_SQL_TAG_DATABASES", "postgresql") .withEnv("SW_APM_SQL_TAG_PREPARED", "true") + .withEnv("SW_APM_EXPORT_LOGS_ENABLED", "true") .withEnv("SW_APM_COLLECTOR", System.getenv("SW_APM_COLLECTOR")) .withEnv("SW_APM_SERVICE_KEY", String.format("%s:java-apm-smoke-test", System.getenv("SW_APM_SERVICE_KEY"))) .withStartupTimeout(Duration.ofMinutes(5))