Remove guava dependency from testing-common (#13676)

This commit is contained in:
Lauri Tulmin 2025-04-09 17:05:45 +03:00 committed by GitHub
parent 62e4de955b
commit d503937806
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
44 changed files with 90 additions and 109 deletions

View File

@ -19,6 +19,9 @@ dependencies {
testLibrary("com.linecorp.armeria:armeria-junit5:1.3.0")
testImplementation(project(":instrumentation:armeria:armeria-1.3:testing"))
// needed for latest dep tests
testCompileOnly("com.google.errorprone:error_prone_annotations")
}
tasks {

View File

@ -7,6 +7,9 @@ dependencies {
library("com.linecorp.armeria:armeria:1.3.0")
testImplementation(project(":instrumentation:armeria:armeria-1.3:testing"))
// needed for latest dep tests
testCompileOnly("com.google.errorprone:error_prone_annotations")
}
tasks {

View File

@ -23,7 +23,6 @@ dependencies {
testImplementation("io.opentelemetry.contrib:opentelemetry-aws-xray-propagator")
testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
testImplementation("io.opentelemetry:opentelemetry-extension-trace-propagators")
testImplementation("com.google.guava:guava")
testImplementation(project(":instrumentation:aws-lambda:aws-lambda-core-1.0:testing"))
testImplementation("uk.org.webcompere:system-stubs-jupiter")

View File

@ -10,8 +10,6 @@ dependencies {
api("org.junit-pioneer:junit-pioneer")
api("org.mockito:mockito-junit-jupiter")
implementation("com.google.guava:guava")
implementation("io.opentelemetry:opentelemetry-api")
implementation("com.github.stefanbirkner:system-lambda")
}

View File

@ -39,7 +39,6 @@ dependencies {
testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
testImplementation("io.opentelemetry:opentelemetry-extension-trace-propagators")
testImplementation("com.google.guava:guava")
testImplementation("com.amazonaws:aws-lambda-java-serialization:1.1.5")
testImplementation(project(":instrumentation:aws-lambda:aws-lambda-events-2.2:testing"))

View File

@ -11,8 +11,6 @@ dependencies {
api("org.junit-pioneer:junit-pioneer")
api("org.mockito:mockito-junit-jupiter")
implementation("com.google.guava:guava")
implementation("io.opentelemetry:opentelemetry-api")
implementation("com.github.stefanbirkner:system-lambda")
}

View File

@ -23,6 +23,7 @@ import static io.opentelemetry.semconv.incubating.RpcIncubatingAttributes.RPC_SE
import static io.opentelemetry.semconv.incubating.RpcIncubatingAttributes.RPC_SYSTEM;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonMap;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;
@ -45,7 +46,6 @@ import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.rds.AmazonRDSClient;
import com.amazonaws.services.rds.model.DeleteOptionGroupRequest;
import com.amazonaws.services.s3.AmazonS3Client;
import com.google.common.collect.ImmutableMap;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
@ -137,7 +137,7 @@ class Aws0ClientTest {
"PUT",
1,
(Function<AmazonS3Client, Object>) c -> c.createBucket("testbucket"),
ImmutableMap.of("aws.bucket.name", "testbucket"),
singletonMap("aws.bucket.name", "testbucket"),
""),
Arguments.of(
new AmazonS3Client().withEndpoint(server.httpUri().toString()),
@ -146,7 +146,7 @@ class Aws0ClientTest {
"GET",
1,
(Function<AmazonS3Client, Object>) c -> c.getObject("someBucket", "someKey"),
ImmutableMap.of("aws.bucket.name", "someBucket"),
singletonMap("aws.bucket.name", "someBucket"),
""),
Arguments.of(
new AmazonEC2Client().withEndpoint(server.httpUri().toString()),

View File

@ -18,7 +18,5 @@ dependencies {
// needed for SQS - using emq directly as localstack references emq v0.15.7 ie WITHOUT AWS trace header propagation
implementation("org.elasticmq:elasticmq-rest-sqs_2.13")
implementation("com.google.guava:guava")
implementation("io.opentelemetry:opentelemetry-api")
}

View File

@ -33,12 +33,12 @@ import com.amazonaws.services.sqs.AmazonSQSAsyncClientBuilder;
import com.amazonaws.services.sqs.model.ReceiveMessageRequest;
import com.amazonaws.services.sqs.model.ReceiveMessageResult;
import com.amazonaws.services.sqs.model.SendMessageRequest;
import com.google.common.collect.ImmutableList;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.test.utils.PortUtils;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
import java.util.Collections;
import org.elasticmq.rest.sqs.SQSRestServer;
import org.elasticmq.rest.sqs.SQSRestServerBuilder;
import org.junit.jupiter.api.AfterEach;
@ -319,6 +319,6 @@ public abstract class AbstractSqsSuppressReceiveSpansTest {
sqsClient.receiveMessage(receive);
sqsClient.sendMessage(send);
sqsClient.receiveMessage(receive);
assertThat(receive.getAttributeNames()).isEqualTo(ImmutableList.of("AWSTraceHeader"));
assertThat(receive.getAttributeNames()).isEqualTo(Collections.singletonList("AWSTraceHeader"));
}
}

View File

@ -24,6 +24,7 @@ import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.
import static io.opentelemetry.semconv.incubating.RpcIncubatingAttributes.RPC_METHOD;
import static io.opentelemetry.semconv.incubating.RpcIncubatingAttributes.RPC_SERVICE;
import static io.opentelemetry.semconv.incubating.RpcIncubatingAttributes.RPC_SYSTEM;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
@ -37,7 +38,6 @@ import com.amazonaws.services.sqs.model.MessageAttributeValue;
import com.amazonaws.services.sqs.model.ReceiveMessageRequest;
import com.amazonaws.services.sqs.model.ReceiveMessageResult;
import com.amazonaws.services.sqs.model.SendMessageRequest;
import com.google.common.collect.ImmutableList;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.test.utils.PortUtils;
@ -183,7 +183,7 @@ public abstract class AbstractSqsTracingTest {
attributes.add(
satisfies(
stringArrayKey("messaging.header.test_message_header"),
val -> val.isEqualTo(ImmutableList.of("test"))));
val -> val.isEqualTo(singletonList("test"))));
}
span.hasName("testSdkSqs publish")
@ -223,7 +223,7 @@ public abstract class AbstractSqsTracingTest {
attributes.add(
satisfies(
stringArrayKey("messaging.header.test_message_header"),
val -> val.isEqualTo(ImmutableList.of("test"))));
val -> val.isEqualTo(singletonList("test"))));
}
span.hasName("testSdkSqs receive")
@ -262,7 +262,7 @@ public abstract class AbstractSqsTracingTest {
attributes.add(
satisfies(
stringArrayKey("messaging.header.test_message_header"),
val -> val.isEqualTo(ImmutableList.of("test"))));
val -> val.isEqualTo(singletonList("test"))));
}
span.hasName("testSdkSqs process")
.hasKind(SpanKind.CONSUMER)
@ -475,6 +475,6 @@ public abstract class AbstractSqsTracingTest {
sqsClient.receiveMessage(receive);
sqsClient.sendMessage(send);
sqsClient.receiveMessage(receive);
assertThat(receive.getAttributeNames()).isEqualTo(ImmutableList.of("AWSTraceHeader"));
assertThat(receive.getAttributeNames()).isEqualTo(singletonList("AWSTraceHeader"));
}
}

