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-86983: make otel log export opt-in only #246

Merged
merged 1 commit into from
Jul 24, 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 @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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(
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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))
Expand Down