Fix build
This commit is contained in:
parent
4d94d04f51
commit
eb3d80a0b0
|
|
@ -66,6 +66,16 @@ testing {
|
||||||
|
|
||||||
implementation("io.grpc:grpc-stub")
|
implementation("io.grpc:grpc-stub")
|
||||||
implementation("io.grpc:grpc-netty")
|
implementation("io.grpc:grpc-netty")
|
||||||
|
|
||||||
|
// NOTE: this is a strange dependency. junit reflectively analyzes classes as part of its test discovery process, eventually encounters to jackson-databind classes, and fails with a NoClassDefFoundError:
|
||||||
|
// JUnit Jupiter > initializationError FAILED
|
||||||
|
// org.junit.platform.launcher.core.DiscoveryIssueException: TestEngine with ID 'junit-jupiter' encountered a critical issue during test discovery:
|
||||||
|
//
|
||||||
|
// (1) [ERROR] ClassSelector [className = 'io.opentelemetry.exporter.internal.grpc.GrpcExporterTest$DummyMarshaler', classLoader = jdk.internal.loader.ClassLoaders$AppClassLoader@2aae9190] resolution failed
|
||||||
|
// Source: ClassSource [className = 'io.opentelemetry.exporter.internal.grpc.GrpcExporterTest$DummyMarshaler', filePosition = null]
|
||||||
|
// at io.opentelemetry.exporter.internal.grpc.GrpcExporterTest$DummyMarshaler.<no-method>(SourceFile:0)
|
||||||
|
// Cause: java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonGenerator
|
||||||
|
implementation("com.fasterxml.jackson.core:jackson-databind")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,16 +50,14 @@ import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
|
||||||
|
|
||||||
class LowAllocationMetricsRequestMarshalerTest {
|
class LowAllocationMetricsRequestMarshalerTest {
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ArgumentsSource(MetricsProvider.class)
|
@MethodSource("metricsArgs")
|
||||||
void validateOutput(Collection<MetricData> metrics) throws Exception {
|
void validateOutput(Collection<MetricData> metrics) throws Exception {
|
||||||
byte[] result;
|
byte[] result;
|
||||||
{
|
{
|
||||||
|
|
@ -85,7 +83,7 @@ class LowAllocationMetricsRequestMarshalerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ArgumentsSource(MetricsProvider.class)
|
@MethodSource("metricsArgs")
|
||||||
void validateJsonOutput(Collection<MetricData> metrics) throws Exception {
|
void validateJsonOutput(Collection<MetricData> metrics) throws Exception {
|
||||||
String result;
|
String result;
|
||||||
{
|
{
|
||||||
|
|
@ -110,122 +108,7 @@ class LowAllocationMetricsRequestMarshalerTest {
|
||||||
assertThat(lowAllocationResult).isEqualTo(result);
|
assertThat(lowAllocationResult).isEqualTo(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
private static Stream<Arguments> metricsArgs() {
|
||||||
@ArgumentsSource(ExemplarProvider.class)
|
|
||||||
void validateExemplar(ExemplarData exemplar) throws Exception {
|
|
||||||
byte[] result;
|
|
||||||
{
|
|
||||||
Marshaler marshaler = ExemplarMarshaler.create(exemplar);
|
|
||||||
ByteArrayOutputStream customOutput =
|
|
||||||
new ByteArrayOutputStream(marshaler.getBinarySerializedSize());
|
|
||||||
marshaler.writeBinaryTo(customOutput);
|
|
||||||
result = customOutput.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] lowAllocationResult;
|
|
||||||
{
|
|
||||||
MarshalerContext context = new MarshalerContext();
|
|
||||||
class TestMarshaler extends MarshalerWithSize {
|
|
||||||
|
|
||||||
protected TestMarshaler() {
|
|
||||||
super(ExemplarStatelessMarshaler.INSTANCE.getBinarySerializedSize(exemplar, context));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeTo(Serializer output) throws IOException {
|
|
||||||
ExemplarStatelessMarshaler.INSTANCE.writeTo(output, exemplar, context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Marshaler marshaler = new TestMarshaler();
|
|
||||||
ByteArrayOutputStream customOutput =
|
|
||||||
new ByteArrayOutputStream(marshaler.getBinarySerializedSize());
|
|
||||||
marshaler.writeBinaryTo(customOutput);
|
|
||||||
lowAllocationResult = customOutput.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
assertThat(lowAllocationResult).isEqualTo(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void validateSummary() throws Exception {
|
|
||||||
List<ValueAtQuantile> percentileValues =
|
|
||||||
Arrays.asList(ImmutableValueAtQuantile.create(3.0, 4.0));
|
|
||||||
List<SummaryPointData> points =
|
|
||||||
Arrays.asList(
|
|
||||||
ImmutableSummaryPointData.create(
|
|
||||||
12345, 12346, Attributes.empty(), 1, 2.0, percentileValues));
|
|
||||||
SummaryData summary = ImmutableSummaryData.create(points);
|
|
||||||
|
|
||||||
byte[] result;
|
|
||||||
{
|
|
||||||
Marshaler marshaler = SummaryMarshaler.create(summary);
|
|
||||||
ByteArrayOutputStream customOutput =
|
|
||||||
new ByteArrayOutputStream(marshaler.getBinarySerializedSize());
|
|
||||||
marshaler.writeBinaryTo(customOutput);
|
|
||||||
result = customOutput.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] lowAllocationResult;
|
|
||||||
{
|
|
||||||
MarshalerContext context = new MarshalerContext();
|
|
||||||
class TestMarshaler extends MarshalerWithSize {
|
|
||||||
|
|
||||||
protected TestMarshaler() {
|
|
||||||
super(SummaryStatelessMarshaler.INSTANCE.getBinarySerializedSize(summary, context));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeTo(Serializer output) throws IOException {
|
|
||||||
SummaryStatelessMarshaler.INSTANCE.writeTo(output, summary, context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Marshaler marshaler = new TestMarshaler();
|
|
||||||
ByteArrayOutputStream customOutput =
|
|
||||||
new ByteArrayOutputStream(marshaler.getBinarySerializedSize());
|
|
||||||
marshaler.writeBinaryTo(customOutput);
|
|
||||||
lowAllocationResult = customOutput.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
assertThat(lowAllocationResult).isEqualTo(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Collection<MetricData> metrics(Consumer<MeterProvider> metricProducer) {
|
|
||||||
InMemoryMetricReader metricReader = InMemoryMetricReader.create();
|
|
||||||
SdkMeterProvider meterProvider =
|
|
||||||
SdkMeterProvider.builder()
|
|
||||||
.registerMetricReader(metricReader)
|
|
||||||
.registerView(
|
|
||||||
InstrumentSelector.builder().setName("exponentialhistogram").build(),
|
|
||||||
View.builder()
|
|
||||||
.setAggregation(Aggregation.base2ExponentialBucketHistogram())
|
|
||||||
.build())
|
|
||||||
.setResource(
|
|
||||||
Resource.create(
|
|
||||||
Attributes.builder()
|
|
||||||
.put(AttributeKey.booleanKey("key_bool"), true)
|
|
||||||
.put(AttributeKey.stringKey("key_string"), "string")
|
|
||||||
.put(AttributeKey.longKey("key_int"), 100L)
|
|
||||||
.put(AttributeKey.doubleKey("key_double"), 100.3)
|
|
||||||
.put(
|
|
||||||
AttributeKey.stringArrayKey("key_string_array"),
|
|
||||||
Arrays.asList("string", "string"))
|
|
||||||
.put(AttributeKey.longArrayKey("key_long_array"), Arrays.asList(12L, 23L))
|
|
||||||
.put(
|
|
||||||
AttributeKey.doubleArrayKey("key_double_array"),
|
|
||||||
Arrays.asList(12.3, 23.1))
|
|
||||||
.put(
|
|
||||||
AttributeKey.booleanArrayKey("key_boolean_array"),
|
|
||||||
Arrays.asList(true, false))
|
|
||||||
.build()))
|
|
||||||
.build();
|
|
||||||
metricProducer.accept(meterProvider);
|
|
||||||
|
|
||||||
return metricReader.collectAllMetrics();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class MetricsProvider implements ArgumentsProvider {
|
|
||||||
@Override
|
|
||||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
arguments(
|
arguments(
|
||||||
named(
|
named(
|
||||||
|
|
@ -242,8 +125,7 @@ class LowAllocationMetricsRequestMarshalerTest {
|
||||||
measurement ->
|
measurement ->
|
||||||
measurement.record(
|
measurement.record(
|
||||||
5,
|
5,
|
||||||
Attributes.of(
|
Attributes.of(AttributeKey.stringKey("key"), "value")))))),
|
||||||
AttributeKey.stringKey("key"), "value")))))),
|
|
||||||
arguments(
|
arguments(
|
||||||
named(
|
named(
|
||||||
"long counter",
|
"long counter",
|
||||||
|
|
@ -273,8 +155,7 @@ class LowAllocationMetricsRequestMarshalerTest {
|
||||||
.setUnit("unit")
|
.setUnit("unit")
|
||||||
.build();
|
.build();
|
||||||
longUpDownCounter.add(1);
|
longUpDownCounter.add(1);
|
||||||
longUpDownCounter.add(
|
longUpDownCounter.add(-1, Attributes.of(AttributeKey.booleanKey("on"), true));
|
||||||
-1, Attributes.of(AttributeKey.booleanKey("on"), true));
|
|
||||||
longUpDownCounter.add(1);
|
longUpDownCounter.add(1);
|
||||||
}))),
|
}))),
|
||||||
arguments(
|
arguments(
|
||||||
|
|
@ -382,11 +263,44 @@ class LowAllocationMetricsRequestMarshalerTest {
|
||||||
histogram.record(5);
|
histogram.record(5);
|
||||||
}))));
|
}))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@MethodSource("exemplarArgs")
|
||||||
|
void validateExemplar(ExemplarData exemplar) throws Exception {
|
||||||
|
byte[] result;
|
||||||
|
{
|
||||||
|
Marshaler marshaler = ExemplarMarshaler.create(exemplar);
|
||||||
|
ByteArrayOutputStream customOutput =
|
||||||
|
new ByteArrayOutputStream(marshaler.getBinarySerializedSize());
|
||||||
|
marshaler.writeBinaryTo(customOutput);
|
||||||
|
result = customOutput.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] lowAllocationResult;
|
||||||
|
{
|
||||||
|
MarshalerContext context = new MarshalerContext();
|
||||||
|
class TestMarshaler extends MarshalerWithSize {
|
||||||
|
|
||||||
|
protected TestMarshaler() {
|
||||||
|
super(ExemplarStatelessMarshaler.INSTANCE.getBinarySerializedSize(exemplar, context));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ExemplarProvider implements ArgumentsProvider {
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
protected void writeTo(Serializer output) throws IOException {
|
||||||
|
ExemplarStatelessMarshaler.INSTANCE.writeTo(output, exemplar, context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Marshaler marshaler = new TestMarshaler();
|
||||||
|
ByteArrayOutputStream customOutput =
|
||||||
|
new ByteArrayOutputStream(marshaler.getBinarySerializedSize());
|
||||||
|
marshaler.writeBinaryTo(customOutput);
|
||||||
|
lowAllocationResult = customOutput.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
assertThat(lowAllocationResult).isEqualTo(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Stream<Arguments> exemplarArgs() {
|
||||||
SpanContext spanContext =
|
SpanContext spanContext =
|
||||||
SpanContext.create(
|
SpanContext.create(
|
||||||
"7b2e170db4df2d593ddb4ddf2ddf2d59",
|
"7b2e170db4df2d593ddb4ddf2ddf2d59",
|
||||||
|
|
@ -404,5 +318,81 @@ class LowAllocationMetricsRequestMarshalerTest {
|
||||||
"long exemplar",
|
"long exemplar",
|
||||||
ImmutableLongExemplarData.create(Attributes.empty(), 12345, spanContext, 5))));
|
ImmutableLongExemplarData.create(Attributes.empty(), 12345, spanContext, 5))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void validateSummary() throws Exception {
|
||||||
|
List<ValueAtQuantile> percentileValues =
|
||||||
|
Arrays.asList(ImmutableValueAtQuantile.create(3.0, 4.0));
|
||||||
|
List<SummaryPointData> points =
|
||||||
|
Arrays.asList(
|
||||||
|
ImmutableSummaryPointData.create(
|
||||||
|
12345, 12346, Attributes.empty(), 1, 2.0, percentileValues));
|
||||||
|
SummaryData summary = ImmutableSummaryData.create(points);
|
||||||
|
|
||||||
|
byte[] result;
|
||||||
|
{
|
||||||
|
Marshaler marshaler = SummaryMarshaler.create(summary);
|
||||||
|
ByteArrayOutputStream customOutput =
|
||||||
|
new ByteArrayOutputStream(marshaler.getBinarySerializedSize());
|
||||||
|
marshaler.writeBinaryTo(customOutput);
|
||||||
|
result = customOutput.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] lowAllocationResult;
|
||||||
|
{
|
||||||
|
MarshalerContext context = new MarshalerContext();
|
||||||
|
class TestMarshaler extends MarshalerWithSize {
|
||||||
|
|
||||||
|
protected TestMarshaler() {
|
||||||
|
super(SummaryStatelessMarshaler.INSTANCE.getBinarySerializedSize(summary, context));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void writeTo(Serializer output) throws IOException {
|
||||||
|
SummaryStatelessMarshaler.INSTANCE.writeTo(output, summary, context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Marshaler marshaler = new TestMarshaler();
|
||||||
|
ByteArrayOutputStream customOutput =
|
||||||
|
new ByteArrayOutputStream(marshaler.getBinarySerializedSize());
|
||||||
|
marshaler.writeBinaryTo(customOutput);
|
||||||
|
lowAllocationResult = customOutput.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
assertThat(lowAllocationResult).isEqualTo(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Collection<MetricData> metrics(Consumer<MeterProvider> metricProducer) {
|
||||||
|
InMemoryMetricReader metricReader = InMemoryMetricReader.create();
|
||||||
|
SdkMeterProvider meterProvider =
|
||||||
|
SdkMeterProvider.builder()
|
||||||
|
.registerMetricReader(metricReader)
|
||||||
|
.registerView(
|
||||||
|
InstrumentSelector.builder().setName("exponentialhistogram").build(),
|
||||||
|
View.builder()
|
||||||
|
.setAggregation(Aggregation.base2ExponentialBucketHistogram())
|
||||||
|
.build())
|
||||||
|
.setResource(
|
||||||
|
Resource.create(
|
||||||
|
Attributes.builder()
|
||||||
|
.put(AttributeKey.booleanKey("key_bool"), true)
|
||||||
|
.put(AttributeKey.stringKey("key_string"), "string")
|
||||||
|
.put(AttributeKey.longKey("key_int"), 100L)
|
||||||
|
.put(AttributeKey.doubleKey("key_double"), 100.3)
|
||||||
|
.put(
|
||||||
|
AttributeKey.stringArrayKey("key_string_array"),
|
||||||
|
Arrays.asList("string", "string"))
|
||||||
|
.put(AttributeKey.longArrayKey("key_long_array"), Arrays.asList(12L, 23L))
|
||||||
|
.put(
|
||||||
|
AttributeKey.doubleArrayKey("key_double_array"),
|
||||||
|
Arrays.asList(12.3, 23.1))
|
||||||
|
.put(
|
||||||
|
AttributeKey.booleanArrayKey("key_boolean_array"),
|
||||||
|
Arrays.asList(true, false))
|
||||||
|
.build()))
|
||||||
|
.build();
|
||||||
|
metricProducer.accept(meterProvider);
|
||||||
|
|
||||||
|
return metricReader.collectAllMetrics();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,12 +91,10 @@ import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Order;
|
import org.junit.jupiter.api.Order;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.TestInstance;
|
import org.junit.jupiter.api.TestInstance;
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
|
||||||
import org.junit.jupiter.params.provider.ValueSource;
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
import org.slf4j.event.Level;
|
import org.slf4j.event.Level;
|
||||||
import org.slf4j.event.LoggingEvent;
|
import org.slf4j.event.LoggingEvent;
|
||||||
|
|
@ -462,7 +460,7 @@ public abstract class AbstractGrpcTelemetryExporterTest<T, U extends Message> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ArgumentsSource(ClientPrivateKeyProvider.class)
|
@MethodSource("clientPrivateKeyArgs")
|
||||||
void clientTls(byte[] privateKey) throws Exception {
|
void clientTls(byte[] privateKey) throws Exception {
|
||||||
TelemetryExporter<T> exporter =
|
TelemetryExporter<T> exporter =
|
||||||
exporterBuilder()
|
exporterBuilder()
|
||||||
|
|
@ -480,15 +478,11 @@ public abstract class AbstractGrpcTelemetryExporterTest<T, U extends Message> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ClientPrivateKeyProvider implements ArgumentsProvider {
|
private static Stream<Arguments> clientPrivateKeyArgs() throws Exception {
|
||||||
@Override
|
|
||||||
@SuppressWarnings("PrimitiveArrayPassedToVarargsMethod")
|
|
||||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) throws Exception {
|
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
arguments(named("PEM", Files.readAllBytes(clientCertificate.privateKeyFile().toPath()))),
|
arguments(named("PEM", Files.readAllBytes(clientCertificate.privateKeyFile().toPath()))),
|
||||||
arguments(named("DER", clientCertificate.privateKey().getEncoded())));
|
arguments(named("DER", clientCertificate.privateKey().getEncoded())));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressLogger(GrpcExporter.class)
|
@SuppressLogger(GrpcExporter.class)
|
||||||
|
|
|
||||||
|
|
@ -92,12 +92,10 @@ import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Order;
|
import org.junit.jupiter.api.Order;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.TestInstance;
|
import org.junit.jupiter.api.TestInstance;
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
|
||||||
import org.junit.jupiter.params.provider.ValueSource;
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
import org.mockserver.integration.ClientAndServer;
|
import org.mockserver.integration.ClientAndServer;
|
||||||
import org.slf4j.event.Level;
|
import org.slf4j.event.Level;
|
||||||
|
|
@ -477,7 +475,7 @@ public abstract class AbstractHttpTelemetryExporterTest<T, U extends Message> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ArgumentsSource(ClientPrivateKeyProvider.class)
|
@MethodSource("clientPrivateKeyArgs")
|
||||||
void clientTls(byte[] privateKey) throws Exception {
|
void clientTls(byte[] privateKey) throws Exception {
|
||||||
TelemetryExporter<T> exporter =
|
TelemetryExporter<T> exporter =
|
||||||
exporterBuilder()
|
exporterBuilder()
|
||||||
|
|
@ -495,15 +493,11 @@ public abstract class AbstractHttpTelemetryExporterTest<T, U extends Message> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ClientPrivateKeyProvider implements ArgumentsProvider {
|
private static Stream<Arguments> clientPrivateKeyArgs() throws Exception {
|
||||||
@Override
|
|
||||||
@SuppressWarnings("PrimitiveArrayPassedToVarargsMethod")
|
|
||||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) throws Exception {
|
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
arguments(named("PEM", Files.readAllBytes(clientCertificate.privateKeyFile().toPath()))),
|
arguments(named("PEM", Files.readAllBytes(clientCertificate.privateKeyFile().toPath()))),
|
||||||
arguments(named("DER", clientCertificate.privateKey().getEncoded())));
|
arguments(named("DER", clientCertificate.privateKey().getEncoded())));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressLogger(HttpExporter.class)
|
@SuppressLogger(HttpExporter.class)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,16 @@ dependencies {
|
||||||
implementation(project(":sdk:common"))
|
implementation(project(":sdk:common"))
|
||||||
|
|
||||||
compileOnly("com.fasterxml.jackson.core:jackson-core")
|
compileOnly("com.fasterxml.jackson.core:jackson-core")
|
||||||
|
|
||||||
|
// NOTE: this is a strange dependency. junit reflectively analyzes classes as part of its test discovery process, eventually encounters to jackson-databind classes, and fails with a NoClassDefFoundError:
|
||||||
|
// JUnit Jupiter > initializationError FAILED
|
||||||
|
// org.junit.platform.launcher.core.DiscoveryIssueException: TestEngine with ID 'junit-jupiter' encountered a critical issue during test discovery:
|
||||||
|
//
|
||||||
|
// (1) [ERROR] ClassSelector [className = 'io.opentelemetry.exporter.sender.jdk.internal.JdkHttpSenderTest$NoOpMarshaler', classLoader = jdk.internal.loader.ClassLoaders$AppClassLoader@2aae9190] resolution failed
|
||||||
|
// Source: ClassSource [className = 'io.opentelemetry.exporter.sender.jdk.internal.JdkHttpSenderTest$NoOpMarshaler', filePosition = null]
|
||||||
|
// at io.opentelemetry.exporter.sender.jdk.internal.JdkHttpSenderTest$NoOpMarshaler.<no-method>(SourceFile:0)
|
||||||
|
// Cause: java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonGenerator
|
||||||
|
testImplementation("com.fasterxml.jackson.core:jackson-databind")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,10 @@ import java.util.stream.Stream;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
|
||||||
|
|
||||||
/** Integration tests for the B3 propagators, in various configurations. */
|
/** Integration tests for the B3 propagators, in various configurations. */
|
||||||
class B3PropagationIntegrationTest {
|
class B3PropagationIntegrationTest {
|
||||||
|
|
@ -160,7 +158,7 @@ class B3PropagationIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ArgumentsSource(WebClientArgumentSupplier.class)
|
@MethodSource("webClientArgs")
|
||||||
void propagation(String testType, WebClient client) throws IOException {
|
void propagation(String testType, WebClient client) throws IOException {
|
||||||
OpenTelemetrySdk clientSdk = setupClient();
|
OpenTelemetrySdk clientSdk = setupClient();
|
||||||
|
|
||||||
|
|
@ -181,7 +179,7 @@ class B3PropagationIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ArgumentsSource(WebClientArgumentSupplier.class)
|
@MethodSource("webClientArgs")
|
||||||
void noClientTracing(String testType, WebClient client) throws IOException {
|
void noClientTracing(String testType, WebClient client) throws IOException {
|
||||||
assertThat(client.get("/frontend").aggregate().join().contentUtf8()).isEqualTo("OK");
|
assertThat(client.get("/frontend").aggregate().join().contentUtf8()).isEqualTo("OK");
|
||||||
|
|
||||||
|
|
@ -194,6 +192,11 @@ class B3PropagationIntegrationTest {
|
||||||
.allSatisfy(spanData -> assertThat(spanData.getTraceId()).isEqualTo(traceId));
|
.allSatisfy(spanData -> assertThat(spanData.getTraceId()).isEqualTo(traceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Stream<Arguments> webClientArgs() {
|
||||||
|
return Stream.of(
|
||||||
|
Arguments.of("b3multi", b3MultiClient), Arguments.of("b3single", b3SingleClient));
|
||||||
|
}
|
||||||
|
|
||||||
private static WebClient createPropagatingClient(URI uri, TextMapPropagator propagator) {
|
private static WebClient createPropagatingClient(URI uri, TextMapPropagator propagator) {
|
||||||
return WebClient.builder(uri)
|
return WebClient.builder(uri)
|
||||||
.decorator(
|
.decorator(
|
||||||
|
|
@ -234,12 +237,4 @@ class B3PropagationIntegrationTest {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class WebClientArgumentSupplier implements ArgumentsProvider {
|
|
||||||
@Override
|
|
||||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
|
||||||
return Stream.of(
|
|
||||||
Arguments.of("b3multi", b3MultiClient), Arguments.of("b3single", b3SingleClient));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,10 @@ import org.awaitility.core.ThrowingRunnable;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Order;
|
import org.junit.jupiter.api.Order;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
|
||||||
import org.slf4j.event.Level;
|
import org.slf4j.event.Level;
|
||||||
import org.slf4j.event.LoggingEvent;
|
import org.slf4j.event.LoggingEvent;
|
||||||
|
|
||||||
|
|
@ -169,7 +167,7 @@ class JaegerRemoteSamplerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ArgumentsSource(ClientPrivateKeyProvider.class)
|
@MethodSource("clientPrivateKeyArgs")
|
||||||
void clientTlsConnectionWorks(byte[] privateKey) throws IOException {
|
void clientTlsConnectionWorks(byte[] privateKey) throws IOException {
|
||||||
try (JaegerRemoteSampler sampler =
|
try (JaegerRemoteSampler sampler =
|
||||||
JaegerRemoteSampler.builder()
|
JaegerRemoteSampler.builder()
|
||||||
|
|
@ -189,15 +187,11 @@ class JaegerRemoteSamplerTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ClientPrivateKeyProvider implements ArgumentsProvider {
|
private static Stream<Arguments> clientPrivateKeyArgs() throws IOException {
|
||||||
@Override
|
|
||||||
@SuppressWarnings("PrimitiveArrayPassedToVarargsMethod")
|
|
||||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) throws Exception {
|
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
arguments(named("PEM", Files.readAllBytes(clientCertificate.privateKeyFile().toPath()))),
|
arguments(named("PEM", Files.readAllBytes(clientCertificate.privateKeyFile().toPath()))),
|
||||||
arguments(named("DER", clientCertificate.privateKey().getEncoded())));
|
arguments(named("DER", clientCertificate.privateKey().getEncoded())));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void tlsViaSslContext() throws Exception {
|
void tlsViaSslContext() throws Exception {
|
||||||
|
|
|
||||||
|
|
@ -51,11 +51,9 @@ import java.util.function.Consumer;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
|
||||||
|
|
||||||
class AttributesAdviceTest {
|
class AttributesAdviceTest {
|
||||||
|
|
||||||
|
|
@ -74,7 +72,7 @@ class AttributesAdviceTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ArgumentsSource(InstrumentsProvider.class)
|
@MethodSource("instrumentProviderArgs")
|
||||||
void instrumentWithoutAdvice(
|
void instrumentWithoutAdvice(
|
||||||
InstrumentFactory instrumentFactory, PointsAssert<AbstractPointAssert<?, ?>> pointsAssert) {
|
InstrumentFactory instrumentFactory, PointsAssert<AbstractPointAssert<?, ?>> pointsAssert) {
|
||||||
InMemoryMetricReader reader = InMemoryMetricReader.create();
|
InMemoryMetricReader reader = InMemoryMetricReader.create();
|
||||||
|
|
@ -91,7 +89,7 @@ class AttributesAdviceTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ArgumentsSource(InstrumentsProvider.class)
|
@MethodSource("instrumentProviderArgs")
|
||||||
void instrumentWithAdvice(
|
void instrumentWithAdvice(
|
||||||
InstrumentFactory instrumentFactory, PointsAssert<AbstractPointAssert<?, ?>> pointsAssert) {
|
InstrumentFactory instrumentFactory, PointsAssert<AbstractPointAssert<?, ?>> pointsAssert) {
|
||||||
InMemoryMetricReader reader = InMemoryMetricReader.create();
|
InMemoryMetricReader reader = InMemoryMetricReader.create();
|
||||||
|
|
@ -113,7 +111,7 @@ class AttributesAdviceTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ArgumentsSource(InstrumentsProvider.class)
|
@MethodSource("instrumentProviderArgs")
|
||||||
void instrumentWithAdviceAndViews(
|
void instrumentWithAdviceAndViews(
|
||||||
InstrumentFactory instrumentFactory, PointsAssert<AbstractPointAssert<?, ?>> pointsAssert) {
|
InstrumentFactory instrumentFactory, PointsAssert<AbstractPointAssert<?, ?>> pointsAssert) {
|
||||||
InMemoryMetricReader reader = InMemoryMetricReader.create();
|
InMemoryMetricReader reader = InMemoryMetricReader.create();
|
||||||
|
|
@ -143,7 +141,7 @@ class AttributesAdviceTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ArgumentsSource(InstrumentsProvider.class)
|
@MethodSource("instrumentProviderArgs")
|
||||||
void instrumentWithAdviceAndDescriptionViews(
|
void instrumentWithAdviceAndDescriptionViews(
|
||||||
InstrumentFactory instrumentFactory, PointsAssert<AbstractPointAssert<?, ?>> pointsAssert) {
|
InstrumentFactory instrumentFactory, PointsAssert<AbstractPointAssert<?, ?>> pointsAssert) {
|
||||||
InMemoryMetricReader reader = InMemoryMetricReader.create();
|
InMemoryMetricReader reader = InMemoryMetricReader.create();
|
||||||
|
|
@ -175,7 +173,7 @@ class AttributesAdviceTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ArgumentsSource(InstrumentsProvider.class)
|
@MethodSource("instrumentProviderArgs")
|
||||||
void instrumentWithAdviceAndBaggage(
|
void instrumentWithAdviceAndBaggage(
|
||||||
InstrumentFactory instrumentFactory, PointsAssert<AbstractPointAssert<?, ?>> pointsAssert) {
|
InstrumentFactory instrumentFactory, PointsAssert<AbstractPointAssert<?, ?>> pointsAssert) {
|
||||||
InMemoryMetricReader reader = InMemoryMetricReader.create();
|
InMemoryMetricReader reader = InMemoryMetricReader.create();
|
||||||
|
|
@ -217,10 +215,7 @@ class AttributesAdviceTest {
|
||||||
equalTo(stringKey("baggage1"), "value1"))));
|
equalTo(stringKey("baggage1"), "value1"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
static final class InstrumentsProvider implements ArgumentsProvider {
|
private static Stream<Arguments> instrumentProviderArgs() {
|
||||||
|
|
||||||
@Override
|
|
||||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
// double counter
|
// double counter
|
||||||
arguments(
|
arguments(
|
||||||
|
|
@ -254,8 +249,7 @@ class AttributesAdviceTest {
|
||||||
},
|
},
|
||||||
(PointsAssert<LongPointAssert>)
|
(PointsAssert<LongPointAssert>)
|
||||||
(metricAssert, assertions) ->
|
(metricAssert, assertions) ->
|
||||||
metricAssert.hasLongSumSatisfying(
|
metricAssert.hasLongSumSatisfying(sum -> sum.hasPointsSatisfying(assertions))),
|
||||||
sum -> sum.hasPointsSatisfying(assertions))),
|
|
||||||
// double gauge
|
// double gauge
|
||||||
arguments(
|
arguments(
|
||||||
(InstrumentFactory)
|
(InstrumentFactory)
|
||||||
|
|
@ -356,9 +350,7 @@ class AttributesAdviceTest {
|
||||||
},
|
},
|
||||||
(PointsAssert<LongPointAssert>)
|
(PointsAssert<LongPointAssert>)
|
||||||
(metricAssert, assertions) ->
|
(metricAssert, assertions) ->
|
||||||
metricAssert.hasLongSumSatisfying(
|
metricAssert.hasLongSumSatisfying(sum -> sum.hasPointsSatisfying(assertions))));
|
||||||
sum -> sum.hasPointsSatisfying(assertions))));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue