diff --git a/instrumentation/camel-2.20/javaagent-unit-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/CamelPropagationUtilTest.java b/instrumentation/camel-2.20/javaagent-unit-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/CamelPropagationUtilTest.java index 38dfafead3f5..42319e3e1a6c 100644 --- a/instrumentation/camel-2.20/javaagent-unit-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/CamelPropagationUtilTest.java +++ b/instrumentation/camel-2.20/javaagent-unit-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/CamelPropagationUtilTest.java @@ -26,17 +26,16 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -public class CamelPropagationUtilTest { +class CamelPropagationUtilTest { @BeforeAll - public static void setUp() { + static void setUp() { GlobalOpenTelemetry.set( OpenTelemetry.propagating(ContextPropagators.create(JaegerPropagator.getInstance()))); } @Test - public void shouldExtractHttpParentForHttpEndpoint() throws Exception { - + void shouldExtractHttpParentForHttpEndpoint() throws Exception { // given Endpoint endpoint = new HttpEndpoint("", new HttpComponent(), URI.create("")); Map exchangeHeaders = @@ -54,8 +53,7 @@ public void shouldExtractHttpParentForHttpEndpoint() throws Exception { } @Test - public void shouldNotFailExtractingNullHttpParentForHttpEndpoint() throws Exception { - + void shouldNotFailExtractingNullHttpParentForHttpEndpoint() throws Exception { // given Endpoint endpoint = new HttpEndpoint("", new HttpComponent(), URI.create("")); Map exchangeHeaders = Collections.singletonMap("uber-trace-id", null); @@ -70,8 +68,7 @@ public void shouldNotFailExtractingNullHttpParentForHttpEndpoint() throws Except } @Test - public void shouldNotFailExtractingNullAwsParentForSqsEndpoint() { - + void shouldNotFailExtractingNullAwsParentForSqsEndpoint() { // given Endpoint endpoint = new SqsEndpoint("", new SqsComponent(), new SqsConfiguration()); Map exchangeHeaders = Collections.singletonMap("AWSTraceHeader", null); @@ -86,8 +83,7 @@ public void shouldNotFailExtractingNullAwsParentForSqsEndpoint() { } @Test - public void shouldExtractAwsParentForSqsEndpoint() { - + void shouldExtractAwsParentForSqsEndpoint() { // given Endpoint endpoint = new SqsEndpoint("", new SqsComponent(), new SqsConfiguration()); Map exchangeHeaders = diff --git a/instrumentation/camel-2.20/javaagent-unit-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/SanitizationTest.java b/instrumentation/camel-2.20/javaagent-unit-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/SanitizationTest.java index a59f82f86897..ad0945c07542 100644 --- a/instrumentation/camel-2.20/javaagent-unit-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/SanitizationTest.java +++ b/instrumentation/camel-2.20/javaagent-unit-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/SanitizationTest.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.apachecamel.decorators; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -20,6 +20,18 @@ class SanitizationTest { + static class CqlArgs implements ArgumentsProvider { + @Override + public Stream provideArguments(ExtensionContext context) { + return Stream.of( + Arguments.of("FROM TABLE WHERE FIELD>=-1234", "FROM TABLE WHERE FIELD>=?"), + Arguments.of( + "SELECT Name, Phone.Number FROM Contact WHERE Address.State = 'NY'", + "SELECT Name, Phone.Number FROM Contact WHERE Address.State = ?"), + Arguments.of("FROM col WHERE @Tag='Something'", "FROM col WHERE @Tag=?")); + } + } + @ParameterizedTest @ArgumentsSource(CqlArgs.class) void sanitizeCql(String original, String expected) { @@ -31,7 +43,22 @@ void sanitizeCql(String original, String expected) { when(exchange.getIn()).thenReturn(message); String actualSanitized = decorator.getStatement(exchange, null); - assertEquals(expected, actualSanitized); + assertThat(actualSanitized).isEqualTo(expected); + } + + static class JdbcArgs implements ArgumentsProvider { + @Override + public Stream provideArguments(ExtensionContext context) { + return Stream.of( + Arguments.of("SELECT 3", "SELECT ?"), + Arguments.of( + "SELECT * FROM TABLE WHERE FIELD = 1234", "SELECT * FROM TABLE WHERE FIELD = ?"), + Arguments.of( + "SELECT * FROM TABLE WHERE FIELD<-1234", "SELECT * FROM TABLE WHERE FIELD provideArguments(ExtensionContext context) { } } - static class CqlArgs implements ArgumentsProvider { - @Override - public Stream provideArguments(ExtensionContext context) { - return Stream.of( - Arguments.of("FROM TABLE WHERE FIELD>=-1234", "FROM TABLE WHERE FIELD>=?"), - Arguments.of( - "SELECT Name, Phone.Number FROM Contact WHERE Address.State = 'NY'", - "SELECT Name, Phone.Number FROM Contact WHERE Address.State = ?"), - Arguments.of("FROM col WHERE @Tag='Something'", "FROM col WHERE @Tag=?")); - } - } + @ParameterizedTest + @ArgumentsSource(SqlArgs.class) + void sanitizeSql(String original, String expected) { - static class JdbcArgs implements ArgumentsProvider { - @Override - public Stream provideArguments(ExtensionContext context) { - return Stream.of( - Arguments.of("SELECT 3", "SELECT ?"), - Arguments.of( - "SELECT * FROM TABLE WHERE FIELD = 1234", "SELECT * FROM TABLE WHERE FIELD = ?"), - Arguments.of( - "SELECT * FROM TABLE WHERE FIELD<-1234", "SELECT * FROM TABLE WHERE FIELD loadDecorators() { result.put("direct-vm", new InternalSpanDecorator()); result.put("disruptor", new InternalSpanDecorator()); result.put("disruptor-vm", new InternalSpanDecorator()); - result.put("elasticsearch", new DbSpanDecorator("elasticsearch", "elasticsearch")); - result.put("opensearch", new DbSpanDecorator("opensearch", "opensearch")); + result.put( + "elasticsearch", + new DbSpanDecorator( + "elasticsearch", DbIncubatingAttributes.DbSystemIncubatingValues.ELASTICSEARCH)); + result.put( + "opensearch", + new DbSpanDecorator( + "opensearch", DbIncubatingAttributes.DbSystemIncubatingValues.OPENSEARCH)); result.put("http4", new Http4SpanDecorator()); result.put("https4", new Https4SpanDecorator()); result.put("http", new HttpSpanDecorator()); diff --git a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/DirectCamelTest.java b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/DirectCamelTest.java index 758a49963c65..6dd9ba6cc697 100644 --- a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/DirectCamelTest.java +++ b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/DirectCamelTest.java @@ -24,8 +24,7 @@ class DirectCamelTest extends AbstractHttpServerUsingTest { @RegisterExtension - public static final InstrumentationExtension testing = - HttpServerInstrumentationExtension.forAgent(); + static final InstrumentationExtension testing = HttpServerInstrumentationExtension.forAgent(); private ConfigurableApplicationContext appContext; diff --git a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/MulticastDirectCamelTest.java b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/MulticastDirectCamelTest.java index 4584a54eac4b..2b13af62e5f1 100644 --- a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/MulticastDirectCamelTest.java +++ b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/MulticastDirectCamelTest.java @@ -24,8 +24,7 @@ class MulticastDirectCamelTest extends AbstractHttpServerUsingTest { @RegisterExtension - public static final InstrumentationExtension testing = - HttpServerInstrumentationExtension.forAgent(); + static final InstrumentationExtension testing = HttpServerInstrumentationExtension.forAgent(); private ConfigurableApplicationContext appContext; diff --git a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/RestCamelTest.java b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/RestCamelTest.java index 1a0ef6fc31d5..b509ba572216 100644 --- a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/RestCamelTest.java +++ b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/RestCamelTest.java @@ -39,8 +39,7 @@ class RestCamelTest extends AbstractHttpServerUsingTest { @RegisterExtension - public static final InstrumentationExtension testing = - HttpServerInstrumentationExtension.forAgent(); + static final InstrumentationExtension testing = HttpServerInstrumentationExtension.forAgent(); private ConfigurableApplicationContext appContext; diff --git a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/SingleServiceCamelTest.java b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/SingleServiceCamelTest.java index abd90e0503d2..cfa154243afd 100644 --- a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/SingleServiceCamelTest.java +++ b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/SingleServiceCamelTest.java @@ -26,8 +26,7 @@ class SingleServiceCamelTest extends AbstractHttpServerUsingTest { @RegisterExtension - public static final InstrumentationExtension testing = - HttpServerInstrumentationExtension.forAgent(); + static final InstrumentationExtension testing = HttpServerInstrumentationExtension.forAgent(); @Override protected ConfigurableApplicationContext setupServer() { diff --git a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/TwoServicesWithDirectClientCamelTest.java b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/TwoServicesWithDirectClientCamelTest.java index 49ece74b10ad..7ae96fedab37 100644 --- a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/TwoServicesWithDirectClientCamelTest.java +++ b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/TwoServicesWithDirectClientCamelTest.java @@ -42,8 +42,7 @@ class TwoServicesWithDirectClientCamelTest extends AbstractHttpServerUsingTest { @RegisterExtension - public static final InstrumentationExtension testing = - HttpServerInstrumentationExtension.forAgent(); + static final InstrumentationExtension testing = HttpServerInstrumentationExtension.forAgent(); private static CamelContext clientContext; diff --git a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/AwsSpanAssertions.java b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/AwsSpanAssertions.java index 9fc24ce69dbc..ff375ca39ea7 100644 --- a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/AwsSpanAssertions.java +++ b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/AwsSpanAssertions.java @@ -24,13 +24,13 @@ 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.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.sdk.testing.assertj.AttributeAssertion; import io.opentelemetry.sdk.testing.assertj.SpanDataAssert; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; class AwsSpanAssertions { @@ -65,41 +65,41 @@ static SpanDataAssert sqs( throw new IllegalStateException("can't get rpc method from span name " + spanName); } - List attributeAssertions = new ArrayList<>(); - attributeAssertions.addAll( - Arrays.asList( - equalTo(stringKey("aws.agent"), "java-aws-sdk"), - satisfies( - stringKey("aws.queue.name"), - val -> - val.satisfiesAnyOf( - v -> assertThat(v).isEqualTo(queueName), v -> assertThat(v).isNull())), - satisfies( - stringKey("aws.queue.url"), - val -> - val.satisfiesAnyOf( - v -> assertThat(v).isEqualTo(queueUrl), v -> assertThat(v).isNull())), - satisfies(AWS_REQUEST_ID, val -> val.isInstanceOf(String.class)), - equalTo(HTTP_REQUEST_METHOD, "POST"), - equalTo(HTTP_RESPONSE_STATUS_CODE, 200), - satisfies(URL_FULL, val -> val.isInstanceOf(String.class)), - satisfies(SERVER_ADDRESS, stringAssert -> stringAssert.isInstanceOf(String.class)), - satisfies( - SERVER_PORT, - val -> - val.satisfiesAnyOf( - v -> assertThat(v).isNull(), - v -> assertThat(v).isInstanceOf(Number.class))), - equalTo(NETWORK_PROTOCOL_VERSION, "1.1"), - equalTo(RPC_SYSTEM, "aws-api"), - satisfies(RPC_METHOD, stringAssert -> stringAssert.isEqualTo(rpcMethod)), - equalTo(RPC_SERVICE, "AmazonSQS"))); + List attributeAssertions = + new ArrayList<>( + asList( + equalTo(stringKey("aws.agent"), "java-aws-sdk"), + satisfies( + stringKey("aws.queue.name"), + val -> + val.satisfiesAnyOf( + v -> assertThat(v).isEqualTo(queueName), v -> assertThat(v).isNull())), + satisfies( + stringKey("aws.queue.url"), + val -> + val.satisfiesAnyOf( + v -> assertThat(v).isEqualTo(queueUrl), v -> assertThat(v).isNull())), + satisfies(AWS_REQUEST_ID, val -> val.isInstanceOf(String.class)), + equalTo(HTTP_REQUEST_METHOD, "POST"), + equalTo(HTTP_RESPONSE_STATUS_CODE, 200), + satisfies(URL_FULL, val -> val.isInstanceOf(String.class)), + satisfies(SERVER_ADDRESS, stringAssert -> stringAssert.isInstanceOf(String.class)), + satisfies( + SERVER_PORT, + val -> + val.satisfiesAnyOf( + v -> assertThat(v).isNull(), + v -> assertThat(v).isInstanceOf(Number.class))), + equalTo(NETWORK_PROTOCOL_VERSION, "1.1"), + equalTo(RPC_SYSTEM, "aws-api"), + satisfies(RPC_METHOD, stringAssert -> stringAssert.isEqualTo(rpcMethod)), + equalTo(RPC_SERVICE, "AmazonSQS"))); if (spanName.endsWith("receive") || spanName.endsWith("process") || spanName.endsWith("publish")) { attributeAssertions.addAll( - Arrays.asList( + asList( equalTo(MESSAGING_DESTINATION_NAME, queueName), equalTo(MESSAGING_SYSTEM, AWS_SQS))); if (spanName.endsWith("receive")) { attributeAssertions.add(equalTo(MESSAGING_OPERATION, "receive")); diff --git a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/CamelSpanAssertions.java b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/CamelSpanAssertions.java index 93813f1aa10d..6c05dde80218 100644 --- a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/CamelSpanAssertions.java +++ b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/CamelSpanAssertions.java @@ -22,7 +22,7 @@ static void direct(SpanDataAssert span, String spanName) { span.hasName(spanName) .hasKind(SpanKind.INTERNAL) .hasNoParent() - .hasAttribute(stringKey("camel.uri"), "direct://" + spanName); + .hasAttributesSatisfyingExactly(equalTo(stringKey("camel.uri"), "direct://" + spanName)); } static SpanDataAssert sqsProduce(SpanDataAssert span, String queueName) { @@ -42,7 +42,7 @@ static SpanDataAssert sqsConsume(SpanDataAssert span, String queueName) { static SpanDataAssert sqsConsume(SpanDataAssert span, String queueName, int delay) { return span.hasName(queueName) .hasKind(SpanKind.INTERNAL) - .hasAttributesSatisfying( + .hasAttributesSatisfyingExactly( equalTo( stringKey("camel.uri"), "aws-sqs://" + queueName + "?amazonSQSClient=%23sqsClient&delay=" + delay), @@ -54,7 +54,7 @@ static SpanDataAssert sqsConsume(SpanDataAssert span, String queueName, int dela static SpanDataAssert snsPublish(SpanDataAssert span, String topicName) { return span.hasName(topicName) .hasKind(SpanKind.INTERNAL) - .hasAttributesSatisfying( + .hasAttributesSatisfyingExactly( equalTo( stringKey("camel.uri"), "aws-sns://" + topicName + "?amazonSNSClient=%23snsClient"), equalTo(MESSAGING_DESTINATION_NAME, topicName)); @@ -63,7 +63,7 @@ static SpanDataAssert snsPublish(SpanDataAssert span, String topicName) { static SpanDataAssert s3(SpanDataAssert span, String bucketName) { return span.hasName("aws-s3") .hasKind(SpanKind.INTERNAL) - .hasAttributesSatisfying( + .hasAttributesSatisfyingExactly( equalTo( stringKey("camel.uri"), "aws-s3://" + bucketName + "?amazonS3Client=%23s3Client")); } diff --git a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/S3CamelTest.java b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/S3CamelTest.java index e02b631b728c..b01c6fb922a5 100644 --- a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/S3CamelTest.java +++ b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/S3CamelTest.java @@ -22,7 +22,7 @@ class S3CamelTest { @RegisterExtension - public static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); + static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); private static final Logger logger = LoggerFactory.getLogger(S3CamelTest.class); @@ -37,7 +37,7 @@ protected static void setUp() { } @Test - public void camelS3ProducerToCamelSqsConsumer() { + void camelS3ProducerToCamelSqsConsumer() { String queueName = "s3SqsCamelTest"; String bucketName = "bucket-test-s3-sqs-camel"; diff --git a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/SnsCamelTest.java b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/SnsCamelTest.java index 21bc6dee94e1..d74d03011dea 100644 --- a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/SnsCamelTest.java +++ b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/SnsCamelTest.java @@ -21,7 +21,7 @@ class SnsCamelTest { @RegisterExtension - public static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); + static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); private static final Logger logger = LoggerFactory.getLogger(SnsCamelTest.class); diff --git a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/SqsCamelTest.java b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/SqsCamelTest.java index b47bcae7f807..d841ea525286 100644 --- a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/SqsCamelTest.java +++ b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/SqsCamelTest.java @@ -16,7 +16,7 @@ class SqsCamelTest { @RegisterExtension - public static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); + static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); private static final AwsConnector awsConnector = AwsConnector.elasticMq(); diff --git a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/CassandraTest.java b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/CassandraTest.java index af03e572f52c..69245ff669e5 100644 --- a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/CassandraTest.java +++ b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/CassandraTest.java @@ -34,8 +34,7 @@ class CassandraTest extends AbstractHttpServerUsingTest { @RegisterExtension - public static final InstrumentationExtension testing = - HttpServerInstrumentationExtension.forAgent(); + static final InstrumentationExtension testing = HttpServerInstrumentationExtension.forAgent(); private ConfigurableApplicationContext appContext;