From e54a007dc14aef36bae5e7ed757e5eda44883bc3 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Mon, 17 May 2021 12:12:56 -0700 Subject: [PATCH] Remove unnecessary method in test harness (#3016) --- .../jaxws/v2_0/JaxWsAnnotationsTest.groovy | 7 ++++--- .../jaxws/jws/v1_1/JwsAnnotationsTest.groovy | 13 +++++++------ .../javaagent/src/test/groovy/RabbitMQTest.groovy | 2 +- .../test/asserts/AttributesAssert.groovy | 5 +---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/instrumentation/jaxws/jaxws-2.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/jaxws/v2_0/JaxWsAnnotationsTest.groovy b/instrumentation/jaxws/jaxws-2.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/jaxws/v2_0/JaxWsAnnotationsTest.groovy index 13b1b0c2b7..1de988c9cd 100644 --- a/instrumentation/jaxws/jaxws-2.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/jaxws/v2_0/JaxWsAnnotationsTest.groovy +++ b/instrumentation/jaxws/jaxws-2.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/jaxws/v2_0/JaxWsAnnotationsTest.groovy @@ -6,6 +6,7 @@ package io.opentelemetry.javaagent.instrumentation.jaxws.v2_0 import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes import io.opentelemetry.test.SoapProvider class JaxWsAnnotationsTest extends AgentInstrumentationSpecification { @@ -18,10 +19,10 @@ class JaxWsAnnotationsTest extends AgentInstrumentationSpecification { assertTraces(1) { trace(0, 1) { span(0) { - name 'SoapProvider.invoke' + name "SoapProvider.invoke" attributes { - attribute('code.namespace', 'io.opentelemetry.test.SoapProvider') - attribute('code.function', 'invoke') + "${SemanticAttributes.CODE_NAMESPACE.key}" "io.opentelemetry.test.SoapProvider" + "${SemanticAttributes.CODE_FUNCTION.key}" "invoke" } } } diff --git a/instrumentation/jaxws/jws-1.1/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/jaxws/jws/v1_1/JwsAnnotationsTest.groovy b/instrumentation/jaxws/jws-1.1/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/jaxws/jws/v1_1/JwsAnnotationsTest.groovy index 13183dbb6e..947fa851ed 100644 --- a/instrumentation/jaxws/jws-1.1/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/jaxws/jws/v1_1/JwsAnnotationsTest.groovy +++ b/instrumentation/jaxws/jws-1.1/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/jaxws/jws/v1_1/JwsAnnotationsTest.groovy @@ -6,6 +6,7 @@ package io.opentelemetry.javaagent.instrumentation.jaxws.jws.v1_1 import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes import io.opentelemetry.test.WebServiceClass import io.opentelemetry.test.WebServiceDefinitionInterface import io.opentelemetry.test.WebServiceFromInterface @@ -25,8 +26,8 @@ class JwsAnnotationsTest extends AgentInstrumentationSpecification { span(0) { name "WebServiceClass.doSomethingPublic" attributes { - attribute('code.function', 'doSomethingPublic') - attribute('code.namespace', 'io.opentelemetry.test.WebServiceClass') + "${SemanticAttributes.CODE_NAMESPACE.key}" "io.opentelemetry.test.WebServiceClass" + "${SemanticAttributes.CODE_FUNCTION.key}" "doSomethingPublic" } } } @@ -45,8 +46,8 @@ class JwsAnnotationsTest extends AgentInstrumentationSpecification { span(0) { name "WebServiceFromInterface.partOfPublicInterface" attributes { - attribute('code.function', 'partOfPublicInterface') - attribute('code.namespace', 'io.opentelemetry.test.WebServiceFromInterface') + "${SemanticAttributes.CODE_NAMESPACE.key}" "io.opentelemetry.test.WebServiceFromInterface" + "${SemanticAttributes.CODE_FUNCTION.key}" "partOfPublicInterface" } } } @@ -69,8 +70,8 @@ class JwsAnnotationsTest extends AgentInstrumentationSpecification { span(0) { name "WebServiceFromInterface.partOfPublicInterface" attributes { - attribute('code.function', 'partOfPublicInterface') - attribute('code.namespace', 'io.opentelemetry.test.WebServiceFromInterface') + "${SemanticAttributes.CODE_NAMESPACE.key}" "io.opentelemetry.test.WebServiceFromInterface" + "${SemanticAttributes.CODE_FUNCTION.key}" "partOfPublicInterface" } } } diff --git a/instrumentation/rabbitmq-2.7/javaagent/src/test/groovy/RabbitMQTest.groovy b/instrumentation/rabbitmq-2.7/javaagent/src/test/groovy/RabbitMQTest.groovy index 6bdb7f6845..d8eab43b1b 100644 --- a/instrumentation/rabbitmq-2.7/javaagent/src/test/groovy/RabbitMQTest.groovy +++ b/instrumentation/rabbitmq-2.7/javaagent/src/test/groovy/RabbitMQTest.groovy @@ -375,7 +375,7 @@ class RabbitMQTest extends AgentInstrumentationSpecification { "rabbitmq.record.queue_time_ms" { it instanceof Long && it >= 0 } } - switch (attribute("rabbitmq.command")) { + switch (trace.span(index).attributes.get(AttributeKey.stringKey("rabbitmq.command"))) { case "basic.publish": "rabbitmq.command" "basic.publish" "rabbitmq.routing_key" { diff --git a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/asserts/AttributesAssert.groovy b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/asserts/AttributesAssert.groovy index 20c84e21bf..42620a242e 100644 --- a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/asserts/AttributesAssert.groovy +++ b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/asserts/AttributesAssert.groovy @@ -45,10 +45,6 @@ class AttributesAssert { } } - def attribute(String name) { - return attributes[name] - } - def methodMissing(String name, args) { if (args.length == 0) { throw new IllegalArgumentException(args.toString()) @@ -56,6 +52,7 @@ class AttributesAssert { attribute(name, args[0]) } + // this could be private, but then codenarc fails, thinking (incorrectly) that it's unused void assertAttributesAllVerified() { Set allAttributes = new TreeSet<>(attributes.keySet()) Set unverifiedAttributes = new TreeSet(allAttributes)