Enable otlp logs by default (#5433)
This commit is contained in:
parent
bf8be57253
commit
85f3fd8545
|
@ -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)
|
||||
|
||||
|
@ -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`. |
|
||||
|
|
|
@ -76,7 +76,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")
|
||||
|
|
|
@ -38,36 +38,39 @@ class LogRecordExporterConfiguration {
|
|||
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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -36,6 +36,8 @@ class ViewConfigCustomizerTest {
|
|||
"none",
|
||||
"otel.metrics.exporter",
|
||||
"none",
|
||||
"otel.logs.exporter",
|
||||
"none",
|
||||
"otel.experimental.metrics.view.config",
|
||||
"classpath:/view-config-customizer-test.yaml"))
|
||||
.addMeterProviderCustomizer(
|
||||
|
|
Loading…
Reference in New Issue