Remove HttpServerTest#extraAttributes() method (#5176)

* Remove HttpServerTest#extraAttributes() method

* fix ktor tests

* fix ratpack and restlet tests

* fix servlet2 tests

* Fix webflux and vertx tests
This commit is contained in:
Mateusz Rzeszutek 2022-01-20 19:41:41 +01:00 committed by GitHub
parent 60da2d42d2
commit 540e4cfafb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 170 additions and 268 deletions

View File

@ -6,7 +6,6 @@
import io.opentelemetry.api.common.AttributeKey
import io.opentelemetry.instrumentation.test.AgentTestTrait
import io.opentelemetry.instrumentation.test.base.HttpServerTest
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
abstract class AkkaHttpServerInstrumentationTest extends HttpServerTest<Object> implements AgentTestTrait {
@ -33,9 +32,7 @@ abstract class AkkaHttpServerInstrumentationTest extends HttpServerTest<Object>
@Override
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
def attributes = super.httpAttributes(endpoint)
attributes.remove(SemanticAttributes.HTTP_ROUTE)
attributes
[]
}
}

View File

@ -52,14 +52,13 @@ abstract class AbstractArmeriaHttpServerTest extends HttpServerTest<Server> {
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
Set<AttributeKey<?>> extra = [
SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH,
SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH,
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_PEER_NAME,
SemanticAttributes.NET_TRANSPORT
SemanticAttributes.HTTP_SERVER_NAME
]
super.httpAttributes(endpoint) + extra
}
@Override

View File

@ -63,12 +63,11 @@ class DropwizardTest extends HttpServerTest<DropwizardTestSupport> implements Ag
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_PEER_NAME,
SemanticAttributes.NET_TRANSPORT
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
Set<AttributeKey<?>> extra = [
SemanticAttributes.HTTP_SERVER_NAME
]
super.httpAttributes(endpoint) + extra
}
// this override is needed because dropwizard reports peer ip as the client ip

View File

@ -57,12 +57,11 @@ class GrailsTest extends HttpServerTest<ConfigurableApplicationContext> implemen
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_PEER_NAME,
SemanticAttributes.NET_TRANSPORT
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
Set<AttributeKey<?>> extra = [
SemanticAttributes.HTTP_SERVER_NAME
]
super.httpAttributes(endpoint) + extra
}
@Override

View File

@ -67,6 +67,7 @@ class GrizzlyFilterchainServerTest extends HttpServerTest<HttpServer> implements
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
def attributes = super.httpAttributes(endpoint)
attributes.remove(SemanticAttributes.HTTP_ROUTE)
attributes.remove(SemanticAttributes.NET_TRANSPORT)
attributes
}

View File

@ -48,6 +48,7 @@ class GrizzlyTest extends HttpServerTest<HttpServer> implements AgentTestTrait {
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
def attributes = super.httpAttributes(endpoint)
attributes.remove(SemanticAttributes.HTTP_ROUTE)
attributes.remove(SemanticAttributes.NET_TRANSPORT)
attributes
}

View File

@ -190,11 +190,11 @@ abstract class JaxRsHttpServerTest<S> extends HttpServerTest<S> implements Agent
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_TRANSPORT
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
Set<AttributeKey<?>> extra = [
SemanticAttributes.HTTP_SERVER_NAME
]
super.httpAttributes(endpoint) + extra
}
@Override

View File

@ -63,11 +63,16 @@ class JettyHandlerTest extends HttpServerTest<Server> implements AgentTestTrait
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_TRANSPORT
]
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
def attributes = super.httpAttributes(endpoint)
attributes.remove(SemanticAttributes.HTTP_ROUTE)
attributes.add(SemanticAttributes.HTTP_SERVER_NAME)
attributes
}
@Override
String expectedServerSpanName(ServerEndpoint endpoint) {
"HTTP GET"
}
@Override
@ -114,7 +119,7 @@ class JettyHandlerTest extends HttpServerTest<Server> implements AgentTestTrait
case EXCEPTION:
throw new Exception(endpoint.body)
case INDEXED_CHILD:
INDEXED_CHILD.collectSpanAttributes {name -> request.getParameter(name) }
INDEXED_CHILD.collectSpanAttributes { name -> request.getParameter(name) }
response.status = endpoint.status
response.writer.print(endpoint.body)
break
@ -140,16 +145,4 @@ class JettyHandlerTest extends HttpServerTest<Server> implements AgentTestTrait
}
}
}
@Override
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
def attributes = super.httpAttributes(endpoint)
attributes.remove(SemanticAttributes.HTTP_ROUTE)
attributes
}
@Override
String expectedServerSpanName(ServerEndpoint endpoint) {
"HTTP GET"
}
}

