Move autoconfigure exporter tests (#5051)
* Move SPI logging-otlp tests to :exporters:logging-otlp * Move SPI zipkin tests to :exporters:zipkin * Move SPI jaeger tests to :exporters:jaeger * Spotless
This commit is contained in:
parent
2fbdd94a33
commit
7f0889a6a3
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.exporter.jaeger.internal;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import okhttp3.HttpUrl;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class JaegerGrpcSpanExporterProviderTest {
|
||||
|
||||
private static final JaegerGrpcSpanExporterProvider provider =
|
||||
new JaegerGrpcSpanExporterProvider();
|
||||
|
||||
@Test
|
||||
void getName() {
|
||||
assertThat(provider.getName()).isEqualTo("jaeger");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createExporter_Default() {
|
||||
try (SpanExporter spanExporter =
|
||||
provider.createExporter(DefaultConfigProperties.createForTest(Collections.emptyMap()))) {
|
||||
assertThat(spanExporter).isInstanceOf(JaegerGrpcSpanExporter.class);
|
||||
assertThat(spanExporter)
|
||||
.extracting("delegate")
|
||||
.extracting("client")
|
||||
.extracting("callTimeoutMillis")
|
||||
.isEqualTo(10000);
|
||||
assertThat(spanExporter)
|
||||
.extracting("delegate")
|
||||
.extracting("url")
|
||||
.isEqualTo(
|
||||
HttpUrl.get("http://localhost:14250/jaeger.api_v2.CollectorService/PostSpans"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void createExporter_WithConfiguration() {
|
||||
Map<String, String> config = new HashMap<>();
|
||||
config.put("otel.exporter.jaeger.endpoint", "http://endpoint:8080");
|
||||
config.put("otel.exporter.jaeger.timeout", "1s");
|
||||
|
||||
try (SpanExporter spanExporter =
|
||||
provider.createExporter(DefaultConfigProperties.createForTest(config))) {
|
||||
assertThat(spanExporter).isInstanceOf(JaegerGrpcSpanExporter.class);
|
||||
assertThat(spanExporter)
|
||||
.extracting("delegate")
|
||||
.extracting("client")
|
||||
.extracting("callTimeoutMillis")
|
||||
.isEqualTo(1000);
|
||||
assertThat(spanExporter)
|
||||
.extracting("delegate")
|
||||
.extracting("url")
|
||||
.isEqualTo(HttpUrl.get("http://endpoint:8080/jaeger.api_v2.CollectorService/PostSpans"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.exporter.logging.otlp.internal;
|
||||
|
||||
import static io.opentelemetry.sdk.testing.assertj.LogAssertions.assertThat;
|
||||
|
||||
import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingLogRecordExporter;
|
||||
import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingMetricExporter;
|
||||
import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingSpanExporter;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
|
||||
import java.util.Collections;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class LoggingExporterProviderTest {
|
||||
|
||||
@Test
|
||||
void logRecordExporterProvider() {
|
||||
LoggingLogRecordExporterProvider provider = new LoggingLogRecordExporterProvider();
|
||||
assertThat(provider.getName()).isEqualTo("logging-otlp");
|
||||
assertThat(
|
||||
provider.createExporter(DefaultConfigProperties.createForTest(Collections.emptyMap())))
|
||||
.isInstanceOf(OtlpJsonLoggingLogRecordExporter.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void metricExporterProvider() {
|
||||
LoggingMetricExporterProvider provider = new LoggingMetricExporterProvider();
|
||||
assertThat(provider.getName()).isEqualTo("logging-otlp");
|
||||
assertThat(
|
||||
provider.createExporter(DefaultConfigProperties.createForTest(Collections.emptyMap())))
|
||||
.isInstanceOf(OtlpJsonLoggingMetricExporter.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void spanExporterProvider() {
|
||||
LoggingSpanExporterProvider provider = new LoggingSpanExporterProvider();
|
||||
assertThat(provider.getName()).isEqualTo("logging-otlp");
|
||||
assertThat(
|
||||
provider.createExporter(DefaultConfigProperties.createForTest(Collections.emptyMap())))
|
||||
.isInstanceOf(OtlpJsonLoggingSpanExporter.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.exporter.zipkin.internal;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import io.opentelemetry.exporter.zipkin.ZipkinSpanExporter;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import okhttp3.HttpUrl;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ZipkinSpanExporterProviderTest {
|
||||
|
||||
private static final ZipkinSpanExporterProvider provider = new ZipkinSpanExporterProvider();
|
||||
|
||||
@Test
|
||||
void getName() {
|
||||
assertThat(provider.getName()).isEqualTo("zipkin");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createExporter_Default() {
|
||||
try (SpanExporter spanExporter =
|
||||
provider.createExporter(DefaultConfigProperties.createForTest(Collections.emptyMap()))) {
|
||||
assertThat(spanExporter).isInstanceOf(ZipkinSpanExporter.class);
|
||||
assertThat(spanExporter)
|
||||
.extracting("sender")
|
||||
.extracting("client")
|
||||
.extracting("readTimeoutMillis")
|
||||
.isEqualTo(10_000);
|
||||
assertThat(spanExporter)
|
||||
.extracting("sender")
|
||||
.extracting("endpoint")
|
||||
.isEqualTo(HttpUrl.get("http://localhost:9411/api/v2/spans"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void createExporter_WithConfiguration() {
|
||||
Map<String, String> config = new HashMap<>();
|
||||
config.put("otel.exporter.zipkin.endpoint", "http://localhost:8080/spans");
|
||||
config.put("otel.exporter.zipkin.timeout", "1s");
|
||||
|
||||
try (SpanExporter spanExporter =
|
||||
provider.createExporter(DefaultConfigProperties.createForTest(config))) {
|
||||
assertThat(spanExporter).isInstanceOf(ZipkinSpanExporter.class);
|
||||
assertThat(spanExporter)
|
||||
.extracting("sender")
|
||||
.extracting("client")
|
||||
.extracting("readTimeoutMillis")
|
||||
.isEqualTo(1000);
|
||||
assertThat(spanExporter)
|
||||
.extracting("sender")
|
||||
.extracting("endpoint")
|
||||
.isEqualTo(HttpUrl.get("http://localhost:8080/spans"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.sdk.autoconfigure;
|
||||
package io.opentelemetry.sdk.autoconfigure.spi.internal;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
|
@ -13,7 +13,6 @@ import static org.assertj.core.api.Assertions.entry;
|
|||
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
|
@ -69,6 +69,7 @@ testing {
|
|||
implementation(project(":extensions:trace-propagators"))
|
||||
implementation(project(":exporters:jaeger"))
|
||||
implementation(project(":exporters:logging"))
|
||||
implementation(project(":exporters:logging-otlp"))
|
||||
implementation(project(":exporters:otlp:all"))
|
||||
implementation(project(":exporters:otlp:logs"))
|
||||
implementation(project(":exporters:otlp:common"))
|
||||
|
|
@ -112,32 +113,6 @@ testing {
|
|||
}
|
||||
}
|
||||
}
|
||||
val testJaeger by registering(JvmTestSuite::class) {
|
||||
dependencies {
|
||||
implementation(project(":exporters:jaeger"))
|
||||
implementation(project(":exporters:jaeger-proto"))
|
||||
|
||||
implementation("com.linecorp.armeria:armeria-junit5")
|
||||
implementation("com.linecorp.armeria:armeria-grpc")
|
||||
runtimeOnly("io.grpc:grpc-netty-shaded")
|
||||
}
|
||||
|
||||
targets {
|
||||
all {
|
||||
testTask {
|
||||
environment("OTEL_METRICS_EXPORTER", "none")
|
||||
environment("OTEL_TRACES_EXPORTER", "jaeger")
|
||||
environment("OTEL_BSP_SCHEDULE_DELAY", "10")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val testLoggingOtlp by registering(JvmTestSuite::class) {
|
||||
dependencies {
|
||||
implementation(project(":exporters:logging-otlp"))
|
||||
implementation("com.google.guava:guava")
|
||||
}
|
||||
}
|
||||
val testOtlp by registering(JvmTestSuite::class) {
|
||||
dependencies {
|
||||
implementation(project(":exporters:otlp:all"))
|
||||
|
|
@ -171,23 +146,6 @@ testing {
|
|||
}
|
||||
}
|
||||
}
|
||||
val testZipkin by registering(JvmTestSuite::class) {
|
||||
dependencies {
|
||||
implementation(project(":exporters:zipkin"))
|
||||
|
||||
implementation("com.linecorp.armeria:armeria-junit5")
|
||||
}
|
||||
|
||||
targets {
|
||||
all {
|
||||
testTask {
|
||||
environment("OTEL_METRICS_EXPORTER", "none")
|
||||
environment("OTEL_TRACES_EXPORTER", "zipkin")
|
||||
environment("OTEL_BSP_SCHEDULE_DELAY", "10")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class LogRecordExporterConfiguration {
|
|||
EXPORTER_ARTIFACT_ID_BY_NAME = new HashMap<>();
|
||||
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("otlp", "opentelemetry-exporter-otlp");
|
||||
EXPORTER_ARTIFACT_ID_BY_NAME.put("otlp", "opentelemetry-exporter-otlp-logs");
|
||||
}
|
||||
|
||||
// Visible for test
|
||||
|
|
|
|||
|
|
@ -5,16 +5,47 @@
|
|||
|
||||
package io.opentelemetry.sdk.autoconfigure;
|
||||
|
||||
import static io.opentelemetry.sdk.autoconfigure.LogRecordExporterConfiguration.configureExporter;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
|
||||
import io.opentelemetry.sdk.logs.export.LogRecordExporter;
|
||||
import java.util.Collections;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class LogRecordExporterConfigurationTest {
|
||||
|
||||
@Test
|
||||
void configureExporter_KnownSpiExportersNotOnClasspath() {
|
||||
NamedSpiManager<LogRecordExporter> spiExportersManager =
|
||||
LogRecordExporterConfiguration.logRecordExporterSpiManager(
|
||||
DefaultConfigProperties.createForTest(Collections.emptyMap()),
|
||||
LogRecordExporterConfigurationTest.class.getClassLoader());
|
||||
|
||||
assertThatThrownBy(() -> configureExporter("logging", spiExportersManager))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessage(
|
||||
"otel.logs.exporter set to \"logging\" but opentelemetry-exporter-logging"
|
||||
+ " not found on classpath. Make sure to add it as a dependency.");
|
||||
assertThatThrownBy(() -> configureExporter("logging-otlp", spiExportersManager))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessage(
|
||||
"otel.logs.exporter set to \"logging-otlp\" but opentelemetry-exporter-logging-otlp"
|
||||
+ " not found on classpath. Make sure to add it as a dependency.");
|
||||
assertThatThrownBy(() -> configureExporter("otlp", spiExportersManager))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessage(
|
||||
"otel.logs.exporter set to \"otlp\" but opentelemetry-exporter-otlp-logs"
|
||||
+ " not found on classpath. Make sure to add it as a dependency.");
|
||||
|
||||
// Unrecognized exporter
|
||||
assertThatThrownBy(() -> configureExporter("foo", spiExportersManager))
|
||||
.hasMessage("Unrecognized value for otel.logs.exporter: foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
void configureLogRecordExporters_duplicates() {
|
||||
ConfigProperties config =
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.sdk.autoconfigure;
|
||||
|
||||
import static io.opentelemetry.sdk.autoconfigure.MetricExporterConfiguration.configureExporter;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
|
||||
import io.opentelemetry.sdk.metrics.export.MetricExporter;
|
||||
import java.util.Collections;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class MetricExporterConfigurationTest {
|
||||
|
||||
private static final ConfigProperties EMPTY =
|
||||
DefaultConfigProperties.createForTest(Collections.emptyMap());
|
||||
|
||||
@Test
|
||||
void configureExporter_KnownSpiExportersNotOnClasspath() {
|
||||
NamedSpiManager<MetricExporter> spiExportersManager =
|
||||
MetricExporterConfiguration.metricExporterSpiManager(
|
||||
EMPTY, MetricExporterConfigurationTest.class.getClassLoader());
|
||||
|
||||
assertThatThrownBy(() -> configureExporter("logging", spiExportersManager))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessage(
|
||||
"otel.metrics.exporter set to \"logging\" but opentelemetry-exporter-logging"
|
||||
+ " not found on classpath. Make sure to add it as a dependency.");
|
||||
assertThatThrownBy(() -> configureExporter("logging-otlp", spiExportersManager))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessage(
|
||||
"otel.metrics.exporter set to \"logging-otlp\" but opentelemetry-exporter-logging-otlp"
|
||||
+ " not found on classpath. Make sure to add it as a dependency.");
|
||||
assertThatThrownBy(() -> configureExporter("otlp", spiExportersManager))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessage(
|
||||
"otel.metrics.exporter set to \"otlp\" but opentelemetry-exporter-otlp"
|
||||
+ " not found on classpath. Make sure to add it as a dependency.");
|
||||
|
||||
// Unrecognized exporter
|
||||
assertThatThrownBy(() -> configureExporter("foo", spiExportersManager))
|
||||
.hasMessage("Unrecognized value for otel.metrics.exporter: foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
void configureReader_Prometheus() {
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
MetricExporterConfiguration.configureReader(
|
||||
"prometheus",
|
||||
EMPTY,
|
||||
MetricExporterConfigurationTest.class.getClassLoader(),
|
||||
(a, unused) -> a))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessageContaining(
|
||||
"Prometheus Metrics Server enabled but opentelemetry-exporter-prometheus not found on "
|
||||
+ "classpath");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,184 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.sdk.autoconfigure;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatCode;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
|
||||
import io.opentelemetry.sdk.logs.export.LogRecordExporter;
|
||||
import io.opentelemetry.sdk.metrics.export.MetricExporter;
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
import java.util.Collections;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class NotOnClasspathTest {
|
||||
|
||||
private static final ConfigProperties EMPTY =
|
||||
DefaultConfigProperties.createForTest(Collections.emptyMap());
|
||||
private static final NamedSpiManager<SpanExporter> SPAN_EXPORTER_SPI_MANAGER =
|
||||
SpanExporterConfiguration.spanExporterSpiManager(
|
||||
EMPTY, NotOnClasspathTest.class.getClassLoader());
|
||||
private static final NamedSpiManager<MetricExporter> METRIC_EXPORTER_SPI_MANAGER =
|
||||
MetricExporterConfiguration.metricExporterSpiManager(
|
||||
EMPTY, NotOnClasspathTest.class.getClassLoader());
|
||||
private static final NamedSpiManager<LogRecordExporter> LOG_RECORD_EXPORTER_SPI_MANAGER =
|
||||
LogRecordExporterConfiguration.logRecordExporterSpiManager(
|
||||
EMPTY, NotOnClasspathTest.class.getClassLoader());
|
||||
|
||||
@Test
|
||||
void otlpSpans() {
|
||||
assertThatThrownBy(
|
||||
() -> SpanExporterConfiguration.configureExporter("otlp", SPAN_EXPORTER_SPI_MANAGER))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessageContaining(
|
||||
"otel.traces.exporter set to \"otlp\" but opentelemetry-exporter-otlp not found on classpath."
|
||||
+ " Make sure to add it as a dependency.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void jaeger() {
|
||||
assertThatThrownBy(
|
||||
() -> SpanExporterConfiguration.configureExporter("jaeger", SPAN_EXPORTER_SPI_MANAGER))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessageContaining(
|
||||
"otel.traces.exporter set to \"jaeger\" but opentelemetry-exporter-jaeger not found on classpath."
|
||||
+ " Make sure to add it as a dependency.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void zipkin() {
|
||||
assertThatThrownBy(
|
||||
() -> SpanExporterConfiguration.configureExporter("zipkin", SPAN_EXPORTER_SPI_MANAGER))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessageContaining(
|
||||
"otel.traces.exporter set to \"zipkin\" but opentelemetry-exporter-zipkin not found on classpath."
|
||||
+ " Make sure to add it as a dependency.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void loggingSpans() {
|
||||
assertThatThrownBy(
|
||||
() -> SpanExporterConfiguration.configureExporter("logging", SPAN_EXPORTER_SPI_MANAGER))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessageContaining(
|
||||
"otel.traces.exporter set to \"logging\" but opentelemetry-exporter-logging not found on classpath."
|
||||
+ " Make sure to add it as a dependency.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void loggingSpansOtlp() {
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
SpanExporterConfiguration.configureExporter(
|
||||
"logging-otlp", SPAN_EXPORTER_SPI_MANAGER))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessageContaining(
|
||||
"otel.traces.exporter set to \"logging-otlp\" but opentelemetry-exporter-logging-otlp not found on classpath."
|
||||
+ " Make sure to add it as a dependency.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void loggingMetrics() {
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
MetricExporterConfiguration.configureExporter(
|
||||
"logging", METRIC_EXPORTER_SPI_MANAGER))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessageContaining(
|
||||
"otel.metrics.exporter set to \"logging\" but opentelemetry-exporter-logging not found on classpath."
|
||||
+ " Make sure to add it as a dependency.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void loggingMetricsOtlp() {
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
MetricExporterConfiguration.configureExporter(
|
||||
"logging-otlp", METRIC_EXPORTER_SPI_MANAGER))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessageContaining(
|
||||
"otel.metrics.exporter set to \"logging-otlp\" but opentelemetry-exporter-logging-otlp not found on classpath."
|
||||
+ " Make sure to add it as a dependency.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void loggingLogs() {
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
LogRecordExporterConfiguration.configureExporter(
|
||||
"logging", LOG_RECORD_EXPORTER_SPI_MANAGER))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessageContaining(
|
||||
"otel.logs.exporter set to \"logging\" but opentelemetry-exporter-logging not found on classpath."
|
||||
+ " Make sure to add it as a dependency.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void loggingLogsOtlp() {
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
LogRecordExporterConfiguration.configureExporter(
|
||||
"logging-otlp", LOG_RECORD_EXPORTER_SPI_MANAGER))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessageContaining(
|
||||
"otel.logs.exporter set to \"logging-otlp\" but opentelemetry-exporter-logging-otlp not found on classpath."
|
||||
+ " Make sure to add it as a dependency.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void otlpMetrics() {
|
||||
assertThatCode(
|
||||
() ->
|
||||
MetricExporterConfiguration.configureExporter("otlp", METRIC_EXPORTER_SPI_MANAGER))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessageContaining(
|
||||
"otel.metrics.exporter set to \"otlp\" but opentelemetry-exporter-otlp not found on classpath."
|
||||
+ " Make sure to add it as a dependency.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void prometheus() {
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
MetricExporterConfiguration.configureReader(
|
||||
"prometheus",
|
||||
EMPTY,
|
||||
NotOnClasspathTest.class.getClassLoader(),
|
||||
(a, unused) -> a))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessageContaining(
|
||||
"Prometheus Metrics Server enabled but opentelemetry-exporter-prometheus not found on "
|
||||
+ "classpath");
|
||||
}
|
||||
|
||||
@Test
|
||||
void b3propagator() {
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
PropagatorConfiguration.configurePropagators(
|
||||
DefaultConfigProperties.createForTest(
|
||||
Collections.singletonMap("otel.propagators", "b3")),
|
||||
PropagatorConfiguration.class.getClassLoader(),
|
||||
(a, config) -> a))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessageContaining("Unrecognized value for otel.propagators: b3");
|
||||
}
|
||||
|
||||
@Test
|
||||
void otlpGrpcLogs() {
|
||||
assertThatCode(
|
||||
() ->
|
||||
LogRecordExporterConfiguration.configureExporter(
|
||||
"otlp", LOG_RECORD_EXPORTER_SPI_MANAGER))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessageContaining(
|
||||
"otel.logs.exporter set to \"otlp\" but opentelemetry-exporter-otlp not found on classpath."
|
||||
+ " Make sure to add it as a dependency.");
|
||||
}
|
||||
}
|
||||
|
|
@ -6,8 +6,10 @@
|
|||
package io.opentelemetry.sdk.autoconfigure;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import io.opentelemetry.context.propagation.ContextPropagators;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
|
||||
import java.util.Collections;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
@ -25,4 +27,17 @@ class PropagatorConfigurationTest {
|
|||
assertThat(contextPropagators.getTextMapPropagator().fields())
|
||||
.containsExactlyInAnyOrder("traceparent", "tracestate", "baggage");
|
||||
}
|
||||
|
||||
@Test
|
||||
void configurePropagators_NotOnClasspath() {
|
||||
assertThatThrownBy(
|
||||
() ->
|
||||
PropagatorConfiguration.configurePropagators(
|
||||
DefaultConfigProperties.createForTest(
|
||||
Collections.singletonMap("otel.propagators", "b3")),
|
||||
PropagatorConfiguration.class.getClassLoader(),
|
||||
(a, config) -> a))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessageContaining("Unrecognized value for otel.propagators: b3");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.sdk.autoconfigure;
|
||||
|
||||
import static io.opentelemetry.sdk.autoconfigure.SpanExporterConfiguration.configureExporter;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
import java.util.Collections;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class SpanExporterConfigurationTest {
|
||||
|
||||
@Test
|
||||
void configureExporter_KnownSpiExportersNotOnClasspath() {
|
||||
NamedSpiManager<SpanExporter> spiExportersManager =
|
||||
SpanExporterConfiguration.spanExporterSpiManager(
|
||||
DefaultConfigProperties.createForTest(Collections.emptyMap()),
|
||||
SpanExporterConfigurationTest.class.getClassLoader());
|
||||
|
||||
assertThatThrownBy(() -> configureExporter("jaeger", spiExportersManager))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessage(
|
||||
"otel.traces.exporter set to \"jaeger\" but opentelemetry-exporter-jaeger"
|
||||
+ " not found on classpath. Make sure to add it as a dependency.");
|
||||
assertThatThrownBy(() -> configureExporter("logging", spiExportersManager))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessage(
|
||||
"otel.traces.exporter set to \"logging\" but opentelemetry-exporter-logging"
|
||||
+ " not found on classpath. Make sure to add it as a dependency.");
|
||||
assertThatThrownBy(() -> configureExporter("logging-otlp", spiExportersManager))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessage(
|
||||
"otel.traces.exporter set to \"logging-otlp\" but opentelemetry-exporter-logging-otlp"
|
||||
+ " not found on classpath. Make sure to add it as a dependency.");
|
||||
assertThatThrownBy(() -> configureExporter("otlp", spiExportersManager))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessage(
|
||||
"otel.traces.exporter set to \"otlp\" but opentelemetry-exporter-otlp"
|
||||
+ " not found on classpath. Make sure to add it as a dependency.");
|
||||
assertThatThrownBy(() -> configureExporter("zipkin", spiExportersManager))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessage(
|
||||
"otel.traces.exporter set to \"zipkin\" but opentelemetry-exporter-zipkin"
|
||||
+ " not found on classpath. Make sure to add it as a dependency.");
|
||||
|
||||
// Unrecognized exporter
|
||||
assertThatThrownBy(() -> configureExporter("foo", spiExportersManager))
|
||||
.isInstanceOf(ConfigurationException.class)
|
||||
.hasMessage("Unrecognized value for otel.traces.exporter: foo");
|
||||
}
|
||||
}
|
||||
|
|
@ -5,14 +5,36 @@
|
|||
|
||||
package io.opentelemetry.sdk.autoconfigure;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.opentelemetry.exporter.logging.SystemOutLogRecordExporter;
|
||||
import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingLogRecordExporter;
|
||||
import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporter;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
|
||||
import io.opentelemetry.sdk.logs.export.LogRecordExporter;
|
||||
import java.util.Collections;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class LogRecordExporterConfigurationTest {
|
||||
class LogRecordExporterConfigurationTest {
|
||||
|
||||
@Test
|
||||
void configureExporter_KnownSpiExportersOnClasspath() {
|
||||
NamedSpiManager<LogRecordExporter> spiExportersManager =
|
||||
LogRecordExporterConfiguration.logRecordExporterSpiManager(
|
||||
DefaultConfigProperties.createForTest(Collections.emptyMap()),
|
||||
LogRecordExporterConfigurationTest.class.getClassLoader());
|
||||
|
||||
assertThat(LogRecordExporterConfiguration.configureExporter("logging", spiExportersManager))
|
||||
.isInstanceOf(SystemOutLogRecordExporter.class);
|
||||
assertThat(
|
||||
LogRecordExporterConfiguration.configureExporter("logging-otlp", spiExportersManager))
|
||||
.isInstanceOf(OtlpJsonLoggingLogRecordExporter.class);
|
||||
assertThat(LogRecordExporterConfiguration.configureExporter("otlp", spiExportersManager))
|
||||
.isInstanceOf(OtlpGrpcLogRecordExporter.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void configureExporter_UnsupportedOtlpProtocol() {
|
||||
|
|
|
|||
|
|
@ -5,14 +5,35 @@
|
|||
|
||||
package io.opentelemetry.sdk.autoconfigure;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.opentelemetry.exporter.logging.LoggingMetricExporter;
|
||||
import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingMetricExporter;
|
||||
import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
|
||||
import io.opentelemetry.sdk.metrics.export.MetricExporter;
|
||||
import java.util.Collections;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MetricExporterConfigurationTest {
|
||||
class MetricExporterConfigurationTest {
|
||||
|
||||
@Test
|
||||
void configureExporter_KnownSpiExportersOnClasspath() {
|
||||
NamedSpiManager<MetricExporter> spiExportersManager =
|
||||
MetricExporterConfiguration.metricExporterSpiManager(
|
||||
DefaultConfigProperties.createForTest(Collections.emptyMap()),
|
||||
ConfigurableMetricExporterTest.class.getClassLoader());
|
||||
|
||||
assertThat(MetricExporterConfiguration.configureExporter("logging", spiExportersManager))
|
||||
.isInstanceOf(LoggingMetricExporter.class);
|
||||
assertThat(MetricExporterConfiguration.configureExporter("logging-otlp", spiExportersManager))
|
||||
.isInstanceOf(OtlpJsonLoggingMetricExporter.class);
|
||||
assertThat(MetricExporterConfiguration.configureExporter("otlp", spiExportersManager))
|
||||
.isInstanceOf(OtlpGrpcMetricExporter.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void configureOtlpMetricsUnsupportedProtocol() {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter;
|
||||
import io.opentelemetry.exporter.logging.LoggingSpanExporter;
|
||||
import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingSpanExporter;
|
||||
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
|
||||
import io.opentelemetry.exporter.zipkin.ZipkinSpanExporter;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
|
||||
|
|
@ -20,6 +23,25 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
class SpanExporterConfigurationTest {
|
||||
|
||||
@Test
|
||||
void configureExporter_KnownSpiExportersOnClasspath() {
|
||||
NamedSpiManager<SpanExporter> spiExportersManager =
|
||||
SpanExporterConfiguration.spanExporterSpiManager(
|
||||
DefaultConfigProperties.createForTest(Collections.emptyMap()),
|
||||
SpanExporterConfigurationTest.class.getClassLoader());
|
||||
|
||||
assertThat(SpanExporterConfiguration.configureExporter("jaeger", spiExportersManager))
|
||||
.isInstanceOf(JaegerGrpcSpanExporter.class);
|
||||
assertThat(SpanExporterConfiguration.configureExporter("logging", spiExportersManager))
|
||||
.isInstanceOf(LoggingSpanExporter.class);
|
||||
assertThat(SpanExporterConfiguration.configureExporter("logging-otlp", spiExportersManager))
|
||||
.isInstanceOf(OtlpJsonLoggingSpanExporter.class);
|
||||
assertThat(SpanExporterConfiguration.configureExporter("otlp", spiExportersManager))
|
||||
.isInstanceOf(OtlpGrpcSpanExporter.class);
|
||||
assertThat(SpanExporterConfiguration.configureExporter("zipkin", spiExportersManager))
|
||||
.isInstanceOf(ZipkinSpanExporter.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void configureOtlpSpansUnsupportedProtocol() {
|
||||
ConfigProperties config =
|
||||
|
|
@ -56,44 +78,4 @@ class SpanExporterConfigurationTest {
|
|||
exporter.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
// Timeout difficult to test using real exports so just check implementation detail here.
|
||||
@Test
|
||||
void configureJaegerTimeout() {
|
||||
ConfigProperties config =
|
||||
DefaultConfigProperties.createForTest(
|
||||
Collections.singletonMap("otel.exporter.jaeger.timeout", "10"));
|
||||
SpanExporter exporter =
|
||||
SpanExporterConfiguration.configureExporter(
|
||||
"jaeger",
|
||||
SpanExporterConfiguration.spanExporterSpiManager(
|
||||
config, SpanExporterConfigurationTest.class.getClassLoader()));
|
||||
try {
|
||||
assertThat(exporter)
|
||||
.isInstanceOfSatisfying(
|
||||
JaegerGrpcSpanExporter.class,
|
||||
jaeger ->
|
||||
assertThat(jaeger).extracting("delegate.client.callTimeoutMillis").isEqualTo(10));
|
||||
} finally {
|
||||
exporter.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
// Timeout difficult to test using real exports so just check that things don't blow up.
|
||||
@Test
|
||||
void configureZipkinTimeout() {
|
||||
ConfigProperties config =
|
||||
DefaultConfigProperties.createForTest(
|
||||
Collections.singletonMap("otel.exporter.zipkin.timeout", "5s"));
|
||||
SpanExporter exporter =
|
||||
SpanExporterConfiguration.configureExporter(
|
||||
"zipkin",
|
||||
SpanExporterConfiguration.spanExporterSpiManager(
|
||||
config, SpanExporterConfigurationTest.class.getClassLoader()));
|
||||
try {
|
||||
assertThat(exporter).isNotNull();
|
||||
} finally {
|
||||
exporter.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.sdk.autoconfigure;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
|
||||
import com.linecorp.armeria.server.ServerBuilder;
|
||||
import com.linecorp.armeria.server.grpc.GrpcService;
|
||||
import com.linecorp.armeria.testing.junit5.server.ServerExtension;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import io.opentelemetry.api.GlobalOpenTelemetry;
|
||||
import io.opentelemetry.exporter.jaeger.proto.api_v2.Collector;
|
||||
import io.opentelemetry.exporter.jaeger.proto.api_v2.CollectorServiceGrpc;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
class JaegerConfigTest {
|
||||
|
||||
private static final BlockingQueue<Collector.PostSpansRequest> jaegerRequests =
|
||||
new LinkedBlockingDeque<>();
|
||||
|
||||
@RegisterExtension
|
||||
public static final ServerExtension server =
|
||||
new ServerExtension() {
|
||||
@Override
|
||||
protected void configure(ServerBuilder sb) {
|
||||
sb.service(
|
||||
GrpcService.builder()
|
||||
// Jaeger
|
||||
.addService(
|
||||
new CollectorServiceGrpc.CollectorServiceImplBase() {
|
||||
@Override
|
||||
public void postSpans(
|
||||
Collector.PostSpansRequest request,
|
||||
StreamObserver<Collector.PostSpansResponse> responseObserver) {
|
||||
jaegerRequests.add(request);
|
||||
responseObserver.onNext(Collector.PostSpansResponse.getDefaultInstance());
|
||||
responseObserver.onCompleted();
|
||||
}
|
||||
})
|
||||
.useBlockingTaskExecutor(true)
|
||||
.build());
|
||||
}
|
||||
};
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
jaegerRequests.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
void configures() {
|
||||
String endpoint = "http://localhost:" + server.httpPort();
|
||||
|
||||
System.setProperty("otel.exporter.jaeger.endpoint", endpoint);
|
||||
|
||||
AutoConfiguredOpenTelemetrySdk.initialize();
|
||||
|
||||
GlobalOpenTelemetry.get().getTracer("test").spanBuilder("test").startSpan().end();
|
||||
|
||||
await().untilAsserted(() -> assertThat(jaegerRequests).hasSize(1));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.sdk.autoconfigure;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.github.netmikey.logunit.api.LogCapturer;
|
||||
import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingLogRecordExporter;
|
||||
import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingMetricExporter;
|
||||
import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingSpanExporter;
|
||||
import io.opentelemetry.sdk.OpenTelemetrySdk;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
class LoggingOtlpTest {
|
||||
|
||||
@RegisterExtension
|
||||
LogCapturer spansCapturer =
|
||||
LogCapturer.create().captureForType(OtlpJsonLoggingSpanExporter.class);
|
||||
|
||||
@RegisterExtension
|
||||
LogCapturer metricsCapturer =
|
||||
LogCapturer.create().captureForType(OtlpJsonLoggingMetricExporter.class);
|
||||
|
||||
@RegisterExtension
|
||||
LogCapturer logsCapturer =
|
||||
LogCapturer.create().captureForType(OtlpJsonLoggingLogRecordExporter.class);
|
||||
|
||||
@Test
|
||||
void configures() {
|
||||
OpenTelemetrySdk sdk =
|
||||
AutoConfiguredOpenTelemetrySdk.builder()
|
||||
.setConfig(
|
||||
DefaultConfigProperties.createForTest(
|
||||
ImmutableMap.of(
|
||||
"otel.traces.exporter", "logging-otlp",
|
||||
"otel.metrics.exporter", "logging-otlp",
|
||||
"otel.logs.exporter", "logging-otlp")))
|
||||
.setResultAsGlobal(false)
|
||||
.build()
|
||||
.getOpenTelemetrySdk();
|
||||
|
||||
sdk.getTracerProvider().get("tracer").spanBuilder("test").startSpan().end();
|
||||
sdk.getMeterProvider().get("meter").counterBuilder("counter").build().add(10);
|
||||
sdk.getSdkLoggerProvider().get("logger").logRecordBuilder().setBody("message").emit();
|
||||
|
||||
sdk.getSdkLoggerProvider().forceFlush().join(10, TimeUnit.SECONDS);
|
||||
sdk.getSdkMeterProvider().forceFlush().join(10, TimeUnit.SECONDS);
|
||||
sdk.getSdkLoggerProvider().forceFlush().join(10, TimeUnit.SECONDS);
|
||||
|
||||
await()
|
||||
.untilAsserted(
|
||||
() -> assertThat(spansCapturer.getEvents().size()).isGreaterThanOrEqualTo(1));
|
||||
await()
|
||||
.untilAsserted(
|
||||
() -> assertThat(metricsCapturer.getEvents().size()).isGreaterThanOrEqualTo(1));
|
||||
await()
|
||||
.untilAsserted(() -> assertThat(logsCapturer.getEvents().size()).isGreaterThanOrEqualTo(1));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.sdk.autoconfigure;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
|
||||
import com.linecorp.armeria.common.HttpResponse;
|
||||
import com.linecorp.armeria.common.HttpStatus;
|
||||
import com.linecorp.armeria.server.ServerBuilder;
|
||||
import com.linecorp.armeria.testing.junit5.server.ServerExtension;
|
||||
import io.opentelemetry.api.GlobalOpenTelemetry;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
class ZipkinConfigTest {
|
||||
|
||||
private static final BlockingQueue<String> zipkinJsonRequests = new LinkedBlockingDeque<>();
|
||||
|
||||
@RegisterExtension
|
||||
public static final ServerExtension server =
|
||||
new ServerExtension() {
|
||||
@Override
|
||||
protected void configure(ServerBuilder sb) {
|
||||
// Zipkin
|
||||
sb.service(
|
||||
"/api/v2/spans",
|
||||
(ctx, req) ->
|
||||
HttpResponse.from(
|
||||
req.aggregate()
|
||||
.thenApply(
|
||||
aggRes -> {
|
||||
zipkinJsonRequests.add(aggRes.contentUtf8());
|
||||
return HttpResponse.of(HttpStatus.OK);
|
||||
})));
|
||||
}
|
||||
};
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
zipkinJsonRequests.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
void configures() {
|
||||
String endpoint = "localhost:" + server.httpPort();
|
||||
|
||||
System.setProperty("otel.exporter.zipkin.endpoint", "http://" + endpoint + "/api/v2/spans");
|
||||
System.setProperty("otel.exporter.zipkin.timeout", "5s");
|
||||
|
||||
AutoConfiguredOpenTelemetrySdk.initialize();
|
||||
|
||||
GlobalOpenTelemetry.get().getTracer("test").spanBuilder("test").startSpan().end();
|
||||
|
||||
await().untilAsserted(() -> assertThat(zipkinJsonRequests).hasSize(1));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue