Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NH-87394: ensure url is formed when port is appended #249

Merged
merged 1 commit into from
Jul 29, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Copy link
Contributor

@cheempz cheempz Jul 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to have this test! To confirm, if the customer is pointing to AO but somehow enables log export, does our distro still try to automatically set any of the OTel log export system properties? Wondering if the log export setting should just take no effect in this scenario, i.e. the customer would need to manually set all the OTel config needed to export logs to SWO.


@Test
@ClearSystemProperty(key = "otel.logs.exporter")
@ClearSystemProperty(key = "otel.exporter.otlp.protocol")
Expand Down