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 d3b5b032..79019419 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 @@ -205,6 +205,10 @@ static void configOtelLogExport(ConfigContainer container) { String collectorEndpoint = (String) container.get(ConfigProperty.AGENT_COLLECTOR); if (collectorEndpoint != null) { + if (collectorEndpoint.contains("appoptics.com")) { + return; + } + collectorEndpoint = collectorEndpoint.split(":")[0]; String[] fragments = collectorEndpoint.split("\\."); if (fragments.length > 2) { // This is based on knowledge of the SWO url format where the third name from the left in 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 a4b61b19..c6bd723f 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 @@ -215,6 +215,41 @@ void verifyOtelLogExportEndpointIsProperlyFormed() throws InvalidConfigException System.getProperty("otel.exporter.otlp.logs.endpoint")); } + @Test + @ClearSystemProperty(key = "otel.logs.exporter") + @ClearSystemProperty(key = "otel.exporter.otlp.protocol") + @ClearSystemProperty(key = "otel.exporter.otlp.logs.headers") + @ClearSystemProperty(key = "otel.exporter.otlp.logs.endpoint") + void verifyOtelLogExportEndpointIsProperlyFormedWithPort() throws InvalidConfigException { + ConfigContainer configContainer = new ConfigContainer(); + configContainer.putByStringValue(ConfigProperty.AGENT_SERVICE_KEY, "token:service"); + configContainer.putByStringValue( + ConfigProperty.AGENT_COLLECTOR, "otel.collector.na-01.cloud.solarwinds.com:443"); + + configContainer.putByStringValue(ConfigProperty.AGENT_EXPORT_LOGS_ENABLED, "true"); + ConfigurationLoader.configOtelLogExport(configContainer); + + assertEquals( + "https://otel.collector.na-01.cloud.solarwinds.com", + System.getProperty("otel.exporter.otlp.logs.endpoint")); + } + + @Test + @ClearSystemProperty(key = "otel.logs.exporter") + @ClearSystemProperty(key = "otel.exporter.otlp.protocol") + @ClearSystemProperty(key = "otel.exporter.otlp.logs.headers") + @ClearSystemProperty(key = "otel.exporter.otlp.logs.endpoint") + void verifyOtelLogExportEndpointIsNullForAO() throws InvalidConfigException { + ConfigContainer configContainer = new ConfigContainer(); + configContainer.putByStringValue(ConfigProperty.AGENT_SERVICE_KEY, "token:service"); + configContainer.putByStringValue(ConfigProperty.AGENT_COLLECTOR, "collector.appoptics.com:443"); + + configContainer.putByStringValue(ConfigProperty.AGENT_EXPORT_LOGS_ENABLED, "true"); + ConfigurationLoader.configOtelLogExport(configContainer); + + assertNull(System.getProperty("otel.exporter.otlp.logs.endpoint")); + } + @Test @ClearSystemProperty(key = "otel.logs.exporter") @ClearSystemProperty(key = "otel.exporter.otlp.protocol")