Skip to content
Draft
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 @@ -158,6 +158,12 @@ public void toJson(JsonWriter writer, Config config) throws IOException {
writer.value(config.isDataStreamsEnabled());
writer.name("data_streams_transaction_extractors");
writer.value(config.getDataStreamsTransactionExtractors());
writer.name("otlp_traces_export_enabled");
writer.value(config.isTraceOtlpExporterEnabled());
writer.name("otlp_metrics_export_enabled");
writer.value(config.isMetricsOtelEnabled() && config.isMetricsOtlpExporterEnabled());
writer.name("otlp_logs_export_enabled");
writer.value(config.isLogsOtelEnabled() && config.isLogsOtlpExporterEnabled());

writer.name("app_logs_collection_enabled");
writer.value(config.isAppLogsCollectionEnabled());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package datadog.trace.core;

import static org.junit.jupiter.api.Assertions.assertEquals;

import com.squareup.moshi.Moshi;
import datadog.trace.api.Config;
import datadog.trace.api.config.OtlpConfig;
import datadog.trace.test.junit.utils.config.WithConfig;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

@Timeout(value = 10, unit = TimeUnit.SECONDS)
public class StatusLoggerTest extends DDCoreJavaSpecification {

@Test
void otlpExportDisabledByDefault() throws IOException {
Map<String, Object> startupLog = startupLog(Config.get());

assertEquals(false, startupLog.get("otlp_traces_export_enabled"));
assertEquals(false, startupLog.get("otlp_metrics_export_enabled"));
assertEquals(false, startupLog.get("otlp_logs_export_enabled"));
}

@Test
@WithConfig(key = OtlpConfig.TRACE_OTEL_EXPORTER, value = "otlp")
@WithConfig(key = OtlpConfig.METRICS_OTEL_ENABLED, value = "true")
@WithConfig(key = OtlpConfig.METRICS_OTEL_EXPORTER, value = "otlp")
@WithConfig(key = OtlpConfig.LOGS_OTEL_ENABLED, value = "true")
@WithConfig(key = OtlpConfig.LOGS_OTEL_EXPORTER, value = "otlp")
void otlpExportEnabledWhenConfigured() throws IOException {
Map<String, Object> startupLog = startupLog(Config.get());

assertEquals(true, startupLog.get("otlp_traces_export_enabled"));
assertEquals(true, startupLog.get("otlp_metrics_export_enabled"));
assertEquals(true, startupLog.get("otlp_logs_export_enabled"));
}

@Test
@WithConfig(key = OtlpConfig.TRACE_OTEL_EXPORTER, value = "otlp")
@WithConfig(key = OtlpConfig.METRICS_OTEL_EXPORTER, value = "otlp")
@WithConfig(key = OtlpConfig.LOGS_OTEL_EXPORTER, value = "otlp")
void metricsAndLogsRequireOtelSignalEnabled() throws IOException {
// The OTLP exporter is selected for every signal, but the metrics and logs OTel signals are
// left disabled, so only trace export should be reported as enabled.
Map<String, Object> startupLog = startupLog(Config.get());

assertEquals(true, startupLog.get("otlp_traces_export_enabled"));
assertEquals(false, startupLog.get("otlp_metrics_export_enabled"));
assertEquals(false, startupLog.get("otlp_logs_export_enabled"));
}

@SuppressWarnings("unchecked")
private static Map<String, Object> startupLog(Config config) throws IOException {
String json =
new Moshi.Builder().add(new StatusLogger()).build().adapter(Config.class).toJson(config);
return (Map<String, Object>) new Moshi.Builder().build().adapter(Object.class).fromJson(json);
}
}
Loading