diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/groovy/CassandraClientTest.groovy b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/groovy/CassandraClientTest.groovy index bf600bf048..5ce04d8112 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/groovy/CassandraClientTest.groovy +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/groovy/CassandraClientTest.groovy @@ -4,7 +4,6 @@ */ import static io.opentelemetry.api.trace.SpanKind.CLIENT -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import com.datastax.driver.core.Cluster import com.datastax.driver.core.Session @@ -111,7 +110,11 @@ class CassandraClientTest extends AgentInstrumentationSpecification { hasNoParent() } cassandraSpan(it, 1, spanName, expectedStatement, operation, keyspace, table, span(0)) - basicSpan(it, 2, "callbackListener", span(0)) + span(2) { + name "callbackListener" + kind SpanKind.INTERNAL + childOf span(0) + } } } diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/test/groovy/CassandraClientTest.groovy b/instrumentation/cassandra/cassandra-4.0/javaagent/src/test/groovy/CassandraClientTest.groovy index b0bedd6c16..e4df1e197c 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/test/groovy/CassandraClientTest.groovy +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/test/groovy/CassandraClientTest.groovy @@ -4,7 +4,6 @@ */ import static io.opentelemetry.api.trace.SpanKind.CLIENT -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import com.datastax.oss.driver.api.core.CqlSession import com.datastax.oss.driver.api.core.config.DefaultDriverOption @@ -88,7 +87,11 @@ class CassandraClientTest extends AgentInstrumentationSpecification { hasNoParent() } cassandraSpan(it, 1, spanName, expectedStatement, operation, keyspace, table, span(0)) - basicSpan(it, 2, "child", span(0)) + span(2) { + name "child" + kind SpanKind.INTERNAL + childOf span(0) + } } } diff --git a/instrumentation/executors/javaagent/src/test/groovy/CompletableFutureTest.groovy b/instrumentation/executors/javaagent/src/test/groovy/CompletableFutureTest.groovy index 46266254b5..149392ac34 100644 --- a/instrumentation/executors/javaagent/src/test/groovy/CompletableFutureTest.groovy +++ b/instrumentation/executors/javaagent/src/test/groovy/CompletableFutureTest.groovy @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import static io.opentelemetry.instrumentation.test.utils.TraceUtils.runInternalSpan import io.opentelemetry.api.trace.SpanKind @@ -62,9 +61,21 @@ class CompletableFutureTest extends AgentInstrumentationSpecification { kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "supplier", span(0)) - basicSpan(it, 2, "appendingSupplier", span(0)) - basicSpan(it, 3, "function", span(0)) + span(1) { + name "supplier" + kind SpanKind.INTERNAL + childOf span(0) + } + span(2) { + name "appendingSupplier" + kind SpanKind.INTERNAL + childOf span(0) + } + span(3) { + name "function" + kind SpanKind.INTERNAL + childOf span(0) + } } } @@ -95,7 +106,11 @@ class CompletableFutureTest extends AgentInstrumentationSpecification { kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "child", span(0)) + span(1) { + name "child" + kind SpanKind.INTERNAL + childOf span(0) + } } } } @@ -123,7 +138,11 @@ class CompletableFutureTest extends AgentInstrumentationSpecification { kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "child", span(0)) + span(1) { + name "child" + kind SpanKind.INTERNAL + childOf span(0) + } } } } @@ -152,7 +171,11 @@ class CompletableFutureTest extends AgentInstrumentationSpecification { kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "child", span(0)) + span(1) { + name "child" + kind SpanKind.INTERNAL + childOf span(0) + } } } } @@ -183,7 +206,11 @@ class CompletableFutureTest extends AgentInstrumentationSpecification { kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "child", span(0)) + span(1) { + name "child" + kind SpanKind.INTERNAL + childOf span(0) + } } } } @@ -214,7 +241,11 @@ class CompletableFutureTest extends AgentInstrumentationSpecification { kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "child", span(0)) + span(1) { + name "child" + kind SpanKind.INTERNAL + childOf span(0) + } } } } @@ -247,7 +278,11 @@ class CompletableFutureTest extends AgentInstrumentationSpecification { kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "child", span(0)) + span(1) { + name "child" + kind SpanKind.INTERNAL + childOf span(0) + } } } } diff --git a/instrumentation/executors/javaagent/src/test/groovy/ExecutorInstrumentationTest.groovy b/instrumentation/executors/javaagent/src/test/groovy/ExecutorInstrumentationTest.groovy index 33d12e72a6..7425d7d7b0 100644 --- a/instrumentation/executors/javaagent/src/test/groovy/ExecutorInstrumentationTest.groovy +++ b/instrumentation/executors/javaagent/src/test/groovy/ExecutorInstrumentationTest.groovy @@ -3,8 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan - import io.opentelemetry.api.trace.SpanKind import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification import java.lang.reflect.InvocationTargetException @@ -81,7 +79,11 @@ class ExecutorInstrumentationTest extends AgentInstrumentationSpecification { kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "asyncChild", span(0)) + span(1) { + name "asyncChild" + kind SpanKind.INTERNAL + childOf span(0) + } } } @@ -166,7 +168,11 @@ class ExecutorInstrumentationTest extends AgentInstrumentationSpecification { kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "asyncChild", span(0)) + span(1) { + name "asyncChild" + kind SpanKind.INTERNAL + childOf span(0) + } } } diff --git a/instrumentation/gwt-2.0/javaagent/src/testapp/webapp/WEB-INF/web.xml b/instrumentation/gwt-2.0/javaagent/src/testapp/webapp/WEB-INF/web.xml index 215442e2bb..acc5f32cea 100644 --- a/instrumentation/gwt-2.0/javaagent/src/testapp/webapp/WEB-INF/web.xml +++ b/instrumentation/gwt-2.0/javaagent/src/testapp/webapp/WEB-INF/web.xml @@ -1,6 +1,6 @@ diff --git a/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-cxf-3.2/javaagent/src/test/groovy/CxfHttpServerTest.groovy b/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-cxf-3.2/javaagent/src/test/groovy/CxfHttpServerTest.groovy index f9a88cc33f..ac12a9a901 100644 --- a/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-cxf-3.2/javaagent/src/test/groovy/CxfHttpServerTest.groovy +++ b/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-cxf-3.2/javaagent/src/test/groovy/CxfHttpServerTest.groovy @@ -6,8 +6,8 @@ import javax.ws.rs.core.MediaType import javax.ws.rs.core.Response import javax.ws.rs.ext.ExceptionMapper -import org.apache.cxf.jaxrs.JAXRSServerFactoryBean import org.apache.cxf.endpoint.Server +import org.apache.cxf.jaxrs.JAXRSServerFactoryBean import test.JaxRsTestApplication class CxfHttpServerTest extends JaxRsHttpServerTest { diff --git a/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-testing/src/main/groovy/JaxRsHttpServerTest.groovy b/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-testing/src/main/groovy/JaxRsHttpServerTest.groovy index daa32f29fd..5e79992017 100644 --- a/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-testing/src/main/groovy/JaxRsHttpServerTest.groovy +++ b/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-testing/src/main/groovy/JaxRsHttpServerTest.groovy @@ -9,7 +9,6 @@ import static io.opentelemetry.api.trace.StatusCode.ERROR import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import static java.util.concurrent.TimeUnit.SECONDS import static org.junit.Assume.assumeTrue @@ -38,7 +37,11 @@ abstract class JaxRsHttpServerTest extends HttpServerTest implements Agent kind SERVER name getContextPath() + "/test-resource-super" } - basicSpan(it, 1, "controller", span(0)) + span(1) { + name "controller" + kind INTERNAL + childOf span(0) + } } } } @@ -60,7 +63,11 @@ abstract class JaxRsHttpServerTest extends HttpServerTest implements Agent kind SERVER name getContextPath() + "/test-resource-interface/call" } - basicSpan(it, 1, "controller", span(0)) + span(1) { + name "controller" + kind INTERNAL + childOf span(0) + } } } } @@ -80,10 +87,26 @@ abstract class JaxRsHttpServerTest extends HttpServerTest implements Agent kind SERVER name getContextPath() + "/test-sub-resource-locator/call/sub" } - basicSpan(it, 1,"JaxRsSubResourceLocatorTestResource.call", span(0)) - basicSpan(it, 2, "controller", span(1)) - basicSpan(it, 3, "SubResource.call", span(0)) - basicSpan(it, 4, "controller", span(3)) + span(1) { + name "JaxRsSubResourceLocatorTestResource.call" + kind INTERNAL + childOf span(0) + } + span(2) { + name "controller" + kind INTERNAL + childOf span(1) + } + span(3) { + name "SubResource.call" + kind INTERNAL + childOf span(0) + } + span(4) { + name "controller" + kind INTERNAL + childOf span(3) + } } } } diff --git a/instrumentation/jaxws/jaxws-2.0-testing/src/main/schema/hello.xsd b/instrumentation/jaxws/jaxws-2.0-testing/src/main/schema/hello.xsd index 7246921293..061dfaa850 100644 --- a/instrumentation/jaxws/jaxws-2.0-testing/src/main/schema/hello.xsd +++ b/instrumentation/jaxws/jaxws-2.0-testing/src/main/schema/hello.xsd @@ -1,4 +1,4 @@ - diff --git a/instrumentation/jdbc/javaagent/src/test/groovy/JdbcInstrumentationTest.groovy b/instrumentation/jdbc/javaagent/src/test/groovy/JdbcInstrumentationTest.groovy index 99cdf073cf..cee0b062e1 100644 --- a/instrumentation/jdbc/javaagent/src/test/groovy/JdbcInstrumentationTest.groovy +++ b/instrumentation/jdbc/javaagent/src/test/groovy/JdbcInstrumentationTest.groovy @@ -6,7 +6,6 @@ import static io.opentelemetry.api.trace.SpanKind.CLIENT import static io.opentelemetry.api.trace.SpanKind.INTERNAL - import com.mchange.v2.c3p0.ComboPooledDataSource import com.zaxxer.hikari.HikariConfig import com.zaxxer.hikari.HikariDataSource diff --git a/instrumentation/jdbc/library/src/test/groovy/io/opentelemetry/instrumentation/jdbc/datasource/TestDataSource.groovy b/instrumentation/jdbc/library/src/test/groovy/io/opentelemetry/instrumentation/jdbc/datasource/TestDataSource.groovy index 78e2d6366f..77c1bfd3e6 100644 --- a/instrumentation/jdbc/library/src/test/groovy/io/opentelemetry/instrumentation/jdbc/datasource/TestDataSource.groovy +++ b/instrumentation/jdbc/library/src/test/groovy/io/opentelemetry/instrumentation/jdbc/datasource/TestDataSource.groovy @@ -6,12 +6,11 @@ package io.opentelemetry.instrumentation.jdbc.datasource import io.opentelemetry.instrumentation.jdbc.TestConnection - -import javax.sql.DataSource import java.sql.Connection import java.sql.SQLException import java.sql.SQLFeatureNotSupportedException import java.util.logging.Logger +import javax.sql.DataSource class TestDataSource implements DataSource { diff --git a/instrumentation/jdbc/testing/src/main/groovy/io/opentelemetry/instrumentation/jdbc/AnotherTestDriver.groovy b/instrumentation/jdbc/testing/src/main/groovy/io/opentelemetry/instrumentation/jdbc/AnotherTestDriver.groovy index 3590fc801e..0658c9bd31 100644 --- a/instrumentation/jdbc/testing/src/main/groovy/io/opentelemetry/instrumentation/jdbc/AnotherTestDriver.groovy +++ b/instrumentation/jdbc/testing/src/main/groovy/io/opentelemetry/instrumentation/jdbc/AnotherTestDriver.groovy @@ -5,7 +5,12 @@ package io.opentelemetry.instrumentation.jdbc -import java.sql.* + +import java.sql.Connection +import java.sql.Driver +import java.sql.DriverPropertyInfo +import java.sql.SQLException +import java.sql.SQLFeatureNotSupportedException import java.util.logging.Logger class AnotherTestDriver implements Driver { diff --git a/instrumentation/jdbc/testing/src/main/groovy/io/opentelemetry/instrumentation/jdbc/TestCallableStatement.groovy b/instrumentation/jdbc/testing/src/main/groovy/io/opentelemetry/instrumentation/jdbc/TestCallableStatement.groovy index b7980fee69..a39a259fc5 100644 --- a/instrumentation/jdbc/testing/src/main/groovy/io/opentelemetry/instrumentation/jdbc/TestCallableStatement.groovy +++ b/instrumentation/jdbc/testing/src/main/groovy/io/opentelemetry/instrumentation/jdbc/TestCallableStatement.groovy @@ -5,7 +5,19 @@ package io.opentelemetry.instrumentation.jdbc -import java.sql.* + +import java.sql.Array +import java.sql.Blob +import java.sql.CallableStatement +import java.sql.Clob +import java.sql.Date +import java.sql.NClob +import java.sql.Ref +import java.sql.RowId +import java.sql.SQLException +import java.sql.SQLXML +import java.sql.Time +import java.sql.Timestamp class TestCallableStatement extends TestPreparedStatement implements CallableStatement { @Override diff --git a/instrumentation/jdbc/testing/src/main/groovy/io/opentelemetry/instrumentation/jdbc/TestDriver.groovy b/instrumentation/jdbc/testing/src/main/groovy/io/opentelemetry/instrumentation/jdbc/TestDriver.groovy index db93d28ed8..033cf445a6 100644 --- a/instrumentation/jdbc/testing/src/main/groovy/io/opentelemetry/instrumentation/jdbc/TestDriver.groovy +++ b/instrumentation/jdbc/testing/src/main/groovy/io/opentelemetry/instrumentation/jdbc/TestDriver.groovy @@ -5,7 +5,12 @@ package io.opentelemetry.instrumentation.jdbc -import java.sql.* + +import java.sql.Connection +import java.sql.Driver +import java.sql.DriverPropertyInfo +import java.sql.SQLException +import java.sql.SQLFeatureNotSupportedException import java.util.logging.Logger class TestDriver implements Driver { diff --git a/instrumentation/jetty/jetty-8.0/javaagent/src/test/groovy/QueuedThreadPoolTest.groovy b/instrumentation/jetty/jetty-8.0/javaagent/src/test/groovy/QueuedThreadPoolTest.groovy index 58b42a670b..b9fdf26a7f 100644 --- a/instrumentation/jetty/jetty-8.0/javaagent/src/test/groovy/QueuedThreadPoolTest.groovy +++ b/instrumentation/jetty/jetty-8.0/javaagent/src/test/groovy/QueuedThreadPoolTest.groovy @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import static org.junit.Assume.assumeTrue import io.opentelemetry.api.trace.SpanKind @@ -45,7 +44,11 @@ class QueuedThreadPoolTest extends AgentInstrumentationSpecification { kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "asyncChild", span(0)) + span(1) { + name "asyncChild" + kind SpanKind.INTERNAL + childOf span(0) + } } } @@ -82,7 +85,11 @@ class QueuedThreadPoolTest extends AgentInstrumentationSpecification { kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "asyncChild", span(0)) + span(1) { + name "asyncChild" + kind SpanKind.INTERNAL + childOf span(0) + } } } diff --git a/instrumentation/jsf/jsf-testing-common/src/main/groovy/BaseJsfTest.groovy b/instrumentation/jsf/jsf-testing-common/src/main/groovy/BaseJsfTest.groovy index 18c6a5ecbf..a2c386b9fc 100644 --- a/instrumentation/jsf/jsf-testing-common/src/main/groovy/BaseJsfTest.groovy +++ b/instrumentation/jsf/jsf-testing-common/src/main/groovy/BaseJsfTest.groovy @@ -5,8 +5,8 @@ import static io.opentelemetry.api.trace.SpanKind.INTERNAL import static io.opentelemetry.api.trace.StatusCode.ERROR -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicServerSpan +import io.opentelemetry.api.trace.SpanKind import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification import io.opentelemetry.instrumentation.test.asserts.TraceAssert import io.opentelemetry.instrumentation.test.base.HttpServerTestTrait @@ -83,7 +83,11 @@ abstract class BaseJsfTest extends AgentInstrumentationSpecification implements and: assertTraces(1) { trace(0, 1) { - basicServerSpan(it, 0, getContextPath() + "/hello.xhtml", null) + span(0) { + name getContextPath() + "/hello.xhtml" + kind SpanKind.SERVER + hasNoParent() + } } } @@ -104,7 +108,11 @@ abstract class BaseJsfTest extends AgentInstrumentationSpecification implements and: assertTraces(1) { trace(0, 1) { - basicServerSpan(it, 0, getContextPath() + "/greeting.xhtml", null) + span(0) { + name getContextPath() + "/greeting.xhtml" + kind SpanKind.SERVER + hasNoParent() + } } } clearExportedData() @@ -146,7 +154,11 @@ abstract class BaseJsfTest extends AgentInstrumentationSpecification implements and: assertTraces(1) { trace(0, 2) { - basicServerSpan(it, 0, getContextPath() + "/greeting.xhtml", null) + span(0) { + name getContextPath() + "/greeting.xhtml" + kind SpanKind.SERVER + hasNoParent() + } handlerSpan(it, 1, span(0), "#{greetingForm.submit()}") } } @@ -165,7 +177,11 @@ abstract class BaseJsfTest extends AgentInstrumentationSpecification implements and: assertTraces(1) { trace(0, 1) { - basicServerSpan(it, 0, getContextPath() + "/greeting.xhtml", null) + span(0) { + name getContextPath() + "/greeting.xhtml" + kind SpanKind.SERVER + hasNoParent() + } } } clearExportedData() @@ -200,12 +216,19 @@ abstract class BaseJsfTest extends AgentInstrumentationSpecification implements then: response2.status().code() == 500 + def ex = new Exception("submit exception") and: assertTraces(1) { trace(0, 2) { - basicServerSpan(it, 0, getContextPath() + "/greeting.xhtml", null, new Exception("submit exception")) - handlerSpan(it, 1, span(0), "#{greetingForm.submit()}", new Exception("submit exception")) + span(0) { + name getContextPath() + "/greeting.xhtml" + kind SpanKind.SERVER + hasNoParent() + status ERROR + errorEvent(ex.class, ex.message) + } + handlerSpan(it, 1, span(0), "#{greetingForm.submit()}", ex) } } } diff --git a/instrumentation/kafka-clients-0.11/javaagent/src/test/groovy/KafkaClientPropagationEnabledTest.groovy b/instrumentation/kafka-clients-0.11/javaagent/src/test/groovy/KafkaClientPropagationEnabledTest.groovy index 3df361b675..d6daff31bd 100644 --- a/instrumentation/kafka-clients-0.11/javaagent/src/test/groovy/KafkaClientPropagationEnabledTest.groovy +++ b/instrumentation/kafka-clients-0.11/javaagent/src/test/groovy/KafkaClientPropagationEnabledTest.groovy @@ -5,7 +5,6 @@ import static io.opentelemetry.api.trace.SpanKind.CONSUMER import static io.opentelemetry.api.trace.SpanKind.PRODUCER -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import io.opentelemetry.api.trace.SpanKind import io.opentelemetry.semconv.trace.attributes.SemanticAttributes @@ -114,7 +113,11 @@ class KafkaClientPropagationEnabledTest extends KafkaClientBaseTest { "kafka.record.queue_time_ms" { it >= 0 } } } - basicSpan(it, 3, "producer callback", span(0)) + span(3) { + name "producer callback" + kind SpanKind.INTERNAL + childOf span(0) + } } } @@ -206,7 +209,11 @@ class KafkaClientPropagationEnabledTest extends KafkaClientBaseTest { "kafka.record.queue_time_ms" { it >= 0 } } } - basicSpan(it, 3, "producer callback", span(0)) + span(3) { + name "producer callback" + kind SpanKind.INTERNAL + childOf span(0) + } } } diff --git a/instrumentation/kubernetes-client-7.0/javaagent/src/test/groovy/KubernetesClientTest.groovy b/instrumentation/kubernetes-client-7.0/javaagent/src/test/groovy/KubernetesClientTest.groovy index 18235c6325..781c111c71 100644 --- a/instrumentation/kubernetes-client-7.0/javaagent/src/test/groovy/KubernetesClientTest.groovy +++ b/instrumentation/kubernetes-client-7.0/javaagent/src/test/groovy/KubernetesClientTest.groovy @@ -5,7 +5,6 @@ import static io.opentelemetry.api.trace.SpanKind.CLIENT import static io.opentelemetry.api.trace.StatusCode.ERROR -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import static io.opentelemetry.instrumentation.test.utils.TraceUtils.runInternalSpan import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP @@ -90,7 +89,13 @@ class KubernetesClientTest extends AgentInstrumentationSpecification { assertTraces(1) { trace(0, 2) { - basicSpan(it, 0, "parent", null, exception) + span(0) { + name "parent" + kind SpanKind.INTERNAL + hasNoParent() + status ERROR + errorEvent(exception.class, exception.message) + } apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 451, exception) } } @@ -128,7 +133,11 @@ class KubernetesClientTest extends AgentInstrumentationSpecification { hasNoParent() } apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 200) - basicSpan(it, 2, "callback", span(0)) + span(2) { + name "callback" + kind SpanKind.INTERNAL + childOf span(0) + } } } } @@ -165,7 +174,11 @@ class KubernetesClientTest extends AgentInstrumentationSpecification { hasNoParent() } apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 451, exception.get()) - basicSpan(it, 2, "callback", span(0)) + span(2) { + name "callback" + kind SpanKind.INTERNAL + childOf span(0) + } } } } diff --git a/instrumentation/mongo/mongo-testing/src/main/groovy/io/opentelemetry/instrumentation/mongo/testing/AbstractMongoClientTest.groovy b/instrumentation/mongo/mongo-testing/src/main/groovy/io/opentelemetry/instrumentation/mongo/testing/AbstractMongoClientTest.groovy index e1bedccb58..918de9ba2f 100644 --- a/instrumentation/mongo/mongo-testing/src/main/groovy/io/opentelemetry/instrumentation/mongo/testing/AbstractMongoClientTest.groovy +++ b/instrumentation/mongo/mongo-testing/src/main/groovy/io/opentelemetry/instrumentation/mongo/testing/AbstractMongoClientTest.groovy @@ -7,7 +7,6 @@ package io.opentelemetry.instrumentation.mongo.testing import static io.opentelemetry.api.trace.SpanKind.CLIENT - import io.opentelemetry.api.trace.SpanKind import io.opentelemetry.instrumentation.test.InstrumentationSpecification import io.opentelemetry.instrumentation.test.asserts.TraceAssert diff --git a/instrumentation/ratpack-1.4/javaagent/src/test/groovy/server/RatpackForkedHttpServerTest.groovy b/instrumentation/ratpack-1.4/javaagent/src/test/groovy/server/RatpackForkedHttpServerTest.groovy index 4eb688cf8c..86fd1d2588 100644 --- a/instrumentation/ratpack-1.4/javaagent/src/test/groovy/server/RatpackForkedHttpServerTest.groovy +++ b/instrumentation/ratpack-1.4/javaagent/src/test/groovy/server/RatpackForkedHttpServerTest.groovy @@ -12,9 +12,8 @@ import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEn import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicServerSpan -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan +import io.opentelemetry.api.trace.SpanKind import io.opentelemetry.testing.internal.armeria.common.AggregatedHttpRequest import io.opentelemetry.testing.internal.armeria.common.AggregatedHttpResponse import io.opentelemetry.testing.internal.armeria.common.HttpMethod @@ -154,9 +153,21 @@ class RatpackForkedHttpServerTest extends RatpackHttpServerTest { assertTraces(1) { trace(0, 3) { - basicServerSpan(it, 0, "/fork_and_yieldAll") - basicSpan(it, 1, "/fork_and_yieldAll", span(0)) - basicSpan(it, 2, "controller", span(1)) + span(0) { + name "/fork_and_yieldAll" + kind SpanKind.SERVER + hasNoParent() + } + span(1) { + name "/fork_and_yieldAll" + kind SpanKind.INTERNAL + childOf span(0) + } + span(2) { + name "controller" + kind SpanKind.INTERNAL + childOf span(1) + } } } } diff --git a/instrumentation/reactor-3.1/testing/src/main/groovy/io/opentelemetry/instrumentation/reactor/AbstractReactorCoreTest.groovy b/instrumentation/reactor-3.1/testing/src/main/groovy/io/opentelemetry/instrumentation/reactor/AbstractReactorCoreTest.groovy index 461ac1420a..66d1451102 100644 --- a/instrumentation/reactor-3.1/testing/src/main/groovy/io/opentelemetry/instrumentation/reactor/AbstractReactorCoreTest.groovy +++ b/instrumentation/reactor-3.1/testing/src/main/groovy/io/opentelemetry/instrumentation/reactor/AbstractReactorCoreTest.groovy @@ -6,7 +6,6 @@ package io.opentelemetry.instrumentation.reactor import static io.opentelemetry.api.trace.StatusCode.ERROR -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import static io.opentelemetry.instrumentation.test.utils.TraceUtils.runInternalSpan import io.opentelemetry.api.GlobalOpenTelemetry @@ -58,10 +57,18 @@ abstract class AbstractReactorCoreTest extends InstrumentationSpecification { kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "publisher-parent", span(0)) + span(1) { + name "publisher-parent" + kind SpanKind.INTERNAL + childOf span(0) + } for (int i = 0; i < workSpans; i++) { - basicSpan(it, 2 + i, "add one", span(1)) + span(2 + i) { + name "add one" + kind SpanKind.INTERNAL + childOf span(1) + } } } } @@ -113,7 +120,11 @@ abstract class AbstractReactorCoreTest extends InstrumentationSpecification { // impact the spans on reactor instrumentations such as netty and lettuce, as reactor is // more of a context propagation mechanism than something we would be tracking for // errors this is ok. - basicSpan(it, 1, "publisher-parent", span(0)) + span(1) { + name "publisher-parent" + kind SpanKind.INTERNAL + childOf span(0) + } } } @@ -144,7 +155,11 @@ abstract class AbstractReactorCoreTest extends InstrumentationSpecification { // impact the spans on reactor instrumentations such as netty and lettuce, as reactor is // more of a context propagation mechanism than something we would be tracking for // errors this is ok. - basicSpan(it, 1, "publisher-parent", span(0)) + span(1) { + name "publisher-parent" + kind SpanKind.INTERNAL + childOf span(0) + } for (int i = 0; i < workSpans; i++) { span(i + 2) { @@ -179,7 +194,11 @@ abstract class AbstractReactorCoreTest extends InstrumentationSpecification { } } - basicSpan(it, 1, "publisher-parent", span(0)) + span(1) { + name "publisher-parent" + kind SpanKind.INTERNAL + childOf span(0) + } } } @@ -203,7 +222,11 @@ abstract class AbstractReactorCoreTest extends InstrumentationSpecification { } } - basicSpan(it, 1, "publisher-parent", span(0)) + span(1) { + name "publisher-parent" + kind SpanKind.INTERNAL + childOf span(0) + } for (int i = 0; i < workSpans; i++) { span(i + 2) { @@ -257,12 +280,28 @@ abstract class AbstractReactorCoreTest extends InstrumentationSpecification { kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "publisher-parent", span(0)) - basicSpan(it, 2, "intermediate", span(1)) + span(1) { + name "publisher-parent" + kind SpanKind.INTERNAL + childOf span(0) + } + span(2) { + name "intermediate" + kind SpanKind.INTERNAL + childOf span(1) + } for (int i = 0; i < 2 * workItems; i = i + 2) { - basicSpan(it, 3 + i, "add one", span(1)) - basicSpan(it, 3 + i + 1, "add two", span(1)) + span(3 + i) { + name "add one" + kind SpanKind.INTERNAL + childOf span(1) + } + span(3 + i + 1) { + name "add two" + kind SpanKind.INTERNAL + childOf span(1) + } } } } diff --git a/instrumentation/reactor-3.1/testing/src/main/groovy/io/opentelemetry/instrumentation/reactor/AbstractSubscriptionTest.groovy b/instrumentation/reactor-3.1/testing/src/main/groovy/io/opentelemetry/instrumentation/reactor/AbstractSubscriptionTest.groovy index 60e3ef0439..32b2243958 100644 --- a/instrumentation/reactor-3.1/testing/src/main/groovy/io/opentelemetry/instrumentation/reactor/AbstractSubscriptionTest.groovy +++ b/instrumentation/reactor-3.1/testing/src/main/groovy/io/opentelemetry/instrumentation/reactor/AbstractSubscriptionTest.groovy @@ -5,7 +5,6 @@ package io.opentelemetry.instrumentation.reactor -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import io.opentelemetry.api.GlobalOpenTelemetry import io.opentelemetry.api.trace.SpanKind @@ -37,7 +36,11 @@ abstract class AbstractSubscriptionTest extends InstrumentationSpecification { kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "Connection.query", span(0)) + span(1) { + name "Connection.query" + kind SpanKind.INTERNAL + childOf span(0) + } } } diff --git a/instrumentation/reactor-netty/reactor-netty-0.9/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/reactornetty/v0_9/AbstractReactorNettyHttpClientTest.groovy b/instrumentation/reactor-netty/reactor-netty-0.9/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/reactornetty/v0_9/AbstractReactorNettyHttpClientTest.groovy index f26579f5ea..a569adb54c 100644 --- a/instrumentation/reactor-netty/reactor-netty-0.9/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/reactornetty/v0_9/AbstractReactorNettyHttpClientTest.groovy +++ b/instrumentation/reactor-netty/reactor-netty-0.9/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/reactornetty/v0_9/AbstractReactorNettyHttpClientTest.groovy @@ -6,7 +6,6 @@ package io.opentelemetry.javaagent.instrumentation.reactornetty.v0_9 import static io.opentelemetry.instrumentation.test.utils.PortUtils.UNUSABLE_PORT -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import io.opentelemetry.api.common.AttributeKey import io.opentelemetry.api.trace.Span @@ -170,7 +169,13 @@ abstract class AbstractReactorNettyHttpClientTest extends HttpClientTest diff --git a/instrumentation/struts-2.3/javaagent/src/test/groovy/Struts2ActionSpanTest.groovy b/instrumentation/struts-2.3/javaagent/src/test/groovy/Struts2ActionSpanTest.groovy index 7e1afa5f10..84632736a7 100644 --- a/instrumentation/struts-2.3/javaagent/src/test/groovy/Struts2ActionSpanTest.groovy +++ b/instrumentation/struts-2.3/javaagent/src/test/groovy/Struts2ActionSpanTest.groovy @@ -9,9 +9,8 @@ import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEn import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicServerSpan -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan +import io.opentelemetry.api.trace.SpanKind import io.opentelemetry.api.trace.StatusCode import io.opentelemetry.instrumentation.test.AgentTestTrait import io.opentelemetry.instrumentation.test.asserts.TraceAssert @@ -133,8 +132,16 @@ class Struts2ActionSpanTest extends HttpServerTest implements AgentTestT and: assertTraces(1) { trace(0, 2) { - basicServerSpan(it, 0, getContextPath() + "/dispatch", null) - basicSpan(it, 1, "GreetingAction.dispatch_servlet", span(0)) + span(0) { + name getContextPath() + "/dispatch" + kind SpanKind.SERVER + hasNoParent() + } + span(1) { + name "GreetingAction.dispatch_servlet" + kind INTERNAL + childOf span(0) + } } } } diff --git a/instrumentation/tapestry-5.4/javaagent/src/test/groovy/TapestryTest.groovy b/instrumentation/tapestry-5.4/javaagent/src/test/groovy/TapestryTest.groovy index 734670c6b3..ef03981458 100644 --- a/instrumentation/tapestry-5.4/javaagent/src/test/groovy/TapestryTest.groovy +++ b/instrumentation/tapestry-5.4/javaagent/src/test/groovy/TapestryTest.groovy @@ -4,7 +4,6 @@ */ import static io.opentelemetry.api.trace.StatusCode.ERROR -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import io.opentelemetry.api.trace.SpanKind import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification @@ -94,7 +93,11 @@ class TapestryTest extends AgentInstrumentationSpecification implements HttpServ assertTraces(1) { trace(0, 2) { serverSpan(it, 0, getContextPath() + "/Index") - basicSpan(it, 1, "activate/Index", span(0)) + span(1) { + name "activate/Index" + kind SpanKind.INTERNAL + childOf span(0) + } } } } @@ -112,13 +115,29 @@ class TapestryTest extends AgentInstrumentationSpecification implements HttpServ assertTraces(2) { trace(0, 4) { serverSpan(it, 0, getContextPath() + "/Index") - basicSpan(it, 1, "activate/Index", span(0)) - basicSpan(it, 2, "action/Index:start", span(0)) - basicSpan(it, 3, "Response.sendRedirect", span(2)) + span(1) { + name "activate/Index" + kind SpanKind.INTERNAL + childOf span(0) + } + span(2) { + name "action/Index:start" + kind SpanKind.INTERNAL + childOf span(0) + } + span(3) { + name "Response.sendRedirect" + kind SpanKind.INTERNAL + childOf span(2) + } } trace(1, 2) { serverSpan(it, 0, getContextPath() + "/Other") - basicSpan(it, 1, "activate/Other", span(0)) + span(1) { + name "activate/Other" + kind SpanKind.INTERNAL + childOf span(0) + } } } } @@ -130,6 +149,7 @@ class TapestryTest extends AgentInstrumentationSpecification implements HttpServ expect: response.status().code() == 500 + def ex = new IllegalStateException("expected") assertTraces(1) { trace(0, 3) { @@ -139,8 +159,18 @@ class TapestryTest extends AgentInstrumentationSpecification implements HttpServ name getContextPath() + "/Index" status ERROR } - basicSpan(it, 1, "activate/Index", span(0)) - basicSpan(it, 2, "action/Index:exception", span(0), new IllegalStateException("expected")) + span(1) { + name "activate/Index" + kind SpanKind.INTERNAL + childOf span(0) + } + span(2) { + name "action/Index:exception" + kind SpanKind.INTERNAL + childOf span(0) + status ERROR + errorEvent(ex.class, ex.message) + } } } } diff --git a/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy b/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy index 6aecbe62b9..a8c3c89d2e 100644 --- a/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy +++ b/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy @@ -8,7 +8,6 @@ import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEn import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import io.opentelemetry.api.trace.Span import io.opentelemetry.api.trace.SpanKind @@ -128,7 +127,11 @@ class UndertowServerTest extends HttpServerTest implements AgentTestTr "${SemanticAttributes.HTTP_USER_AGENT.key}" TEST_USER_AGENT } } - basicSpan(it, 1, "sendResponse", span(0)) + span(1) { + name "sendResponse" + kind SpanKind.INTERNAL + childOf span(0) + } } } } @@ -170,7 +173,11 @@ class UndertowServerTest extends HttpServerTest implements AgentTestTr "${SemanticAttributes.HTTP_USER_AGENT.key}" TEST_USER_AGENT } } - basicSpan(it, 1, "sendResponseWithException", span(0)) + span(1) { + name "sendResponseWithException" + kind SpanKind.INTERNAL + childOf span(0) + } } } } diff --git a/instrumentation/vaadin-14.2/testing/src/main/groovy/test/vaadin/AbstractVaadin14Test.groovy b/instrumentation/vaadin-14.2/testing/src/main/groovy/test/vaadin/AbstractVaadin14Test.groovy index ad2c27e9a5..bc31082d59 100644 --- a/instrumentation/vaadin-14.2/testing/src/main/groovy/test/vaadin/AbstractVaadin14Test.groovy +++ b/instrumentation/vaadin-14.2/testing/src/main/groovy/test/vaadin/AbstractVaadin14Test.groovy @@ -5,9 +5,9 @@ package test.vaadin -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import com.vaadin.flow.server.Version +import io.opentelemetry.api.trace.SpanKind abstract class AbstractVaadin14Test extends AbstractVaadinTest { static final boolean VAADIN_14_4 = Version.majorVersion >= 2 && Version.minorVersion >= 4 @@ -33,11 +33,19 @@ abstract class AbstractVaadin14Test extends AbstractVaadinTest { def handlers = getRequestHandlers("BootstrapHandler") trace(0, 2 + handlers.size()) { serverSpan(it, 0, getContextPath() + "/main") - basicSpan(it, 1, "SpringVaadinServletService.handleRequest", span(0)) + span(1) { + name "SpringVaadinServletService.handleRequest" + kind SpanKind.INTERNAL + childOf span(0) + } int spanIndex = 2 handlers.each { handler -> - basicSpan(it, spanIndex++, handler + ".handleRequest", span(1)) + span(spanIndex++) { + name handler + ".handleRequest" + kind SpanKind.INTERNAL + childOf span(1) + } } } // following traces are for javascript files used on page @@ -64,13 +72,25 @@ abstract class AbstractVaadin14Test extends AbstractVaadinTest { def handlers = getRequestHandlers("UidlRequestHandler") trace(0, 2 + handlers.size() + 1) { serverSpan(it, 0, getContextPath() + "/main") - basicSpan(it, 1, "SpringVaadinServletService.handleRequest", span(0)) + span(1) { + name "SpringVaadinServletService.handleRequest" + kind SpanKind.INTERNAL + childOf span(0) + } int spanIndex = 2 handlers.each { handler -> - basicSpan(it, spanIndex++, handler + ".handleRequest", span(1)) + span(spanIndex++) { + name handler + ".handleRequest" + kind SpanKind.INTERNAL + childOf span(1) + } + } + span(spanIndex) { + name "EventRpcHandler.handle/click" + kind SpanKind.INTERNAL + childOf span(spanIndex - 1) } - basicSpan(it, spanIndex, "EventRpcHandler.handle/click", span(spanIndex - 1)) } } } diff --git a/instrumentation/vaadin-14.2/testing/src/main/groovy/test/vaadin/AbstractVaadin16Test.groovy b/instrumentation/vaadin-14.2/testing/src/main/groovy/test/vaadin/AbstractVaadin16Test.groovy index bc9de5ee6c..abeb09cd20 100644 --- a/instrumentation/vaadin-14.2/testing/src/main/groovy/test/vaadin/AbstractVaadin16Test.groovy +++ b/instrumentation/vaadin-14.2/testing/src/main/groovy/test/vaadin/AbstractVaadin16Test.groovy @@ -5,9 +5,9 @@ package test.vaadin -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import com.vaadin.flow.server.Version +import io.opentelemetry.api.trace.SpanKind abstract class AbstractVaadin16Test extends AbstractVaadinTest { static final boolean VAADIN_17 = Version.majorVersion >= 4 @@ -36,10 +36,18 @@ abstract class AbstractVaadin16Test extends AbstractVaadinTest { def handlers = getRequestHandlers("IndexHtmlRequestHandler") trace(0, 2 + handlers.size()) { serverSpan(it, 0, "IndexHtmlRequestHandler.handleRequest") - basicSpan(it, 1, "SpringVaadinServletService.handleRequest", span(0)) + span(1) { + name "SpringVaadinServletService.handleRequest" + kind SpanKind.INTERNAL + childOf span(0) + } int spanIndex = 2 handlers.each { handler -> - basicSpan(it, spanIndex++, handler + ".handleRequest", span(1)) + span(spanIndex++) { + name handler + ".handleRequest" + kind SpanKind.INTERNAL + childOf span(1) + } } } // /xyz/VAADIN/build/vaadin-bundle-*.cache.js @@ -56,10 +64,18 @@ abstract class AbstractVaadin16Test extends AbstractVaadinTest { handlers = getRequestHandlers("JavaScriptBootstrapHandler") trace(traceIndex, 2 + handlers.size()) { serverSpan(it, 0, getContextPath()) - basicSpan(it, 1, "SpringVaadinServletService.handleRequest", span(0)) + span(1) { + name "SpringVaadinServletService.handleRequest" + kind SpanKind.INTERNAL + childOf span(0) + } int spanIndex = 2 handlers.each { handler -> - basicSpan(it, spanIndex++, handler + ".handleRequest", span(1)) + span(spanIndex++) { + name handler + ".handleRequest" + kind SpanKind.INTERNAL + childOf span(1) + } } } // /xyz/VAADIN/build/vaadin-?-*.cache.js @@ -81,15 +97,31 @@ abstract class AbstractVaadin16Test extends AbstractVaadinTest { handlers = getRequestHandlers("UidlRequestHandler") trace(traceIndex + 5, 2 + handlers.size() + 2) { serverSpan(it, 0, getContextPath() + "/main") - basicSpan(it, 1, "SpringVaadinServletService.handleRequest", span(0)) + span(1) { + name "SpringVaadinServletService.handleRequest" + kind SpanKind.INTERNAL + childOf span(0) + } int spanIndex = 2 handlers.each { handler -> - basicSpan(it, spanIndex++, handler + ".handleRequest", span(1)) + span(spanIndex++) { + name handler + ".handleRequest" + kind SpanKind.INTERNAL + childOf span(1) + } } - basicSpan(it, spanIndex, "PublishedServerEventHandlerRpcHandler.handle", span(spanIndex - 1)) - basicSpan(it, spanIndex + 1, "JavaScriptBootstrapUI.connectClient", span(spanIndex)) + span(spanIndex) { + name "PublishedServerEventHandlerRpcHandler.handle" + kind SpanKind.INTERNAL + childOf span(spanIndex - 1) + } + span(spanIndex + 1) { + name "JavaScriptBootstrapUI.connectClient" + kind SpanKind.INTERNAL + childOf span(spanIndex) + } } } } @@ -100,14 +132,26 @@ abstract class AbstractVaadin16Test extends AbstractVaadinTest { def handlers = getRequestHandlers("UidlRequestHandler") trace(0, 2 + handlers.size() + 1) { serverSpan(it, 0, getContextPath() + "/main") - basicSpan(it, 1, "SpringVaadinServletService.handleRequest", span(0)) + span(1) { + name "SpringVaadinServletService.handleRequest" + kind SpanKind.INTERNAL + childOf span(0) + } int spanIndex = 2 handlers.each { handler -> - basicSpan(it, spanIndex++, handler + ".handleRequest", span(1)) + span(spanIndex++) { + name handler + ".handleRequest" + kind SpanKind.INTERNAL + childOf span(1) + } } - basicSpan(it, spanIndex, "EventRpcHandler.handle/click", span(spanIndex - 1)) + span(spanIndex) { + name "EventRpcHandler.handle/click" + kind SpanKind.INTERNAL + childOf span(spanIndex - 1) + } } } } diff --git a/instrumentation/vertx-reactive-3.5/javaagent/src/test/groovy/VertxReactivePropagationTest.groovy b/instrumentation/vertx-reactive-3.5/javaagent/src/test/groovy/VertxReactivePropagationTest.groovy index 54c3805f95..4de2b2ce90 100644 --- a/instrumentation/vertx-reactive-3.5/javaagent/src/test/groovy/VertxReactivePropagationTest.groovy +++ b/instrumentation/vertx-reactive-3.5/javaagent/src/test/groovy/VertxReactivePropagationTest.groovy @@ -8,12 +8,10 @@ import static VertxReactiveWebServer.TEST_REQUEST_ID_PARAMETER import static io.opentelemetry.api.trace.SpanKind.CLIENT import static io.opentelemetry.api.trace.SpanKind.SERVER import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicClientSpan -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicServerSpan -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import io.opentelemetry.api.GlobalOpenTelemetry import io.opentelemetry.api.trace.Span +import io.opentelemetry.api.trace.SpanKind import io.opentelemetry.context.Context import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification import io.opentelemetry.instrumentation.test.utils.PortUtils @@ -73,8 +71,16 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification { "${SemanticAttributes.HTTP_CLIENT_IP.key}" "127.0.0.1" } } - basicSpan(it, 1, "handleListProducts", span(0)) - basicSpan(it, 2, "listProducts", span(1)) + span(1) { + name "handleListProducts" + kind SpanKind.INTERNAL + childOf span(0) + } + span(2) { + name "listProducts" + kind SpanKind.INTERNAL + childOf span(1) + } span(3) { name "SELECT test.products" kind CLIENT @@ -129,34 +135,59 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification { def rootSpan = it.span(0) def requestId = Long.valueOf(rootSpan.name.substring("client ".length())) - basicSpan(it, 0, "client $requestId", null, null) { - "${TEST_REQUEST_ID_ATTRIBUTE}" requestId + span(0) { + name "client $requestId" + kind SpanKind.INTERNAL + hasNoParent() + attributes { + "${TEST_REQUEST_ID_ATTRIBUTE}" requestId + } } - basicServerSpan(it, 1, "/listProducts", span(0), null) { - "${SemanticAttributes.NET_PEER_PORT.key}" Long - "${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1" - "${SemanticAttributes.HTTP_URL.key}" "http://localhost:$port$baseUrl?$TEST_REQUEST_ID_PARAMETER=$requestId" - "${SemanticAttributes.HTTP_METHOD.key}" "GET" - "${SemanticAttributes.HTTP_STATUS_CODE.key}" 200 - "${SemanticAttributes.HTTP_FLAVOR.key}" "1.1" - "${SemanticAttributes.HTTP_USER_AGENT.key}" String - "${SemanticAttributes.HTTP_CLIENT_IP.key}" "127.0.0.1" - "${TEST_REQUEST_ID_ATTRIBUTE}" requestId + span(1) { + name "/listProducts" + kind SERVER + childOf(span(0)) + attributes { + "${SemanticAttributes.NET_PEER_PORT.key}" Long + "${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1" + "${SemanticAttributes.HTTP_URL.key}" "http://localhost:$port$baseUrl?$TEST_REQUEST_ID_PARAMETER=$requestId" + "${SemanticAttributes.HTTP_METHOD.key}" "GET" + "${SemanticAttributes.HTTP_STATUS_CODE.key}" 200 + "${SemanticAttributes.HTTP_FLAVOR.key}" "1.1" + "${SemanticAttributes.HTTP_USER_AGENT.key}" String + "${SemanticAttributes.HTTP_CLIENT_IP.key}" "127.0.0.1" + "${TEST_REQUEST_ID_ATTRIBUTE}" requestId + } } - basicSpan(it, 2, "handleListProducts", span(1), null) { - "${TEST_REQUEST_ID_ATTRIBUTE}" requestId + span(2) { + name "handleListProducts" + kind SpanKind.INTERNAL + childOf(span(1)) + attributes { + "${TEST_REQUEST_ID_ATTRIBUTE}" requestId + } } - basicSpan(it, 3, "listProducts", span(2), null) { - "${TEST_REQUEST_ID_ATTRIBUTE}" requestId + span(3) { + name "listProducts" + kind SpanKind.INTERNAL + childOf(span(2)) + attributes { + "${TEST_REQUEST_ID_ATTRIBUTE}" requestId + } } - basicClientSpan(it, 4, "SELECT test.products", span(3), null) { - "${SemanticAttributes.DB_SYSTEM.key}" "hsqldb" - "${SemanticAttributes.DB_NAME.key}" "test" - "${SemanticAttributes.DB_USER.key}" "SA" - "${SemanticAttributes.DB_CONNECTION_STRING.key}" "hsqldb:mem:" - "${SemanticAttributes.DB_STATEMENT.key}" "SELECT id AS request$requestId, name, price, weight FROM products" - "${SemanticAttributes.DB_OPERATION.key}" "SELECT" - "${SemanticAttributes.DB_SQL_TABLE.key}" "products" + span(4) { + name "SELECT test.products" + kind CLIENT + childOf(span(3)) + attributes { + "${SemanticAttributes.DB_SYSTEM.key}" "hsqldb" + "${SemanticAttributes.DB_NAME.key}" "test" + "${SemanticAttributes.DB_USER.key}" "SA" + "${SemanticAttributes.DB_CONNECTION_STRING.key}" "hsqldb:mem:" + "${SemanticAttributes.DB_STATEMENT.key}" "SELECT id AS request$requestId, name, price, weight FROM products" + "${SemanticAttributes.DB_OPERATION.key}" "SELECT" + "${SemanticAttributes.DB_SQL_TABLE.key}" "products" + } } } } diff --git a/instrumentation/wicket-8.0/javaagent/src/test/groovy/WicketTest.groovy b/instrumentation/wicket-8.0/javaagent/src/test/groovy/WicketTest.groovy index 7f0be996d1..2f52303697 100644 --- a/instrumentation/wicket-8.0/javaagent/src/test/groovy/WicketTest.groovy +++ b/instrumentation/wicket-8.0/javaagent/src/test/groovy/WicketTest.groovy @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicServerSpan - import hello.HelloApplication +import io.opentelemetry.api.trace.SpanKind +import io.opentelemetry.api.trace.StatusCode import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification import io.opentelemetry.instrumentation.test.base.HttpServerTestTrait import io.opentelemetry.testing.internal.armeria.common.AggregatedHttpResponse @@ -61,7 +61,11 @@ class WicketTest extends AgentInstrumentationSpecification implements HttpServer assertTraces(1) { trace(0, 1) { - basicServerSpan(it, 0, getContextPath() + "/wicket-test/hello.HelloPage") + span(0) { + name getContextPath() + "/wicket-test/hello.HelloPage" + kind SpanKind.SERVER + hasNoParent() + } } } } @@ -72,10 +76,17 @@ class WicketTest extends AgentInstrumentationSpecification implements HttpServer expect: response.status().code() == 500 + def ex = new Exception("test exception") assertTraces(1) { trace(0, 1) { - basicServerSpan(it, 0, getContextPath() + "/wicket-test/hello.ExceptionPage", null, new Exception("test exception")) + span(0) { + name getContextPath() + "/wicket-test/hello.ExceptionPage" + kind SpanKind.SERVER + hasNoParent() + status StatusCode.ERROR + errorEvent(ex.class, ex.message) + } } } } diff --git a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/AbstractPromiseTest.groovy b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/AbstractPromiseTest.groovy index 763aef9e17..8e291ffde1 100644 --- a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/AbstractPromiseTest.groovy +++ b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/AbstractPromiseTest.groovy @@ -5,7 +5,6 @@ package io.opentelemetry.instrumentation.test.base -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import io.opentelemetry.api.trace.SpanKind import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification @@ -48,8 +47,16 @@ abstract class AbstractPromiseTest extends AgentInstrumentationSpecificati kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "other", it.span(0)) - basicSpan(it, 2, "callback", it.span(0)) + span(1) { + name "other" + kind SpanKind.INTERNAL + childOf span(0) + } + span(2) { + name "callback" + kind SpanKind.INTERNAL + childOf span(0) + } } } @@ -83,7 +90,11 @@ abstract class AbstractPromiseTest extends AgentInstrumentationSpecificati kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "callback", span(0)) + span(1) { + name "callback" + kind SpanKind.INTERNAL + childOf span(0) + } } trace(1, 1) { span(0) { @@ -123,7 +134,11 @@ abstract class AbstractPromiseTest extends AgentInstrumentationSpecificati kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "callback", it.span(0)) + span(1) { + name "callback" + kind SpanKind.INTERNAL + childOf span(0) + } } } @@ -156,7 +171,11 @@ abstract class AbstractPromiseTest extends AgentInstrumentationSpecificati kind SpanKind.INTERNAL hasNoParent() } - basicSpan(it, 1, "callback", it.span(0)) + span(1) { + name "callback" + kind SpanKind.INTERNAL + childOf span(0) + } } } diff --git a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpClientTest.groovy b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpClientTest.groovy index 8d7cd453f1..ab39201395 100644 --- a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpClientTest.groovy +++ b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpClientTest.groovy @@ -9,8 +9,6 @@ import static io.opentelemetry.api.trace.SpanKind.CLIENT import static io.opentelemetry.api.trace.SpanKind.SERVER import static io.opentelemetry.api.trace.StatusCode.ERROR import static io.opentelemetry.instrumentation.test.utils.PortUtils.UNUSABLE_PORT -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicClientSpan -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import static io.opentelemetry.instrumentation.test.utils.TraceUtils.runUnderParentClientSpan import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP import static io.opentelemetry.testing.internal.armeria.common.MediaType.PLAIN_TEXT_UTF_8 @@ -382,7 +380,11 @@ abstract class HttpClientTest extends InstrumentationSpecification { traces.sort(orderByRootSpanKind(CLIENT, SERVER)) trace(0, 1) { - basicClientSpan(it, 0, "parent-client-span") + span(0) { + name "parent-client-span" + kind CLIENT + hasNoParent() + } } trace(1, 1) { serverSpan(it, 0) @@ -421,7 +423,11 @@ abstract class HttpClientTest extends InstrumentationSpecification { } clientSpan(it, 1, span(0), method) serverSpan(it, 2, span(1)) - basicSpan(it, 3, "child", span(0)) + span(3) { + name "child" + kind SpanKind.INTERNAL + childOf span(0) + } } } @@ -571,7 +577,11 @@ abstract class HttpClientTest extends InstrumentationSpecification { then: assertTraces(1) { trace(0, 3) { - basicSpan(it, 0, "parent", null) + span(0) { + name "parent" + kind SpanKind.INTERNAL + hasNoParent() + } clientSpan(it, 1, span(0), method, uri, 500) serverSpan(it, 2, span(1)) } @@ -649,7 +659,13 @@ abstract class HttpClientTest extends InstrumentationSpecification { and: assertTraces(1) { trace(0, 2) { - basicSpan(it, 0, "parent", null, thrownException) + span(0) { + name "parent" + kind SpanKind.INTERNAL + hasNoParent() + status ERROR + errorEvent(thrownException.class, thrownException.message) + } clientSpan(it, 1, span(0), method, uri, null, thrownException) } } @@ -687,7 +703,11 @@ abstract class HttpClientTest extends InstrumentationSpecification { hasNoParent() } clientSpan(it, 1, span(0), method, uri, null, thrownException) - basicSpan(it, 2, "callback", span(0)) + span(2) { + name "callback" + kind SpanKind.INTERNAL + childOf span(0) + } } } @@ -710,7 +730,13 @@ abstract class HttpClientTest extends InstrumentationSpecification { def thrownException = ex instanceof ExecutionException ? ex.cause : ex assertTraces(1) { trace(0, 2) { - basicSpan(it, 0, "parent", null, thrownException) + span(0) { + name "parent" + kind SpanKind.INTERNAL + hasNoParent() + status ERROR + errorEvent(thrownException.class, thrownException.message) + } clientSpan(it, 1, span(0), method, uri, null, thrownException) } } @@ -782,8 +808,13 @@ abstract class HttpClientTest extends InstrumentationSpecification { //Traces can be in arbitrary order, let us find out the request id of the current one def requestId = Integer.parseInt(rootSpan.name.substring("Parent span ".length())) - basicSpan(it, 0, "Parent span " + requestId, null, null) { - it."test.request.id" requestId + span(0) { + name "Parent span " + requestId + kind SpanKind.INTERNAL + hasNoParent() + attributes { + "test.request.id" requestId + } } clientSpan(it, 1, span(0), method, url) serverSpan(it, 2, span(1)) { @@ -831,14 +862,23 @@ abstract class HttpClientTest extends InstrumentationSpecification { //Traces can be in arbitrary order, let us find out the request id of the current one def requestId = Integer.parseInt(rootSpan.name.substring("Parent span ".length())) - basicSpan(it, 0, "Parent span " + requestId, null, null) { - it."test.request.id" requestId + span(0) { + name "Parent span " + requestId + kind SpanKind.INTERNAL + hasNoParent() + attributes { + "test.request.id" requestId + } } clientSpan(it, 1, span(0), method, url) serverSpan(it, 2, span(1)) { it."test.request.id" requestId } - basicSpan(it, 3, "child", span(0)) + span(3) { + name "child" + kind SpanKind.INTERNAL + childOf span(0) + } } } } @@ -881,8 +921,13 @@ abstract class HttpClientTest extends InstrumentationSpecification { //Traces can be in arbitrary order, let us find out the request id of the current one def requestId = Integer.parseInt(rootSpan.name.substring("Parent span ".length())) - basicSpan(it, 0, "Parent span " + requestId, null, null) { - it."test.request.id" requestId + span(0) { + name "Parent span " + requestId + kind SpanKind.INTERNAL + hasNoParent() + attributes { + "test.request.id" requestId + } } clientSpan(it, 1, span(0), method, url) serverSpan(it, 2, span(1)) { diff --git a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy index 56c8ba68d4..4f2d2b6995 100644 --- a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy +++ b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy @@ -13,7 +13,6 @@ import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEn import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS -import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan import static io.opentelemetry.instrumentation.test.utils.TraceUtils.runUnderTrace import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP import static org.junit.Assume.assumeTrue @@ -420,8 +419,13 @@ abstract class HttpServerTest extends InstrumentationSpecification imple //Traces can be in arbitrary order, let us find out the request id of the current one def requestId = Integer.parseInt(rootSpan.name.substring("client ".length())) - basicSpan(it, 0, "client " + requestId, null, null) { - "${ServerEndpoint.ID_ATTRIBUTE_NAME}" requestId + span(0) { + name "client " + requestId + kind SpanKind.INTERNAL + hasNoParent() + attributes { + "${ServerEndpoint.ID_ATTRIBUTE_NAME}" requestId + } } indexedServerSpan(it, span(0), requestId) diff --git a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/utils/TraceUtils.groovy b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/utils/TraceUtils.groovy index 468c5d7b4e..2d4e697f4d 100644 --- a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/utils/TraceUtils.groovy +++ b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/utils/TraceUtils.groovy @@ -5,22 +5,17 @@ package io.opentelemetry.instrumentation.test.utils -import groovy.transform.stc.ClosureParams -import groovy.transform.stc.SimpleType + import io.opentelemetry.api.GlobalOpenTelemetry import io.opentelemetry.api.trace.Span import io.opentelemetry.api.trace.SpanKind import io.opentelemetry.api.trace.StatusCode import io.opentelemetry.api.trace.Tracer import io.opentelemetry.extension.annotations.WithSpan -import io.opentelemetry.instrumentation.test.asserts.AttributesAssert -import io.opentelemetry.instrumentation.test.asserts.TraceAssert import io.opentelemetry.instrumentation.test.server.ServerTraceUtils import io.opentelemetry.instrumentation.testing.util.ThrowingRunnable -import io.opentelemetry.sdk.trace.data.SpanData import java.util.concurrent.Callable import java.util.concurrent.ExecutionException - // TODO: convert all usages of this class to the Java TraceUtils one class TraceUtils { @@ -69,47 +64,6 @@ class TraceUtils { r.call() } - static basicClientSpan(TraceAssert trace, int index, String operation, Object parentSpan = null, Throwable exception = null, - @ClosureParams(value = SimpleType, options = ['io.opentelemetry.instrumentation.test.asserts.AttributesAssert']) - @DelegatesTo(value = AttributesAssert, strategy = Closure.DELEGATE_FIRST) Closure additionAttributesAssert = null) { - return basicSpanForKind(trace, index, SpanKind.CLIENT, operation, parentSpan, exception, additionAttributesAssert) - } - - static basicServerSpan(TraceAssert trace, int index, String operation, Object parentSpan = null, Throwable exception = null, - @ClosureParams(value = SimpleType, options = ['io.opentelemetry.instrumentation.test.asserts.AttributesAssert']) - @DelegatesTo(value = AttributesAssert, strategy = Closure.DELEGATE_FIRST) Closure additionAttributesAssert = null) { - return basicSpanForKind(trace, index, SpanKind.SERVER, operation, parentSpan, exception, additionAttributesAssert) - } - - // TODO rename to basicInternalSpan - static basicSpan(TraceAssert trace, int index, String operation, Object parentSpan = null, Throwable exception = null, - @ClosureParams(value = SimpleType, options = ['io.opentelemetry.instrumentation.test.asserts.AttributesAssert']) - @DelegatesTo(value = AttributesAssert, strategy = Closure.DELEGATE_FIRST) Closure additionAttributesAssert = null) { - return basicSpanForKind(trace, index, SpanKind.INTERNAL, operation, parentSpan, exception, additionAttributesAssert) - } - - private static basicSpanForKind(TraceAssert trace, int index, SpanKind spanKind, String operation, Object parentSpan = null, Throwable exception = null, - @ClosureParams(value = SimpleType, options = ['io.opentelemetry.instrumentation.test.asserts.AttributesAssert']) - @DelegatesTo(value = AttributesAssert, strategy = Closure.DELEGATE_FIRST) Closure additionAttributesAssert = null) { - trace.span(index) { - if (parentSpan == null) { - hasNoParent() - } else { - childOf((SpanData) parentSpan) - } - name operation - kind spanKind - if (exception) { - status StatusCode.ERROR - errorEvent(exception.class, exception.message) - } - - if (additionAttributesAssert != null) { - attributes(additionAttributesAssert) - } - } - } - static T runUnderTraceWithoutExceptionCatch(String spanName, Callable r) { Span span = tracer.spanBuilder(spanName).setSpanKind(SpanKind.INTERNAL).startSpan()