View File

@ -30,7 +30,5 @@ dependencies {
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.18.2")
implementation("com.google.guava:guava")
implementation("io.opentelemetry:opentelemetry-api")
}

View File

@ -16,6 +16,7 @@ dependencies {
compileOnly("com.google.auto.value:auto-value-annotations")
annotationProcessor("com.google.auto.value:auto-value")
testImplementation("com.google.guava:guava")
testLibrary("com.clickhouse:clickhouse-client:0.5.0")
testLibrary("com.clickhouse:clickhouse-http-client:0.5.0")
testLibrary("org.apache.httpcomponents.client5:httpclient5:5.2.3")

View File

@ -5,7 +5,7 @@
package io.opentelemetry.javaagent.instrumentation.finaglehttp.v23_11;
import static io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions.DEFAULT_HTTP_ATTRIBUTES;
import static io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions.DEFAULT_HTTP_ATTRIBUTES_WITHOUT_ROUTE;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.CAPTURE_HEADERS;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.ERROR;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;
@ -14,9 +14,7 @@ import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.QUERY_PARAM;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.REDIRECT;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.SUCCESS;
import static io.opentelemetry.semconv.HttpAttributes.HTTP_ROUTE;
import com.google.common.collect.Sets;
import com.twitter.finagle.ListeningServer;
import com.twitter.finagle.Service;
import com.twitter.finagle.http.Request;
@ -35,7 +33,6 @@ import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumenta
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions;
import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint;
import java.net.URI;
import java.util.Collections;
import org.junit.jupiter.api.extension.RegisterExtension;
abstract class AbstractServerTest extends AbstractHttpServerTest<ListeningServer> {
@ -47,8 +44,7 @@ abstract class AbstractServerTest extends AbstractHttpServerTest<ListeningServer
protected void configure(HttpServerTestOptions options) {
super.configure(options);
options.setTestException(false);
options.setHttpAttributes(
unused -> Sets.difference(DEFAULT_HTTP_ATTRIBUTES, Collections.singleton(HTTP_ROUTE)));
options.setHttpAttributes(unused -> DEFAULT_HTTP_ATTRIBUTES_WITHOUT_ROUTE);
options.setTestCaptureHttpHeaders(true);
}

View File

@ -35,6 +35,7 @@ dependencies {
// some classes in earlier versions of derby were split out into derbytools in later versions
latestDepTestLibrary("org.apache.derby:derbytools:latest.release")
testImplementation("com.google.guava:guava")
testImplementation(project(":instrumentation:jdbc:testing"))
// these dependencies are for SlickTest

View File

@ -5,7 +5,7 @@
package io.opentelemetry.javaagent.instrumentation.jetty.v11_0;
import static io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions.DEFAULT_HTTP_ATTRIBUTES;
import static io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions.DEFAULT_HTTP_ATTRIBUTES_WITHOUT_ROUTE;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.CAPTURE_HEADERS;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.ERROR;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;
@ -15,10 +15,8 @@ import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.REDIRECT;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.SUCCESS;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.semconv.HttpAttributes.HTTP_ROUTE;
import static org.assertj.core.api.Assertions.assertThat;
import com.google.common.collect.Sets;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerTest;
@ -33,7 +31,6 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Writer;
import java.util.Collections;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Response;
import org.eclipse.jetty.server.Server;
@ -78,8 +75,7 @@ class JettyHandlerTest extends AbstractHttpServerTest<Server> {
@Override
protected void configure(HttpServerTestOptions options) {
options.setHttpAttributes(
unused -> Sets.difference(DEFAULT_HTTP_ATTRIBUTES, Collections.singleton(HTTP_ROUTE)));
options.setHttpAttributes(unused -> DEFAULT_HTTP_ATTRIBUTES_WITHOUT_ROUTE);
options.setHasResponseSpan(endpoint -> endpoint == REDIRECT || endpoint == ERROR);
options.setHasResponseCustomizer(endpoint -> true);
}

View File

@ -5,7 +5,7 @@
package io.opentelemetry.javaagent.instrumentation.jetty.v12_0;
import static io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions.DEFAULT_HTTP_ATTRIBUTES;
import static io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions.DEFAULT_HTTP_ATTRIBUTES_WITHOUT_ROUTE;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.CAPTURE_HEADERS;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.ERROR;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;
@ -15,10 +15,8 @@ import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.REDIRECT;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.SUCCESS;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.semconv.HttpAttributes.HTTP_ROUTE;
import static org.assertj.core.api.Assertions.assertThat;
import com.google.common.collect.Sets;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerTest;
@ -29,7 +27,6 @@ import io.opentelemetry.sdk.testing.assertj.SpanDataAssert;
import io.opentelemetry.semconv.incubating.CodeIncubatingAttributes;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Response;
@ -59,8 +56,7 @@ class Jetty12HandlerTest extends AbstractHttpServerTest<Server> {
@Override
protected void configure(HttpServerTestOptions options) {
options.setHttpAttributes(
unused -> Sets.difference(DEFAULT_HTTP_ATTRIBUTES, Collections.singleton(HTTP_ROUTE)));
options.setHttpAttributes(unused -> DEFAULT_HTTP_ATTRIBUTES_WITHOUT_ROUTE);
options.setHasResponseCustomizer(endpoint -> endpoint != EXCEPTION);
}

View File

@ -5,7 +5,7 @@
package io.opentelemetry.javaagent.instrumentation.jetty.v8_0;
import static io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions.DEFAULT_HTTP_ATTRIBUTES;
import static io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions.DEFAULT_HTTP_ATTRIBUTES_WITHOUT_ROUTE;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.CAPTURE_HEADERS;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.ERROR;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;
@ -15,10 +15,8 @@ import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.REDIRECT;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.SUCCESS;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.semconv.HttpAttributes.HTTP_ROUTE;
import static org.assertj.core.api.Assertions.assertThat;
import com.google.common.collect.Sets;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerTest;
@ -29,7 +27,6 @@ import io.opentelemetry.sdk.testing.assertj.SpanDataAssert;
import io.opentelemetry.semconv.incubating.CodeIncubatingAttributes;
import java.io.IOException;
import java.io.Writer;
import java.util.Collections;
import javax.servlet.DispatcherType;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@ -78,8 +75,7 @@ class JettyHandlerTest extends AbstractHttpServerTest<Server> {
@Override
protected void configure(HttpServerTestOptions options) {
options.setHttpAttributes(
unused -> Sets.difference(DEFAULT_HTTP_ATTRIBUTES, Collections.singleton(HTTP_ROUTE)));
options.setHttpAttributes(unused -> DEFAULT_HTTP_ATTRIBUTES_WITHOUT_ROUTE);
options.setHasResponseSpan(endpoint -> endpoint == REDIRECT || endpoint == ERROR);
options.setHasResponseCustomizer(endpoint -> endpoint != EXCEPTION);
}

View File

@ -19,6 +19,7 @@ dependencies {
// Include kafka-clients instrumentation for tests.
testInstrumentation(project(":instrumentation:kafka:kafka-clients:kafka-clients-0.11:javaagent"))
testImplementation("com.google.guava:guava")
testImplementation("org.testcontainers:kafka")
}

View File

@ -16,7 +16,9 @@ dependencies {
implementation(project(":instrumentation:lettuce:lettuce-common:library"))
testImplementation("com.google.guava:guava")
testImplementation("io.lettuce:lettuce-core:5.0.0.RELEASE")
testInstrumentation(project(":instrumentation:reactor:reactor-3.1:javaagent"))
latestDepTestLibrary("io.lettuce:lettuce-core:5.0.+") // see lettuce-5.1 module

View File

@ -5,10 +5,13 @@
package io.opentelemetry.instrumentation.lettuce.common;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Named.named;
import com.google.common.collect.ImmutableList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
@ -24,29 +27,29 @@ class LettuceArgSplitterTest {
private static Stream<Arguments> providesArguments() {
return Stream.of(
Arguments.of(named("a null value", new Parameter(null, ImmutableList.of()))),
Arguments.of(named("an empty value", new Parameter("", ImmutableList.of()))),
Arguments.of(named("a single key", new Parameter("key<key>", ImmutableList.of("key")))),
Arguments.of(named("a null value", new Parameter(null, emptyList()))),
Arguments.of(named("an empty value", new Parameter("", emptyList()))),
Arguments.of(named("a single key", new Parameter("key<key>", singletonList("key")))),
Arguments.of(
named("a single value", new Parameter("value<value>", ImmutableList.of("value")))),
named("a single value", new Parameter("value<value>", singletonList("value")))),
Arguments.of(
named("a plain string", new Parameter("teststring", ImmutableList.of("teststring")))),
Arguments.of(named("an integer", new Parameter("42", ImmutableList.of("42")))),
named("a plain string", new Parameter("teststring", singletonList("teststring")))),
Arguments.of(named("an integer", new Parameter("42", singletonList("42")))),
Arguments.of(
named("a base64 value", new Parameter("TeST123==", ImmutableList.of("TeST123==")))),
named("a base64 value", new Parameter("TeST123==", singletonList("TeST123==")))),
Arguments.of(
named(
"a complex list of args",
new Parameter(
"key<key> aSDFgh4321= 5 test value<val>",
ImmutableList.of("key", "aSDFgh4321=", "5", "test", "val")))));
Arrays.asList("key", "aSDFgh4321=", "5", "test", "val")))));
}
private static class Parameter {
public final String args;
public final ImmutableList<String> result;
public final List<String> result;
public Parameter(String query, ImmutableList<String> result) {
public Parameter(String query, List<String> result) {
this.args = query;
this.result = result;
}

View File

@ -26,6 +26,7 @@ dependencies {
// this dependency is needed for the slf4j->log4j test
testImplementation("org.apache.logging.log4j:log4j-slf4j2-impl:2.+")
testCompileOnly("biz.aQute.bnd:biz.aQute.bnd.annotation:7.0.0")
testCompileOnly("com.google.errorprone:error_prone_annotations")
} else {
// log4j 2.17 doesn't have an slf4j2 bridge
testImplementation("org.apache.logging.log4j:log4j-slf4j-impl:2.17.0")

View File

@ -13,6 +13,7 @@ dependencies {
if (findProperty("testLatestDeps") as Boolean) {
testCompileOnly("biz.aQute.bnd:biz.aQute.bnd.annotation:7.0.0")
testCompileOnly("com.google.errorprone:error_prone_annotations")
}
}

View File

@ -7,8 +7,6 @@ dependencies {
api("org.apache.logging.log4j:log4j-core:2.7")
implementation("com.google.guava:guava")
implementation("io.opentelemetry:opentelemetry-api")
annotationProcessor("org.apache.logging.log4j:log4j-core:2.7")

View File

@ -9,6 +9,5 @@ dependencies {
api("ch.qos.logback:logback-classic:1.0.0")
implementation("com.google.guava:guava")
implementation("io.opentelemetry:opentelemetry-api")
}

View File

@ -9,7 +9,7 @@ import static io.netty.handler.codec.http.HttpHeaderNames.CONTENT_LENGTH;
import static io.netty.handler.codec.http.HttpHeaderNames.CONTENT_TYPE;
import static io.netty.handler.codec.http.HttpResponseStatus.INTERNAL_SERVER_ERROR;
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
import static io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions.DEFAULT_HTTP_ATTRIBUTES;
import static io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions.DEFAULT_HTTP_ATTRIBUTES_WITHOUT_ROUTE;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.CAPTURE_HEADERS;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.ERROR;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;
@ -18,9 +18,7 @@ import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.QUERY_PARAM;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.REDIRECT;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.SUCCESS;
import static io.opentelemetry.semconv.HttpAttributes.HTTP_ROUTE;
import com.google.common.collect.Sets;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
@ -46,7 +44,6 @@ import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerTes
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions;
import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint;
import java.net.URI;
import java.util.Collections;
public abstract class AbstractNetty41ServerTest extends AbstractHttpServerTest<EventLoopGroup> {
@ -58,8 +55,7 @@ public abstract class AbstractNetty41ServerTest extends AbstractHttpServerTest<E
@Override
protected void configure(HttpServerTestOptions options) {
options.setTestException(false);
options.setHttpAttributes(
unused -> Sets.difference(DEFAULT_HTTP_ATTRIBUTES, Collections.singleton(HTTP_ROUTE)));
options.setHttpAttributes(unused -> DEFAULT_HTTP_ATTRIBUTES_WITHOUT_ROUTE);
}
@Override

View File

@ -7,7 +7,5 @@ dependencies {
api("com.squareup.okhttp3:okhttp:3.0.0")
implementation("com.google.guava:guava")
implementation("io.opentelemetry:opentelemetry-api")
}

View File

@ -6,6 +6,5 @@ dependencies {
api(project(":testing-common"))
implementation("org.apache.rocketmq:rocketmq-test:4.8.0")
implementation("com.google.guava:guava")
implementation("io.opentelemetry:opentelemetry-api")
}

View File

@ -4,10 +4,7 @@ plugins {
dependencies {
api(project(":testing-common"))
api("io.reactivex.rxjava2:rxjava:2.1.3")
implementation("com.google.guava:guava")
implementation("io.opentelemetry:opentelemetry-api")
}

View File

@ -6,10 +6,10 @@
package io.opentelemetry.instrumentation.rxjava.v2_0;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.attributeEntry;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import com.google.common.primitives.Ints;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
@ -173,8 +173,7 @@ public abstract class AbstractRxJava2Test {
public void basicFlowable() {
Iterable<Integer> result =
createParentSpan(
() ->
Flowable.fromIterable(Ints.asList(5, 6)).map(this::addOne).toList().blockingGet());
() -> Flowable.fromIterable(asList(5, 6)).map(this::addOne).toList().blockingGet());
assertThat(result).contains(6, 7);
testing()
.waitAndAssertTraces(
@ -196,7 +195,7 @@ public abstract class AbstractRxJava2Test {
List<Integer> result =
createParentSpan(
() ->
Flowable.fromIterable(Ints.asList(6, 7))
Flowable.fromIterable(asList(6, 7))
.map(this::addOne)
.map(this::addOne)
.toList()
@ -230,7 +229,7 @@ public abstract class AbstractRxJava2Test {
List<Integer> result =
createParentSpan(
() ->
Flowable.fromIterable(Ints.asList(7, 8))
Flowable.fromIterable(asList(7, 8))
.delay(100, TimeUnit.MILLISECONDS)
.map(this::addOne)
.toList()
@ -256,7 +255,7 @@ public abstract class AbstractRxJava2Test {
List<Integer> result =
createParentSpan(
() ->
Flowable.fromIterable(Ints.asList(8, 9))
Flowable.fromIterable(asList(8, 9))
.delay(100, TimeUnit.MILLISECONDS)
.map(this::addOne)
.delay(100, TimeUnit.MILLISECONDS)
@ -477,7 +476,7 @@ public abstract class AbstractRxJava2Test {
() ->
createParentSpan(
() ->
Flowable.fromIterable(Ints.asList(5, 6))
Flowable.fromIterable(asList(5, 6))
.map(this::addOne)
.map(
i -> {
@ -513,7 +512,7 @@ public abstract class AbstractRxJava2Test {
public void basicFlowableCancel() {
createParentSpan(
() ->
Flowable.fromIterable(Ints.asList(5, 6))
Flowable.fromIterable(asList(5, 6))
.map(this::addOne)
.subscribe(CancellingSubscriber.INSTANCE));
testing()
@ -597,7 +596,7 @@ public abstract class AbstractRxJava2Test {
public void basicFlowableChain() {
createParentSpan(
() ->
Flowable.fromIterable(Ints.asList(5, 6))
Flowable.fromIterable(asList(5, 6))
.map(this::addOne)
.map(this::addOne)
.concatWith(Maybe.just(1).map(this::addOne).toFlowable())
@ -685,8 +684,7 @@ public abstract class AbstractRxJava2Test {
List<Integer> result =
createParentSpan(
() -> {
Flowable<Integer> flowable =
Flowable.fromIterable(Ints.asList(1, 2)).map(this::addOne);
Flowable<Integer> flowable = Flowable.fromIterable(asList(1, 2)).map(this::addOne);
return testing()
.runWithSpan("intermediate", () -> flowable.map(this::addTwo))
.toList()
@ -789,7 +787,7 @@ public abstract class AbstractRxJava2Test {
.runWithSpan(
"flowable root",
() -> {
return Flowable.fromIterable(Ints.asList(1, 2, 3, 4))
return Flowable.fromIterable(asList(1, 2, 3, 4))
.parallel()
.runOn(scheduler)
.flatMap(num -> Maybe.just(num).map(this::addOne).toFlowable())

View File

@ -9,6 +9,5 @@ dependencies {
implementation(project(":instrumentation-annotations"))
implementation("io.opentelemetry:opentelemetry-extension-annotations")
implementation("com.google.guava:guava")
implementation("io.opentelemetry:opentelemetry-api")
}

View File

@ -7,9 +7,9 @@ package io.opentelemetry.instrumentation.rxjava.v3.common;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.attributeEntry;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import com.google.common.primitives.Ints;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
@ -173,8 +173,7 @@ public abstract class AbstractRxJava3Test {
public void basicFlowable() {
Iterable<Integer> result =
createParentSpan(
() ->
Flowable.fromIterable(Ints.asList(5, 6)).map(this::addOne).toList().blockingGet());
() -> Flowable.fromIterable(asList(5, 6)).map(this::addOne).toList().blockingGet());
assertThat(result).contains(6, 7);
testing()
.waitAndAssertTraces(
@ -196,7 +195,7 @@ public abstract class AbstractRxJava3Test {
List<Integer> result =
createParentSpan(
() ->
Flowable.fromIterable(Ints.asList(6, 7))
Flowable.fromIterable(asList(6, 7))
.map(this::addOne)
.map(this::addOne)
.toList()
@ -230,7 +229,7 @@ public abstract class AbstractRxJava3Test {
List<Integer> result =
createParentSpan(
() ->
Flowable.fromIterable(Ints.asList(7, 8))
Flowable.fromIterable(asList(7, 8))
.delay(100, TimeUnit.MILLISECONDS)
.map(this::addOne)
.toList()
@ -256,7 +255,7 @@ public abstract class AbstractRxJava3Test {
List<Integer> result =
createParentSpan(
() ->
Flowable.fromIterable(Ints.asList(8, 9))
Flowable.fromIterable(asList(8, 9))
.delay(100, TimeUnit.MILLISECONDS)
.map(this::addOne)
.delay(100, TimeUnit.MILLISECONDS)
@ -477,7 +476,7 @@ public abstract class AbstractRxJava3Test {
() ->
createParentSpan(
() ->
Flowable.fromIterable(Ints.asList(5, 6))
Flowable.fromIterable(asList(5, 6))
.map(this::addOne)
.map(
i -> {
@ -513,7 +512,7 @@ public abstract class AbstractRxJava3Test {
public void basicFlowableCancel() {
createParentSpan(
() ->
Flowable.fromIterable(Ints.asList(5, 6))
Flowable.fromIterable(asList(5, 6))
.map(this::addOne)
.subscribe(CancellingSubscriber.INSTANCE));
testing()
@ -597,7 +596,7 @@ public abstract class AbstractRxJava3Test {
public void basicFlowableChain() {
createParentSpan(
() ->
Flowable.fromIterable(Ints.asList(5, 6))
Flowable.fromIterable(asList(5, 6))
.map(this::addOne)
.map(this::addOne)
.concatWith(Maybe.just(1).map(this::addOne))
@ -685,8 +684,7 @@ public abstract class AbstractRxJava3Test {
List<Integer> result =
createParentSpan(
() -> {
Flowable<Integer> flowable =
Flowable.fromIterable(Ints.asList(1, 2)).map(this::addOne);
Flowable<Integer> flowable = Flowable.fromIterable(asList(1, 2)).map(this::addOne);
return testing()
.runWithSpan("intermediate", () -> flowable.map(this::addTwo))
.toList()
@ -789,7 +787,7 @@ public abstract class AbstractRxJava3Test {
.runWithSpan(
"flowable root",
() -> {
return Flowable.fromIterable(Ints.asList(1, 2, 3, 4))
return Flowable.fromIterable(asList(1, 2, 3, 4))
.parallel()
.runOn(scheduler)
.flatMap(num -> Maybe.just(num).map(this::addOne).toFlowable())

View File

@ -14,7 +14,9 @@ muzzle {
dependencies {
library("org.springframework.batch:spring-batch-core:3.0.0.RELEASE")
testImplementation("com.google.guava:guava")
testImplementation("javax.inject:javax.inject:1")
// SimpleAsyncTaskExecutor context propagation
testInstrumentation(project(":instrumentation:spring:spring-core-2.0:javaagent"))

View File

@ -7,11 +7,11 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.internal.resources
import static org.assertj.core.api.Assertions.assertThat;
import com.google.common.collect.ImmutableMap;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider;
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
import java.util.Collections;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@ -35,7 +35,7 @@ public class DistroVersionResourceProviderTest {
assertThat(
resource
.createResource(DefaultConfigProperties.createFromMap(ImmutableMap.of()))
.createResource(DefaultConfigProperties.createFromMap(Collections.emptyMap()))
.getAttributes()
.asMap())
.containsEntry(

View File

@ -32,6 +32,7 @@ dependencies {
testInstrumentation(project(":instrumentation:spring:spring-web:spring-web-3.1:javaagent"))
testImplementation(project(":instrumentation:spring:spring-webmvc:spring-webmvc-common:testing"))
testImplementation("com.google.guava:guava")
testLibrary("org.springframework.boot:spring-boot-starter-test:1.5.17.RELEASE")
testLibrary("org.springframework.boot:spring-boot-starter-web:1.5.17.RELEASE")

View File

@ -15,7 +15,6 @@ import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_NAMESPACE;
import static org.assertj.core.api.Assertions.assertThat;
import com.google.common.collect.ImmutableMap;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.spring.webmvc.boot.AbstractSpringBootBasedTest;
import io.opentelemetry.instrumentation.spring.webmvc.boot.AppConfig;
@ -26,6 +25,7 @@ import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint;
import io.opentelemetry.sdk.testing.assertj.SpanDataAssert;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.data.StatusData;
import java.util.Map;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
@ -55,7 +55,7 @@ class SpringBootBasedTest extends AbstractSpringBootBasedTest {
protected ConfigurableApplicationContext setupServer() {
SpringApplication app = new SpringApplication(AppConfig.class, securityConfigClass());
app.setDefaultProperties(
ImmutableMap.of(
Map.of(
"server.port",
port,
"server.context-path",

View File

@ -12,7 +12,6 @@ import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_STACKTRACE;
import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_TYPE;
import static org.assertj.core.api.Assertions.assertThat;
import com.google.common.collect.ImmutableMap;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.spring.webmvc.filter.AbstractServletFilterTest;
import io.opentelemetry.instrumentation.spring.webmvc.filter.FilteredAppConfig;
@ -24,6 +23,7 @@ import io.opentelemetry.javaagent.instrumentation.spring.webmvc.v6_0.boot.Securi
import io.opentelemetry.sdk.testing.assertj.SpanDataAssert;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.data.StatusData;
import java.util.Map;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
@ -50,8 +50,7 @@ class ServletFilterTest extends AbstractServletFilterTest {
protected ConfigurableApplicationContext setupServer() {
SpringApplication app =
new SpringApplication(FilteredAppConfig.class, securityConfigClass(), filterConfigClass());
app.setDefaultProperties(
ImmutableMap.of("server.port", port, "server.error.include-message", "always"));
app.setDefaultProperties(Map.of("server.port", port, "server.error.include-message", "always"));
return app.run();
}

View File

@ -46,6 +46,7 @@ dependencies {
testImplementation("javax.xml.bind:jaxb-api:2.2.11")
testImplementation("com.sun.xml.bind:jaxb-core:2.2.11")
testImplementation("com.sun.xml.bind:jaxb-impl:2.2.11")
testImplementation("com.google.guava:guava")
testInstrumentation(project(":instrumentation:servlet:servlet-3.0:javaagent"))
}

View File

@ -13,7 +13,6 @@ import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.SUCCESS;
import static io.opentelemetry.semconv.NetworkAttributes.NETWORK_PEER_PORT;
import com.google.common.collect.ImmutableSet;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerTest;
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension;
@ -23,6 +22,7 @@ import io.undertow.Undertow;
import io.undertow.util.Headers;
import io.undertow.util.HttpString;
import io.undertow.util.StatusCodes;
import java.util.Collections;
import org.junit.jupiter.api.extension.RegisterExtension;
class UndertowServerDispatchTest extends AbstractHttpServerTest<Undertow> {
@ -130,6 +130,6 @@ class UndertowServerDispatchTest extends AbstractHttpServerTest<Undertow> {
options.setTestException(false);
options.setHasResponseCustomizer(endpoint -> true);
options.setHttpAttributes(endpoint -> ImmutableSet.of(NETWORK_PEER_PORT));
options.setHttpAttributes(endpoint -> Collections.singleton(NETWORK_PEER_PORT));
}
}

View File

@ -30,7 +30,6 @@ import static io.opentelemetry.semconv.UrlAttributes.URL_SCHEME;
import static io.opentelemetry.semconv.UserAgentAttributes.USER_AGENT_ORIGINAL;
import static org.assertj.core.api.Assertions.assertThat;
import com.google.common.collect.ImmutableSet;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
@ -44,6 +43,7 @@ import io.undertow.util.Headers;
import io.undertow.util.HttpString;
import io.undertow.util.StatusCodes;
import java.net.URI;
import java.util.Collections;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@ -168,7 +168,7 @@ class UndertowServerTest extends AbstractHttpServerTest<Undertow> {
@Override
protected void configure(HttpServerTestOptions options) {
super.configure(options);
options.setHttpAttributes(endpoint -> ImmutableSet.of(NETWORK_PEER_PORT));
options.setHttpAttributes(endpoint -> Collections.singleton(NETWORK_PEER_PORT));
options.setHasResponseCustomizer(serverEndpoint -> true);
options.setUseHttp2(useHttp2());
}

View File

@ -14,6 +14,7 @@ dependencies {
compileOnly("org.springframework.boot:spring-boot-starter-test")
api(project(":testing-common"))
api("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
implementation("com.google.guava:guava")
}
tasks.withType<BootJar> {

View File

@ -51,7 +51,6 @@ dependencies {
api("org.assertj:assertj-core")
// Needs to be api dependency due to Spock restriction.
api("org.awaitility:awaitility")
api("com.google.guava:guava")
api("org.mockito:mockito-core")
api("org.slf4j:slf4j-api")

View File

@ -26,7 +26,8 @@ public final class HttpServerTestOptions {
public static final Set<AttributeKey<?>> DEFAULT_HTTP_ATTRIBUTES =
Collections.unmodifiableSet(
new HashSet<>(Arrays.asList(HttpAttributes.HTTP_ROUTE, ServerAttributes.SERVER_PORT)));
public static final Set<AttributeKey<?>> DEFAULT_HTTP_ATTRIBUTES_WITHOUT_ROUTE =
Collections.singleton(ServerAttributes.SERVER_PORT);
public static final SpanNameMapper DEFAULT_EXPECTED_SERVER_SPAN_NAME_MAPPER =
(uri, method, route) -> {
if (HttpConstants._OTHER.equals(method)) {

View File

@ -5,7 +5,6 @@
package io.opentelemetry.javaagent.testing.common;
import static com.google.common.base.Strings.emptyToNull;
import static io.opentelemetry.api.common.AttributeKey.booleanArrayKey;
import static io.opentelemetry.api.common.AttributeKey.doubleArrayKey;
import static io.opentelemetry.api.common.AttributeKey.longArrayKey;
@ -757,5 +756,9 @@ public final class AgentTestingExporterAccess {
return encoding;
}
private static String emptyToNull(String string) {
return string == null || string.isEmpty() ? null : string;
}
private AgentTestingExporterAccess() {}
}

View File

@ -5,6 +5,7 @@ plugins {
dependencies {
implementation("com.linecorp.armeria:armeria-junit5:1.32.4")
implementation("com.google.errorprone:error_prone_annotations")
}
tasks {
@ -21,6 +22,7 @@ tasks {
relocate("net.bytebuddy", "io.opentelemetry.testing.internal.bytebuddy")
relocate("reactor", "io.opentelemetry.testing.internal.reactor")
relocate("com.aayushatharva.brotli4j", "io.opentelemetry.testing.internal.brotli4j")
relocate("com.google.errorprone", "io.opentelemetry.testing.internal.errorprone")
// Allows tests of Netty instrumentations which would otherwise conflict.
// The relocation must end with io.netty to allow Netty to detect shaded native libraries.