Add autoconfigure console alias for logging exporter (#6027)
This commit is contained in:
parent
97609a9bdd
commit
7655192df5
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Copyright The OpenTelemetry Authors
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.opentelemetry.exporter.logging.internal;
|
||||||
|
|
||||||
|
import io.opentelemetry.exporter.logging.SystemOutLogRecordExporter;
|
||||||
|
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
||||||
|
import io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogRecordExporterProvider;
|
||||||
|
import io.opentelemetry.sdk.logs.export.LogRecordExporter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link LogRecordExporter} SPI implementation for {@link SystemOutLogRecordExporter}.
|
||||||
|
*
|
||||||
|
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
|
||||||
|
* at any time.
|
||||||
|
*/
|
||||||
|
public final class ConsoleLogRecordExporterProvider
|
||||||
|
implements ConfigurableLogRecordExporterProvider {
|
||||||
|
@Override
|
||||||
|
public LogRecordExporter createExporter(ConfigProperties config) {
|
||||||
|
return SystemOutLogRecordExporter.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "console";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright The OpenTelemetry Authors
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.opentelemetry.exporter.logging.internal;
|
||||||
|
|
||||||
|
import io.opentelemetry.exporter.logging.LoggingMetricExporter;
|
||||||
|
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
||||||
|
import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
|
||||||
|
import io.opentelemetry.sdk.metrics.export.MetricExporter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link MetricExporter} SPI implementation for {@link LoggingMetricExporter}.
|
||||||
|
*
|
||||||
|
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
|
||||||
|
* at any time.
|
||||||
|
*/
|
||||||
|
public final class ConsoleMetricExporterProvider implements ConfigurableMetricExporterProvider {
|
||||||
|
@Override
|
||||||
|
public MetricExporter createExporter(ConfigProperties config) {
|
||||||
|
return LoggingMetricExporter.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "console";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright The OpenTelemetry Authors
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.opentelemetry.exporter.logging.internal;
|
||||||
|
|
||||||
|
import io.opentelemetry.exporter.logging.LoggingSpanExporter;
|
||||||
|
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
||||||
|
import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider;
|
||||||
|
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SpanExporter} SPI implementation for {@link LoggingSpanExporter}.
|
||||||
|
*
|
||||||
|
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
|
||||||
|
* at any time.
|
||||||
|
*/
|
||||||
|
public final class ConsoleSpanExporterProvider implements ConfigurableSpanExporterProvider {
|
||||||
|
@Override
|
||||||
|
public SpanExporter createExporter(ConfigProperties config) {
|
||||||
|
return LoggingSpanExporter.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "console";
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,8 +15,13 @@ import io.opentelemetry.sdk.logs.export.LogRecordExporter;
|
||||||
*
|
*
|
||||||
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
|
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
|
||||||
* at any time.
|
* at any time.
|
||||||
|
*
|
||||||
|
* @deprecated The name {@code logging} is a deprecated alias for {@code console}, which is provided
|
||||||
|
* via {@link ConsoleLogRecordExporterProvider}.
|
||||||
*/
|
*/
|
||||||
public class LoggingLogRecordExporterProvider implements ConfigurableLogRecordExporterProvider {
|
@Deprecated
|
||||||
|
public final class LoggingLogRecordExporterProvider
|
||||||
|
implements ConfigurableLogRecordExporterProvider {
|
||||||
@Override
|
@Override
|
||||||
public LogRecordExporter createExporter(ConfigProperties config) {
|
public LogRecordExporter createExporter(ConfigProperties config) {
|
||||||
return SystemOutLogRecordExporter.create();
|
return SystemOutLogRecordExporter.create();
|
||||||
|
|
|
@ -15,8 +15,12 @@ import io.opentelemetry.sdk.metrics.export.MetricExporter;
|
||||||
*
|
*
|
||||||
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
|
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
|
||||||
* at any time.
|
* at any time.
|
||||||
|
*
|
||||||
|
* @deprecated The name {@code logging} is a deprecated alias for {@code console}, which is provided
|
||||||
|
* via {@link ConsoleMetricExporterProvider}.
|
||||||
*/
|
*/
|
||||||
public class LoggingMetricExporterProvider implements ConfigurableMetricExporterProvider {
|
@Deprecated
|
||||||
|
public final class LoggingMetricExporterProvider implements ConfigurableMetricExporterProvider {
|
||||||
@Override
|
@Override
|
||||||
public MetricExporter createExporter(ConfigProperties config) {
|
public MetricExporter createExporter(ConfigProperties config) {
|
||||||
return LoggingMetricExporter.create();
|
return LoggingMetricExporter.create();
|
||||||
|
|
|
@ -15,8 +15,12 @@ import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||||
*
|
*
|
||||||
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
|
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
|
||||||
* at any time.
|
* at any time.
|
||||||
|
*
|
||||||
|
* @deprecated The name {@code logging} is a deprecated alias for {@code console}, which is provided
|
||||||
|
* via {@link ConsoleSpanExporterProvider}.
|
||||||
*/
|
*/
|
||||||
public class LoggingSpanExporterProvider implements ConfigurableSpanExporterProvider {
|
@Deprecated
|
||||||
|
public final class LoggingSpanExporterProvider implements ConfigurableSpanExporterProvider {
|
||||||
@Override
|
@Override
|
||||||
public SpanExporter createExporter(ConfigProperties config) {
|
public SpanExporter createExporter(ConfigProperties config) {
|
||||||
return LoggingSpanExporter.create();
|
return LoggingSpanExporter.create();
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
io.opentelemetry.exporter.logging.internal.LoggingLogRecordExporterProvider
|
io.opentelemetry.exporter.logging.internal.LoggingLogRecordExporterProvider
|
||||||
|
io.opentelemetry.exporter.logging.internal.ConsoleLogRecordExporterProvider
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
io.opentelemetry.exporter.logging.internal.LoggingMetricExporterProvider
|
io.opentelemetry.exporter.logging.internal.LoggingMetricExporterProvider
|
||||||
|
io.opentelemetry.exporter.logging.internal.ConsoleMetricExporterProvider
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
io.opentelemetry.exporter.logging.internal.LoggingSpanExporterProvider
|
io.opentelemetry.exporter.logging.internal.LoggingSpanExporterProvider
|
||||||
|
io.opentelemetry.exporter.logging.internal.ConsoleSpanExporterProvider
|
||||||
|
|
|
@ -143,9 +143,14 @@ The logging exporter prints the name of the span along with its attributes to st
|
||||||
|
|
||||||
| System property | Environment variable | Description |
|
| System property | Environment variable | Description |
|
||||||
|-------------------------------|-------------------------------|----------------------------------------------------------------------|
|
|-------------------------------|-------------------------------|----------------------------------------------------------------------|
|
||||||
| otel.traces.exporter=logging | OTEL_TRACES_EXPORTER=logging | Select the logging exporter for tracing |
|
| otel.traces.exporter=console | OTEL_TRACES_EXPORTER=console | Select the logging exporter for tracing |
|
||||||
| otel.metrics.exporter=logging | OTEL_METRICS_EXPORTER=logging | Select the logging exporter for metrics |
|
| otel.metrics.exporter=console | OTEL_METRICS_EXPORTER=console | Select the logging exporter for metrics |
|
||||||
| otel.logs.exporter=logging | OTEL_LOGS_EXPORTER=logging | Select the logging exporter for logs |
|
| otel.logs.exporter=console | OTEL_LOGS_EXPORTER=console | Select the logging exporter for logs |
|
||||||
|
|
||||||
|
The logging exporter is also set when `otel.traces.exporter`, `otel.metrics.exporter`,
|
||||||
|
or `otel.logs.exporter` is set to `logging`. `logging` is a deprecated alias for `console`, the
|
||||||
|
preferred value
|
||||||
|
as [defined in the specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#exporter-selection).
|
||||||
|
|
||||||
#### Logging OTLP JSON exporter
|
#### Logging OTLP JSON exporter
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ final class LogRecordExporterConfiguration {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
EXPORTER_ARTIFACT_ID_BY_NAME = new HashMap<>();
|
EXPORTER_ARTIFACT_ID_BY_NAME = new HashMap<>();
|
||||||
|
EXPORTER_ARTIFACT_ID_BY_NAME.put("console", "opentelemetry-exporter-logging");
|
||||||
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging", "opentelemetry-exporter-logging");
|
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging", "opentelemetry-exporter-logging");
|
||||||
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging-otlp", "opentelemetry-exporter-logging-otlp");
|
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging-otlp", "opentelemetry-exporter-logging-otlp");
|
||||||
EXPORTER_ARTIFACT_ID_BY_NAME.put("otlp", "opentelemetry-exporter-otlp");
|
EXPORTER_ARTIFACT_ID_BY_NAME.put("otlp", "opentelemetry-exporter-otlp");
|
||||||
|
|
|
@ -21,6 +21,7 @@ import io.opentelemetry.sdk.logs.export.SimpleLogRecordProcessor;
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -28,6 +29,9 @@ import java.util.function.BiFunction;
|
||||||
|
|
||||||
final class LoggerProviderConfiguration {
|
final class LoggerProviderConfiguration {
|
||||||
|
|
||||||
|
private static final List<String> simpleProcessorExporterNames =
|
||||||
|
Arrays.asList("console", "logging");
|
||||||
|
|
||||||
static void configureLoggerProvider(
|
static void configureLoggerProvider(
|
||||||
SdkLoggerProviderBuilder loggerProviderBuilder,
|
SdkLoggerProviderBuilder loggerProviderBuilder,
|
||||||
ConfigProperties config,
|
ConfigProperties config,
|
||||||
|
@ -64,11 +68,13 @@ final class LoggerProviderConfiguration {
|
||||||
Map<String, LogRecordExporter> exportersByNameCopy = new HashMap<>(exportersByName);
|
Map<String, LogRecordExporter> exportersByNameCopy = new HashMap<>(exportersByName);
|
||||||
List<LogRecordProcessor> logRecordProcessors = new ArrayList<>();
|
List<LogRecordProcessor> logRecordProcessors = new ArrayList<>();
|
||||||
|
|
||||||
LogRecordExporter exporter = exportersByNameCopy.remove("logging");
|
for (String simpleProcessorExporterName : simpleProcessorExporterNames) {
|
||||||
if (exporter != null) {
|
LogRecordExporter exporter = exportersByNameCopy.remove(simpleProcessorExporterName);
|
||||||
LogRecordProcessor logRecordProcessor = SimpleLogRecordProcessor.create(exporter);
|
if (exporter != null) {
|
||||||
closeables.add(logRecordProcessor);
|
LogRecordProcessor logRecordProcessor = SimpleLogRecordProcessor.create(exporter);
|
||||||
logRecordProcessors.add(logRecordProcessor);
|
closeables.add(logRecordProcessor);
|
||||||
|
logRecordProcessors.add(logRecordProcessor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exportersByNameCopy.isEmpty()) {
|
if (!exportersByNameCopy.isEmpty()) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ final class MetricExporterConfiguration {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
EXPORTER_ARTIFACT_ID_BY_NAME = new HashMap<>();
|
EXPORTER_ARTIFACT_ID_BY_NAME = new HashMap<>();
|
||||||
|
EXPORTER_ARTIFACT_ID_BY_NAME.put("console", "opentelemetry-exporter-logging");
|
||||||
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging", "opentelemetry-exporter-logging");
|
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging", "opentelemetry-exporter-logging");
|
||||||
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging-otlp", "opentelemetry-exporter-logging-otlp");
|
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging-otlp", "opentelemetry-exporter-logging-otlp");
|
||||||
EXPORTER_ARTIFACT_ID_BY_NAME.put("otlp", "opentelemetry-exporter-otlp");
|
EXPORTER_ARTIFACT_ID_BY_NAME.put("otlp", "opentelemetry-exporter-otlp");
|
||||||
|
|
|
@ -27,6 +27,7 @@ final class SpanExporterConfiguration {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
EXPORTER_ARTIFACT_ID_BY_NAME = new HashMap<>();
|
EXPORTER_ARTIFACT_ID_BY_NAME = new HashMap<>();
|
||||||
|
EXPORTER_ARTIFACT_ID_BY_NAME.put("console", "opentelemetry-exporter-logging");
|
||||||
EXPORTER_ARTIFACT_ID_BY_NAME.put("jaeger", "opentelemetry-exporter-jaeger");
|
EXPORTER_ARTIFACT_ID_BY_NAME.put("jaeger", "opentelemetry-exporter-jaeger");
|
||||||
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging", "opentelemetry-exporter-logging");
|
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging", "opentelemetry-exporter-logging");
|
||||||
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging-otlp", "opentelemetry-exporter-logging-otlp");
|
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging-otlp", "opentelemetry-exporter-logging-otlp");
|
||||||
|
|
|
@ -23,6 +23,7 @@ import io.opentelemetry.sdk.trace.samplers.Sampler;
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -32,6 +33,8 @@ final class TracerProviderConfiguration {
|
||||||
|
|
||||||
private static final double DEFAULT_TRACEIDRATIO_SAMPLE_RATIO = 1.0d;
|
private static final double DEFAULT_TRACEIDRATIO_SAMPLE_RATIO = 1.0d;
|
||||||
private static final String PARENTBASED_ALWAYS_ON = "parentbased_always_on";
|
private static final String PARENTBASED_ALWAYS_ON = "parentbased_always_on";
|
||||||
|
private static final List<String> simpleProcessorExporterNames =
|
||||||
|
Arrays.asList("console", "logging");
|
||||||
|
|
||||||
static void configureTracerProvider(
|
static void configureTracerProvider(
|
||||||
SdkTracerProviderBuilder tracerProviderBuilder,
|
SdkTracerProviderBuilder tracerProviderBuilder,
|
||||||
|
@ -74,11 +77,13 @@ final class TracerProviderConfiguration {
|
||||||
Map<String, SpanExporter> exportersByNameCopy = new HashMap<>(exportersByName);
|
Map<String, SpanExporter> exportersByNameCopy = new HashMap<>(exportersByName);
|
||||||
List<SpanProcessor> spanProcessors = new ArrayList<>();
|
List<SpanProcessor> spanProcessors = new ArrayList<>();
|
||||||
|
|
||||||
SpanExporter exporter = exportersByNameCopy.remove("logging");
|
for (String simpleProcessorExporterNames : simpleProcessorExporterNames) {
|
||||||
if (exporter != null) {
|
SpanExporter exporter = exportersByNameCopy.remove(simpleProcessorExporterNames);
|
||||||
SpanProcessor spanProcessor = SimpleSpanProcessor.create(exporter);
|
if (exporter != null) {
|
||||||
closeables.add(spanProcessor);
|
SpanProcessor spanProcessor = SimpleSpanProcessor.create(exporter);
|
||||||
spanProcessors.add(spanProcessor);
|
closeables.add(spanProcessor);
|
||||||
|
spanProcessors.add(spanProcessor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exportersByNameCopy.isEmpty()) {
|
if (!exportersByNameCopy.isEmpty()) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||||
|
@ -137,20 +138,25 @@ class ConfigurableSpanExporterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void configureSpanProcessors_simpleSpanProcessor() {
|
void configureSpanProcessors_simpleSpanProcessor() {
|
||||||
String exporterName = "logging";
|
|
||||||
List<Closeable> closeables = new ArrayList<>();
|
List<Closeable> closeables = new ArrayList<>();
|
||||||
|
|
||||||
|
Map<String, SpanExporter> exportersByName = new LinkedHashMap<>();
|
||||||
|
exportersByName.put("console", LoggingSpanExporter.create());
|
||||||
|
exportersByName.put("logging", LoggingSpanExporter.create());
|
||||||
|
|
||||||
List<SpanProcessor> spanProcessors =
|
List<SpanProcessor> spanProcessors =
|
||||||
TracerProviderConfiguration.configureSpanProcessors(
|
TracerProviderConfiguration.configureSpanProcessors(
|
||||||
DefaultConfigProperties.createFromMap(
|
DefaultConfigProperties.createFromMap(
|
||||||
Collections.singletonMap("otel.traces.exporter", exporterName)),
|
Collections.singletonMap("otel.traces.exporter", "console,logging")),
|
||||||
ImmutableMap.of(exporterName, LoggingSpanExporter.create()),
|
exportersByName,
|
||||||
MeterProvider.noop(),
|
MeterProvider.noop(),
|
||||||
closeables);
|
closeables);
|
||||||
cleanup.addCloseables(closeables);
|
cleanup.addCloseables(closeables);
|
||||||
|
|
||||||
assertThat(spanProcessors).hasExactlyElementsOfTypes(SimpleSpanProcessor.class);
|
assertThat(spanProcessors)
|
||||||
assertThat(closeables).hasExactlyElementsOfTypes(SimpleSpanProcessor.class);
|
.hasExactlyElementsOfTypes(SimpleSpanProcessor.class, SimpleSpanProcessor.class);
|
||||||
|
assertThat(closeables)
|
||||||
|
.hasExactlyElementsOfTypes(SimpleSpanProcessor.class, SimpleSpanProcessor.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -31,6 +31,8 @@ class LogRecordExporterConfigurationTest {
|
||||||
LogRecordExporterConfiguration.logRecordExporterSpiManager(
|
LogRecordExporterConfiguration.logRecordExporterSpiManager(
|
||||||
DefaultConfigProperties.createFromMap(Collections.emptyMap()), spiHelper);
|
DefaultConfigProperties.createFromMap(Collections.emptyMap()), spiHelper);
|
||||||
|
|
||||||
|
assertThat(LogRecordExporterConfiguration.configureExporter("console", spiExportersManager))
|
||||||
|
.isInstanceOf(SystemOutLogRecordExporter.class);
|
||||||
assertThat(LogRecordExporterConfiguration.configureExporter("logging", spiExportersManager))
|
assertThat(LogRecordExporterConfiguration.configureExporter("logging", spiExportersManager))
|
||||||
.isInstanceOf(SystemOutLogRecordExporter.class);
|
.isInstanceOf(SystemOutLogRecordExporter.class);
|
||||||
assertThat(
|
assertThat(
|
||||||
|
|
|
@ -7,7 +7,6 @@ package io.opentelemetry.sdk.autoconfigure;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import io.opentelemetry.api.metrics.MeterProvider;
|
import io.opentelemetry.api.metrics.MeterProvider;
|
||||||
import io.opentelemetry.exporter.logging.SystemOutLogRecordExporter;
|
import io.opentelemetry.exporter.logging.SystemOutLogRecordExporter;
|
||||||
import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporter;
|
import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporter;
|
||||||
|
@ -18,12 +17,14 @@ import io.opentelemetry.sdk.logs.LogRecordProcessor;
|
||||||
import io.opentelemetry.sdk.logs.SdkLoggerProvider;
|
import io.opentelemetry.sdk.logs.SdkLoggerProvider;
|
||||||
import io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder;
|
import io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder;
|
||||||
import io.opentelemetry.sdk.logs.export.BatchLogRecordProcessor;
|
import io.opentelemetry.sdk.logs.export.BatchLogRecordProcessor;
|
||||||
|
import io.opentelemetry.sdk.logs.export.LogRecordExporter;
|
||||||
import io.opentelemetry.sdk.logs.export.SimpleLogRecordProcessor;
|
import io.opentelemetry.sdk.logs.export.SimpleLogRecordProcessor;
|
||||||
import io.opentelemetry.sdk.trace.internal.JcTools;
|
import io.opentelemetry.sdk.trace.internal.JcTools;
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
@ -85,26 +86,31 @@ class LoggerProviderConfigurationTest {
|
||||||
void configureLogRecordProcessors_multipleExportersWithLogging() {
|
void configureLogRecordProcessors_multipleExportersWithLogging() {
|
||||||
List<Closeable> closeables = new ArrayList<>();
|
List<Closeable> closeables = new ArrayList<>();
|
||||||
|
|
||||||
|
Map<String, LogRecordExporter> exportersByName = new LinkedHashMap<>();
|
||||||
|
exportersByName.put("console", SystemOutLogRecordExporter.create());
|
||||||
|
exportersByName.put("logging", SystemOutLogRecordExporter.create());
|
||||||
|
exportersByName.put("otlp", OtlpGrpcLogRecordExporter.builder().build());
|
||||||
|
|
||||||
List<LogRecordProcessor> logRecordProcessors =
|
List<LogRecordProcessor> logRecordProcessors =
|
||||||
LoggerProviderConfiguration.configureLogRecordProcessors(
|
LoggerProviderConfiguration.configureLogRecordProcessors(
|
||||||
DefaultConfigProperties.createFromMap(Collections.emptyMap()),
|
DefaultConfigProperties.createFromMap(Collections.emptyMap()),
|
||||||
ImmutableMap.of(
|
exportersByName,
|
||||||
"logging",
|
|
||||||
SystemOutLogRecordExporter.create(),
|
|
||||||
"otlp",
|
|
||||||
OtlpGrpcLogRecordExporter.builder().build()),
|
|
||||||
MeterProvider.noop(),
|
MeterProvider.noop(),
|
||||||
closeables);
|
closeables);
|
||||||
cleanup.addCloseables(closeables);
|
cleanup.addCloseables(closeables);
|
||||||
|
|
||||||
assertThat(logRecordProcessors)
|
assertThat(logRecordProcessors)
|
||||||
.hasSize(2)
|
.hasSize(3)
|
||||||
.hasAtLeastOneElementOfType(SimpleLogRecordProcessor.class)
|
.hasExactlyElementsOfTypes(
|
||||||
.hasAtLeastOneElementOfType(BatchLogRecordProcessor.class);
|
SimpleLogRecordProcessor.class,
|
||||||
|
SimpleLogRecordProcessor.class,
|
||||||
|
BatchLogRecordProcessor.class);
|
||||||
assertThat(closeables)
|
assertThat(closeables)
|
||||||
.hasSize(2)
|
.hasSize(3)
|
||||||
.hasAtLeastOneElementOfType(SimpleLogRecordProcessor.class)
|
.hasExactlyElementsOfTypes(
|
||||||
.hasAtLeastOneElementOfType(BatchLogRecordProcessor.class);
|
SimpleLogRecordProcessor.class,
|
||||||
|
SimpleLogRecordProcessor.class,
|
||||||
|
BatchLogRecordProcessor.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -33,6 +33,8 @@ class SpanExporterConfigurationTest {
|
||||||
SpanExporterConfiguration.spanExporterSpiManager(
|
SpanExporterConfiguration.spanExporterSpiManager(
|
||||||
DefaultConfigProperties.createFromMap(Collections.emptyMap()), spiHelper);
|
DefaultConfigProperties.createFromMap(Collections.emptyMap()), spiHelper);
|
||||||
|
|
||||||
|
assertThat(SpanExporterConfiguration.configureExporter("console", spiExportersManager))
|
||||||
|
.isInstanceOf(LoggingSpanExporter.class);
|
||||||
assertThat(SpanExporterConfiguration.configureExporter("logging", spiExportersManager))
|
assertThat(SpanExporterConfiguration.configureExporter("logging", spiExportersManager))
|
||||||
.isInstanceOf(LoggingSpanExporter.class);
|
.isInstanceOf(LoggingSpanExporter.class);
|
||||||
assertThat(SpanExporterConfiguration.configureExporter("logging-otlp", spiExportersManager))
|
assertThat(SpanExporterConfiguration.configureExporter("logging-otlp", spiExportersManager))
|
||||||
|
|
Loading…
Reference in New Issue