Skip to content

Commit

Permalink
Set default otel.logs.exporter to otlp
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-berg committed May 10, 2023
1 parent 47ee573 commit 63dcadc
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
4 changes: 2 additions & 2 deletions sdk-extensions/autoconfigure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The following configuration properties are common to all exporters:
|-----------------------|-----------------------|----------------------------------------------------------------------------------------------------------------------------|
| otel.traces.exporter | OTEL_TRACES_EXPORTER | List of exporters to be used for tracing, separated by commas. Default is `otlp`. `none` means no autoconfigured exporter. |
| otel.metrics.exporter | OTEL_METRICS_EXPORTER | List of exporters to be used for metrics, separated by commas. Default is `otlp`. `none` means no autoconfigured exporter. |
| otel.logs.exporter | OTEL_LOGS_EXPORTER | List of exporters to be used for logging, separated by commas. Default is `none`. |
| otel.logs.exporter | OTEL_LOGS_EXPORTER | List of exporters to be used for logging, separated by commas. Default is `otlp`. `none` means no autoconfigured exporter. |

### OTLP exporter (span, metric, and log exporters)

Expand All @@ -64,7 +64,7 @@ The [OpenTelemetry Protocol (OTLP)](https://github.com/open-telemetry/openteleme
|----------------------------------------------------------|----------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| otel.traces.exporter=otlp (default) | OTEL_TRACES_EXPORTER=otlp | Select the OpenTelemetry exporter for tracing (default) |
| otel.metrics.exporter=otlp (default) | OTEL_METRICS_EXPORTER=otlp | Select the OpenTelemetry exporter for metrics (default) |
| otel.logs.exporter=otlp | OTEL_LOGS_EXPORTER=otlp | Select the OpenTelemetry exporter for logs |
| otel.logs.exporter=otlp (default) | OTEL_LOGS_EXPORTER=otlp | Select the OpenTelemetry exporter for logs (default) |
| otel.exporter.otlp.endpoint | OTEL_EXPORTER_OTLP_ENDPOINT | The OTLP traces, metrics, and logs endpoint to connect to. Must be a URL with a scheme of either `http` or `https` based on the use of TLS. If protocol is `http/protobuf` the version and signal will be appended to the path (e.g. `v1/traces`, `v1/metrics`, or `v1/logs`). Default is `http://localhost:4317` when protocol is `grpc`, and `http://localhost:4318/v1/{signal}` when protocol is `http/protobuf`. |
| otel.exporter.otlp.traces.endpoint | OTEL_EXPORTER_OTLP_TRACES_ENDPOINT | The OTLP traces endpoint to connect to. Must be a URL with a scheme of either `http` or `https` based on the use of TLS. Default is `http://localhost:4317` when protocol is `grpc`, and `http://localhost:4318/v1/traces` when protocol is `http/protobuf`. |
| otel.exporter.otlp.metrics.endpoint | OTEL_EXPORTER_OTLP_METRICS_ENDPOINT | The OTLP metrics endpoint to connect to. Must be a URL with a scheme of either `http` or `https` based on the use of TLS. Default is `http://localhost:4317` when protocol is `grpc`, and `http://localhost:4318/v1/metrics` when protocol is `http/protobuf`. |
Expand Down
1 change: 0 additions & 1 deletion sdk-extensions/autoconfigure/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ testing {
targets {
all {
testTask {
environment("OTEL_LOGS_EXPORTER", "otlp")
environment("OTEL_RESOURCE_ATTRIBUTES", "service.name=test,cat=meow")
environment("OTEL_PROPAGATORS", "tracecontext,baggage,b3,b3multi,jaeger,ottrace,test")
environment("OTEL_EXPORTER_OTLP_HEADERS", "cat=meow,dog=bark")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,36 +38,39 @@ static Map<String, LogRecordExporter> configureLogRecordExporters(
logRecordExporterCustomizer,
List<Closeable> closeables) {
Set<String> exporterNames = DefaultConfigProperties.getSet(config, "otel.logs.exporter");

// Default to no exporter
if (exporterNames.isEmpty()) {
exporterNames = Collections.singleton(EXPORTER_NONE);
}

if (exporterNames.contains(EXPORTER_NONE)) {
if (exporterNames.size() > 1) {
throw new ConfigurationException(
"otel.logs.exporter contains " + EXPORTER_NONE + " along with other exporters");
}
return Collections.emptyMap();
LogRecordExporter noop = LogRecordExporter.composite();
LogRecordExporter customized = logRecordExporterCustomizer.apply(noop, config);
if (customized == noop) {
return Collections.emptyMap();
}
closeables.add(customized);
return Collections.singletonMap(EXPORTER_NONE, customized);
}

if (exporterNames.isEmpty()) {
exporterNames = Collections.singleton("otlp");
}

NamedSpiManager<LogRecordExporter> spiExportersManager =
logRecordExporterSpiManager(config, serviceClassLoader);

Map<String, LogRecordExporter> exportersByName = new HashMap<>();
for (String name : exporterNames) {
LogRecordExporter logRecordExporter = configureExporter(name, spiExportersManager);
Map<String, LogRecordExporter> map = new HashMap<>();
for (String exporterName : exporterNames) {
LogRecordExporter logRecordExporter = configureExporter(exporterName, spiExportersManager);
closeables.add(logRecordExporter);
LogRecordExporter customizedLogRecordExporter =
logRecordExporterCustomizer.apply(logRecordExporter, config);
if (customizedLogRecordExporter != logRecordExporter) {
closeables.add(customizedLogRecordExporter);
}
exportersByName.put(name, customizedLogRecordExporter);
map.put(exporterName, customizedLogRecordExporter);
}

return Collections.unmodifiableMap(exportersByName);
return Collections.unmodifiableMap(map);
}

// Visible for testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ class LoggerProviderConfigurationTest {

@Test
void configureLoggerProvider() {
Map<String, String> properties = Collections.singletonMap("otel.logs.exporter", "otlp");
List<Closeable> closeables = new ArrayList<>();

SdkLoggerProviderBuilder builder = SdkLoggerProvider.builder();
LoggerProviderConfiguration.configureLoggerProvider(
builder,
DefaultConfigProperties.createForTest(properties),
DefaultConfigProperties.createForTest(Collections.emptyMap()),
LoggerProviderConfiguration.class.getClassLoader(),
MeterProvider.noop(),
(a, unused) -> a,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ void customizeMeterProvider_Spi() {
"none",
"otel.metrics.exporter",
"none",
"otel.logs.exporter",
"none",
"otel.experimental.metrics.view.config",
"classpath:/view-config-customizer-test.yaml"))
.addMeterProviderCustomizer(
Expand Down

0 comments on commit 63dcadc

Please sign in to comment.