View File

@ -64,11 +64,16 @@ class JettyHandlerTest extends HttpServerTest<Server> implements AgentTestTrait
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_TRANSPORT
]
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
def attributes = super.httpAttributes(endpoint)
attributes.remove(SemanticAttributes.HTTP_ROUTE)
attributes.addAll(SemanticAttributes.HTTP_SERVER_NAME)
attributes
}
@Override
String expectedServerSpanName(ServerEndpoint endpoint) {
"HTTP GET"
}
@Override
@ -115,7 +120,7 @@ class JettyHandlerTest extends HttpServerTest<Server> implements AgentTestTrait
case EXCEPTION:
throw new Exception(endpoint.body)
case INDEXED_CHILD:
INDEXED_CHILD.collectSpanAttributes {name -> request.getParameter(name) }
INDEXED_CHILD.collectSpanAttributes { name -> request.getParameter(name) }
response.status = endpoint.status
response.writer.print(endpoint.body)
break
@ -141,16 +146,4 @@ class JettyHandlerTest extends HttpServerTest<Server> implements AgentTestTrait
}
}
}
@Override
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
def attributes = super.httpAttributes(endpoint)
attributes.remove(SemanticAttributes.HTTP_ROUTE)
attributes
}
@Override
String expectedServerSpanName(ServerEndpoint endpoint) {
"HTTP GET"
}
}

View File

@ -39,6 +39,13 @@ class KtorHttpServerTest extends HttpServerTest<ApplicationEngine> implements Li
true
}
@Override
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
def attributes = super.httpAttributes(endpoint)
attributes.remove(SemanticAttributes.NET_PEER_PORT)
attributes
}
@Override
String expectedServerSpanName(ServerEndpoint endpoint) {
def route = expectedHttpRoute(endpoint)
@ -54,12 +61,4 @@ class KtorHttpServerTest extends HttpServerTest<ApplicationEngine> implements Li
return super.expectedHttpRoute(endpoint)
}
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.NET_PEER_NAME,
SemanticAttributes.NET_TRANSPORT
]
}
}

View File

@ -5,11 +5,15 @@
package io.opentelemetry.javaagent.instrumentation.netty.v3_8.server;
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP;
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_UDP;
import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import javax.annotation.Nullable;
import org.jboss.netty.channel.socket.DatagramChannel;
import org.jboss.netty.handler.codec.http.HttpResponse;
final class NettyNetServerAttributesExtractor
@ -18,7 +22,7 @@ final class NettyNetServerAttributesExtractor
@Override
@Nullable
public String transport(HttpRequestAndChannel requestAndChannel) {
return null;
return requestAndChannel.channel() instanceof DatagramChannel ? IP_UDP : IP_TCP;
}
@Override

View File

@ -5,6 +5,10 @@
package io.opentelemetry.javaagent.instrumentation.netty.common.server;
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP;
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_UDP;
import io.netty.channel.socket.DatagramChannel;
import io.netty.handler.codec.http.HttpResponse;
import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor;
import io.opentelemetry.javaagent.instrumentation.netty.common.HttpRequestAndChannel;
@ -18,7 +22,7 @@ final class NettyNetServerAttributesExtractor
@Override
@Nullable
public String transport(HttpRequestAndChannel requestAndChannel) {
return null;
return requestAndChannel.channel() instanceof DatagramChannel ? IP_UDP : IP_TCP;
}
@Override

View File

@ -11,7 +11,6 @@ import io.opentelemetry.instrumentation.test.AgentTestTrait
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
import io.opentelemetry.instrumentation.test.base.HttpServerTest
import io.opentelemetry.sdk.trace.data.SpanData
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import play.BuiltInComponents
import play.Mode
import play.mvc.Controller
@ -103,9 +102,7 @@ class PlayServerTest extends HttpServerTest<Server> implements AgentTestTrait {
@Override
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
def attributes = super.httpAttributes(endpoint)
attributes.remove(SemanticAttributes.HTTP_ROUTE)
attributes
[]
}
@Override

View File

@ -5,7 +5,6 @@
package io.opentelemetry.instrumentation.ratpack.server
import io.opentelemetry.api.common.AttributeKey
import io.opentelemetry.instrumentation.test.InstrumentationSpecification
import io.opentelemetry.instrumentation.test.utils.PortUtils
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
@ -81,10 +80,6 @@ abstract class AbstractRatpackRoutesTest extends InstrumentationSpecification {
abstract boolean hasHandlerSpan()
List<AttributeKey<?>> extraAttributes() {
[]
}
def "test bindings for #path"() {
when:
def resp = client.get(path).aggregate().join()
@ -93,8 +88,6 @@ abstract class AbstractRatpackRoutesTest extends InstrumentationSpecification {
resp.status().code() == 200
resp.contentUtf8() == route
def extraAttributes = extraAttributes()
assertTraces(1) {
trace(0, 1 + (hasHandlerSpan() ? 1 : 0)) {
span(0) {
@ -102,35 +95,19 @@ abstract class AbstractRatpackRoutesTest extends InstrumentationSpecification {
kind SERVER
hasNoParent()
attributes {
if (extraAttributes.contains(SemanticAttributes.NET_TRANSPORT)) {
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
}
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
// net.peer.name resolves to "127.0.0.1" on windows which is same as net.peer.ip so then not captured
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" }
"$SemanticAttributes.NET_PEER_IP" { it == null || it == "127.0.0.1" }
"$SemanticAttributes.NET_PEER_PORT" Long
"$SemanticAttributes.HTTP_METHOD" "GET"
"$SemanticAttributes.HTTP_STATUS_CODE" 200
"$SemanticAttributes.HTTP_FLAVOR" "1.1"
"$SemanticAttributes.HTTP_USER_AGENT" String
if (extraAttributes.contains(SemanticAttributes.HTTP_URL)) {
"$SemanticAttributes.HTTP_URL" "http://localhost:${app.bindPort}/${path}"
} else {
"$SemanticAttributes.HTTP_SCHEME" "http"
"$SemanticAttributes.HTTP_HOST" "localhost:${app.bindPort}"
"$SemanticAttributes.HTTP_TARGET" "/$path"
}
if (extraAttributes.contains(SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH)) {
"$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" Long
}
if (extraAttributes.contains(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH)) {
"$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" Long
}
if (extraAttributes.contains(SemanticAttributes.HTTP_SERVER_NAME)) {
"$SemanticAttributes.HTTP_SERVER_NAME" String
}
"$SemanticAttributes.HTTP_SCHEME" "http"
"$SemanticAttributes.HTTP_HOST" "localhost:${app.bindPort}"
"$SemanticAttributes.HTTP_TARGET" "/$path"
"$SemanticAttributes.HTTP_ROUTE" "/$route"
}
}

View File

@ -5,10 +5,8 @@
package io.opentelemetry.instrumentation.ratpack.server
import io.opentelemetry.api.common.AttributeKey
import io.opentelemetry.instrumentation.ratpack.RatpackTracing
import io.opentelemetry.instrumentation.test.LibraryTestTrait
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import ratpack.server.RatpackServerSpec
class RatpackAsyncHttpServerTest extends AbstractRatpackAsyncHttpServerTest implements LibraryTestTrait {
@ -26,12 +24,4 @@ class RatpackAsyncHttpServerTest extends AbstractRatpackAsyncHttpServerTest impl
boolean hasHandlerSpan(ServerEndpoint endpoint) {
false
}
@Override
List<AttributeKey<?>> extraAttributes() {
return [
SemanticAttributes.HTTP_ROUTE,
SemanticAttributes.NET_TRANSPORT
]
}
}

View File

@ -5,10 +5,8 @@
package io.opentelemetry.instrumentation.ratpack.server
import io.opentelemetry.api.common.AttributeKey
import io.opentelemetry.instrumentation.ratpack.RatpackTracing
import io.opentelemetry.instrumentation.test.LibraryTestTrait
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import ratpack.server.RatpackServerSpec
class RatpackForkedHttpServerTest extends AbstractRatpackForkedHttpServerTest implements LibraryTestTrait {
@ -26,12 +24,4 @@ class RatpackForkedHttpServerTest extends AbstractRatpackForkedHttpServerTest im
boolean hasHandlerSpan(ServerEndpoint endpoint) {
false
}
@Override
List<AttributeKey<?>> extraAttributes() {
return [
SemanticAttributes.HTTP_ROUTE,
SemanticAttributes.NET_TRANSPORT
]
}
}

View File

@ -5,10 +5,8 @@
package io.opentelemetry.instrumentation.ratpack.server
import io.opentelemetry.api.common.AttributeKey
import io.opentelemetry.instrumentation.ratpack.RatpackTracing
import io.opentelemetry.instrumentation.test.LibraryTestTrait
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import ratpack.server.RatpackServerSpec
class RatpackHttpServerTest extends AbstractRatpackHttpServerTest implements LibraryTestTrait {
@ -26,12 +24,4 @@ class RatpackHttpServerTest extends AbstractRatpackHttpServerTest implements Lib
boolean hasHandlerSpan(ServerEndpoint endpoint) {
false
}
@Override
List<AttributeKey<?>> extraAttributes() {
return [
SemanticAttributes.HTTP_ROUTE,
SemanticAttributes.NET_TRANSPORT
]
}
}

View File

@ -5,10 +5,9 @@
package io.opentelemetry.instrumentation.ratpack.server
import io.opentelemetry.api.common.AttributeKey
import io.opentelemetry.instrumentation.ratpack.RatpackTracing
import io.opentelemetry.instrumentation.test.LibraryTestTrait
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import ratpack.server.RatpackServerSpec
class RatpackRoutesTest extends AbstractRatpackRoutesTest implements LibraryTestTrait {
@ -24,11 +23,4 @@ class RatpackRoutesTest extends AbstractRatpackRoutesTest implements LibraryTest
boolean hasHandlerSpan() {
return false
}
@Override
List<AttributeKey<?>> extraAttributes() {
return [
SemanticAttributes.NET_TRANSPORT
]
}
}

View File

@ -5,9 +5,8 @@
package io.opentelemetry.instrumentation.restlet.v1_0
import io.opentelemetry.api.common.AttributeKey
import io.opentelemetry.instrumentation.test.base.HttpServerTest
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import org.restlet.Component
import org.restlet.Context
import org.restlet.Redirector
@ -152,13 +151,6 @@ abstract class AbstractRestletServerTest extends HttpServerTest<Server> {
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.NET_TRANSPORT
]
}
@Override
boolean testPathParam() {
true

View File

@ -46,14 +46,6 @@ abstract class AbstractServletServerTest extends HttpServerTest<Server> {
return jettyServer
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.NET_TRANSPORT,
SemanticAttributes.HTTP_SERVER_NAME
]
}
@Override
void stopServer(Server server) {
server.stop()
@ -70,6 +62,14 @@ abstract class AbstractServletServerTest extends HttpServerTest<Server> {
true
}
@Override
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
Set<AttributeKey<?>> extra = [
SemanticAttributes.HTTP_SERVER_NAME
]
super.httpAttributes(endpoint) + extra
}
@Override
String expectedHttpRoute(ServerEndpoint endpoint) {
switch (endpoint) {

View File

@ -5,9 +5,8 @@
package io.opentelemetry.instrumentation.restlet.v2_0
import io.opentelemetry.api.common.AttributeKey
import io.opentelemetry.instrumentation.test.base.HttpServerTest
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import org.restlet.Component
import org.restlet.Context
import org.restlet.Request
@ -165,13 +164,6 @@ abstract class AbstractRestletServerTest extends HttpServerTest<Server> {
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.NET_TRANSPORT
]
}
@Override
boolean testPathParam() {
true

View File

@ -73,17 +73,10 @@ class JettyServlet2Test extends HttpServerTest<Server> implements AgentTestTrait
@Override
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
def attributes = super.httpAttributes(endpoint)
attributes.remove(SemanticAttributes.HTTP_ROUTE)
attributes
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_TRANSPORT
]
] as Set
}
@Override

View File

@ -72,11 +72,11 @@ abstract class AbstractServlet3Test<SERVER, CONTEXT> extends HttpServerTest<SERV
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_TRANSPORT
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
Set<AttributeKey<?>> extra = [
SemanticAttributes.HTTP_SERVER_NAME
]
super.httpAttributes(endpoint) + extra
}
@Override

View File

@ -3,9 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import io.opentelemetry.api.common.AttributeKey
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import io.opentelemetry.testing.internal.armeria.common.AggregatedHttpResponse
import org.apache.catalina.AccessLog
import org.apache.catalina.Context
@ -41,16 +39,6 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue
@Unroll
abstract class TomcatServlet3Test extends AbstractServlet3Test<Tomcat, Context> {
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_PEER_NAME,
SemanticAttributes.NET_TRANSPORT
]
}
@Override
Class<?> expectedExceptionClass() {
ServletException

View File

@ -80,11 +80,11 @@ abstract class AbstractServlet5Test<SERVER, CONTEXT> extends HttpServerTest<SERV
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_TRANSPORT
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
Set<AttributeKey<?>> extra = [
SemanticAttributes.HTTP_SERVER_NAME
]
super.httpAttributes(endpoint) + extra
}
@Override

View File

@ -42,12 +42,11 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue
abstract class TomcatServlet5Test extends AbstractServlet5Test<Tomcat, Context> {
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_PEER_NAME,
SemanticAttributes.NET_TRANSPORT
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
Set<AttributeKey<?>> extra = [
SemanticAttributes.HTTP_SERVER_NAME
]
super.httpAttributes(endpoint) + extra
}
@Override

View File

@ -36,6 +36,7 @@ public class RouteOnSuccessOrError implements BiConsumer<HandlerFunction<?>, Thr
if (context != null) {
Span serverSpan = ServerSpan.fromContextOrNull(context);
if (serverSpan != null) {
// TODO should update SERVER span name/route using ServerSpanNaming
serverSpan.updateName(ServletContextPath.prepend(context, parseRoute(predicateString)));
}
}

View File

@ -28,6 +28,7 @@ import static io.opentelemetry.api.trace.SpanKind.INTERNAL
import static io.opentelemetry.api.trace.SpanKind.SERVER
import static io.opentelemetry.api.trace.StatusCode.ERROR
import static io.opentelemetry.api.trace.StatusCode.UNSET
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = [SpringWebFluxTestApplication, ForceNettyAutoConfiguration])
class SpringWebfluxTest extends AgentInstrumentationSpecification {
@ -79,6 +80,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
kind SERVER
hasNoParent()
attributes {
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" }
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"
"$SemanticAttributes.NET_PEER_PORT" Long
@ -144,6 +146,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
kind SERVER
hasNoParent()
attributes {
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" }
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"
"$SemanticAttributes.NET_PEER_PORT" Long
@ -229,6 +232,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
kind SERVER
hasNoParent()
attributes {
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" }
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"
"$SemanticAttributes.NET_PEER_PORT" Long
@ -292,6 +296,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
hasNoParent()
status UNSET
attributes {
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" }
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"
"$SemanticAttributes.NET_PEER_PORT" Long
@ -334,6 +339,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
kind SERVER
hasNoParent()
attributes {
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" }
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"
"$SemanticAttributes.NET_PEER_PORT" Long
@ -381,6 +387,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
status ERROR
hasNoParent()
attributes {
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" }
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"
"$SemanticAttributes.NET_PEER_PORT" Long
@ -443,6 +450,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
kind SERVER
hasNoParent()
attributes {
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" }
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"
"$SemanticAttributes.NET_PEER_PORT" Long
@ -473,6 +481,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
kind SERVER
hasNoParent()
attributes {
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" }
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"
"$SemanticAttributes.NET_PEER_PORT" Long
@ -518,6 +527,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
kind SERVER
hasNoParent()
attributes {
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" }
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"
"$SemanticAttributes.NET_PEER_PORT" Long

View File

@ -54,12 +54,11 @@ class SpringBootBasedTest extends HttpServerTest<ConfigurableApplicationContext>
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_PEER_NAME,
SemanticAttributes.NET_TRANSPORT
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
Set<AttributeKey<?>> extra = [
SemanticAttributes.HTTP_SERVER_NAME
]
super.httpAttributes(endpoint) + extra
}
@Override

View File

@ -39,12 +39,11 @@ class ServletFilterTest extends HttpServerTest<ConfigurableApplicationContext> i
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_PEER_NAME,
SemanticAttributes.NET_TRANSPORT
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
Set<AttributeKey<?>> extra = [
SemanticAttributes.HTTP_SERVER_NAME
]
super.httpAttributes(endpoint) + extra
}
@Override

View File

@ -30,11 +30,11 @@ import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEn
class Struts2ActionSpanTest extends HttpServerTest<Server> implements AgentTestTrait {
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_TRANSPORT
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
Set<AttributeKey<?>> extra = [
SemanticAttributes.HTTP_SERVER_NAME
]
super.httpAttributes(endpoint) + extra
}
@Override

View File

@ -110,12 +110,11 @@ class TomcatAsyncTest extends HttpServerTest<Tomcat> implements AgentTestTrait {
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_PEER_NAME,
SemanticAttributes.NET_TRANSPORT
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
Set<AttributeKey<?>> extra = [
SemanticAttributes.HTTP_SERVER_NAME
]
super.httpAttributes(endpoint) + extra
}
@Override

View File

@ -75,12 +75,11 @@ class TomcatHandlerTest extends HttpServerTest<Tomcat> implements AgentTestTrait
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_PEER_NAME,
SemanticAttributes.NET_TRANSPORT
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
Set<AttributeKey<?>> extra = [
SemanticAttributes.HTTP_SERVER_NAME
]
super.httpAttributes(endpoint) + extra
}
@Override

View File

@ -110,12 +110,11 @@ class TomcatAsyncTest extends HttpServerTest<Tomcat> implements AgentTestTrait {
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_PEER_NAME,
SemanticAttributes.NET_TRANSPORT
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
Set<AttributeKey<?>> extra = [
SemanticAttributes.HTTP_SERVER_NAME
]
super.httpAttributes(endpoint) + extra
}
@Override

View File

@ -75,12 +75,11 @@ class TomcatHandlerTest extends HttpServerTest<Tomcat> implements AgentTestTrait
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_SERVER_NAME,
SemanticAttributes.NET_PEER_NAME,
SemanticAttributes.NET_TRANSPORT
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
Set<AttributeKey<?>> extra = [
SemanticAttributes.HTTP_SERVER_NAME
]
super.httpAttributes(endpoint) + extra
}
@Override

View File

@ -100,6 +100,7 @@ class UndertowServerDispatchTest extends HttpServerTest<Undertow> implements Age
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
def attributes = super.httpAttributes(endpoint)
attributes.remove(SemanticAttributes.HTTP_ROUTE)
attributes.add(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH)
attributes
}
@ -107,13 +108,4 @@ class UndertowServerDispatchTest extends HttpServerTest<Undertow> implements Age
String expectedServerSpanName(ServerEndpoint endpoint) {
return "HTTP GET"
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH,
SemanticAttributes.NET_PEER_NAME,
SemanticAttributes.NET_TRANSPORT
]
}
}

View File

@ -109,6 +109,7 @@ class UndertowServerTest extends HttpServerTest<Undertow> implements AgentTestTr
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
def attributes = super.httpAttributes(endpoint)
attributes.remove(SemanticAttributes.HTTP_ROUTE)
attributes.add(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH)
attributes
}
@ -117,15 +118,6 @@ class UndertowServerTest extends HttpServerTest<Undertow> implements AgentTestTr
return "HTTP GET"
}
@Override
List<AttributeKey<?>> extraAttributes() {
[
SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH,
SemanticAttributes.NET_PEER_NAME,
SemanticAttributes.NET_TRANSPORT
]
}
def "test send response"() {
setup:
def uri = address.resolve("sendResponse")

View File

@ -24,6 +24,7 @@ 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.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP
class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
@Shared
@ -62,6 +63,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
kind SERVER
hasNoParent()
attributes {
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" }
"$SemanticAttributes.NET_PEER_PORT" Long
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"
@ -151,6 +153,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
kind SERVER
childOf(span(0))
attributes {
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" }
"$SemanticAttributes.NET_PEER_PORT" Long
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"

View File

@ -24,6 +24,7 @@ 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.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP
class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
@Shared
@ -62,6 +63,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
kind SERVER
hasNoParent()
attributes {
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" }
"$SemanticAttributes.NET_PEER_PORT" Long
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"
@ -151,6 +153,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
kind SERVER
childOf(span(0))
attributes {
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" }
"$SemanticAttributes.NET_PEER_PORT" Long
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"

View File

@ -159,12 +159,12 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
/** A list of additional HTTP server span attributes extracted by the instrumentation per URI. */
Set<AttributeKey<?>> httpAttributes(ServerEndpoint endpoint) {
[SemanticAttributes.HTTP_ROUTE] as Set
}
// TODO: remove that method and use httpAttributes everywhere; similar to HttpClientTest
List<AttributeKey<?>> extraAttributes() {
[]
[
SemanticAttributes.HTTP_ROUTE,
SemanticAttributes.NET_TRANSPORT,
SemanticAttributes.NET_PEER_NAME,
SemanticAttributes.NET_PEER_PORT
] as Set
}
enum ServerEndpoint {
@ -663,7 +663,7 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
// parent span must be cast otherwise it breaks debugging classloading (junit loads it early)
void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) {
def httpAttributes = extraAttributes() + this.httpAttributes(endpoint)
def httpAttributes = this.httpAttributes(endpoint)
trace.span(index) {
name expectedServerSpanName(endpoint)
kind SpanKind.SERVER // can't use static import because of SERVER type parameter
@ -690,10 +690,19 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
if (httpAttributes.contains(SemanticAttributes.NET_TRANSPORT)) {
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
}
// net.peer.name resolves to "127.0.0.1" on windows which is same as net.peer.ip so then not captured
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == address.host }
"$SemanticAttributes.NET_PEER_PORT" { it == null || (it instanceof Long && it != port) }
"$SemanticAttributes.NET_PEER_IP" { it == null || it == peerIp(endpoint) } // Optional
if (httpAttributes.contains(SemanticAttributes.NET_PEER_NAME)) {
// net.peer.name resolves to "127.0.0.1" on windows which is same as net.peer.ip so then not captured
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == address.host }
}
if (httpAttributes.contains(SemanticAttributes.NET_PEER_PORT)) {
"$SemanticAttributes.NET_PEER_PORT" { (it instanceof Long && it.intValue() != port) }
}
if (httpAttributes.contains(SemanticAttributes.NET_PEER_IP)) {
"$SemanticAttributes.NET_PEER_IP" { it == peerIp(endpoint) }
} else {
"$SemanticAttributes.NET_PEER_IP" { it == null || it == peerIp(endpoint) }
// Optional
}
"$SemanticAttributes.HTTP_CLIENT_IP" { it == null || it == TEST_CLIENT_IP }
"$SemanticAttributes.HTTP_METHOD" method
@ -701,8 +710,8 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
"$SemanticAttributes.HTTP_FLAVOR" { it == "1.1" || it == "2.0" }
"$SemanticAttributes.HTTP_USER_AGENT" TEST_USER_AGENT
"$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" }
"$SemanticAttributes.HTTP_SCHEME" "http"
"$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" }
"$SemanticAttributes.HTTP_TARGET" endpoint.resolvePath(address).getPath() + "${endpoint == QUERY_PARAM ? "?${endpoint.body}" : ""}"
if (httpAttributes.contains(SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH)) {
@ -737,7 +746,7 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
void indexedServerSpan(TraceAssert trace, Object parent, int requestId) {
ServerEndpoint endpoint = INDEXED_CHILD
def httpAttributes = extraAttributes() + this.httpAttributes(endpoint)
def httpAttributes = this.httpAttributes(endpoint)
trace.span(1) {
name expectedServerSpanName(endpoint)
kind SpanKind.SERVER // can't use static import because of SERVER type parameter
@ -746,10 +755,19 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
if (httpAttributes.contains(SemanticAttributes.NET_TRANSPORT)) {
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
}
// net.peer.name resolves to "127.0.0.1" on windows which is same as net.peer.ip so then not captured
"$SemanticAttributes.NET_PEER_NAME" { (it == null || it == address.host) }
"$SemanticAttributes.NET_PEER_PORT" { it == null || it instanceof Long }
"$SemanticAttributes.NET_PEER_IP" { it == null || it == peerIp(endpoint) } // Optional
if (httpAttributes.contains(SemanticAttributes.NET_PEER_NAME)) {
// net.peer.name resolves to "127.0.0.1" on windows which is same as net.peer.ip so then not captured
"$SemanticAttributes.NET_PEER_NAME" { it == null || it == address.host }
}
if (httpAttributes.contains(SemanticAttributes.NET_PEER_PORT)) {
"$SemanticAttributes.NET_PEER_PORT" { (it instanceof Long && it.intValue() != port) }
}
if (httpAttributes.contains(SemanticAttributes.NET_PEER_IP)) {
"$SemanticAttributes.NET_PEER_IP" { it == peerIp(endpoint) }
} else {
"$SemanticAttributes.NET_PEER_IP" { it == null || it == peerIp(endpoint) }
// Optional
}
"$SemanticAttributes.HTTP_CLIENT_IP" { it == null || it == TEST_CLIENT_IP }
"$SemanticAttributes.HTTP_METHOD" "GET"