Fix some tests on windows
MODIFY
instrumentation/grpc-1.6/testing/src/main/groovy/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcStreamingTest.groovy
instrumentation/grpc-1.6/testing/src/main/groovy/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcStreamingTest.groovy
@@ -137,8 +137,8 @@ abstract class AbstractGrpcStreamingTest extends InstrumentationSpecification {
"${SemanticAttributes.RPC_SERVICE.key}" "example.Greeter"
"${SemanticAttributes.RPC_METHOD.key}" "Conversation"
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
- // "localhost" on linux, "127.0.0.1" on windows
- "${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == "127.0.0.1" }
+ // 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.key}" { it == "localhost" || it == null }
"${SemanticAttributes.NET_PEER_PORT.key}" Long
"${SemanticAttributes.NET_TRANSPORT.key}" SemanticAttributes.NetTransportValues.IP_TCP
"${SemanticAttributes.RPC_GRPC_STATUS_CODE.key}" Status.OK.code.value()

MODIFY
instrumentation/grpc-1.6/testing/src/main/groovy/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.groovy
instrumentation/grpc-1.6/testing/src/main/groovy/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.groovy
@@ -141,8 +141,8 @@ abstract class AbstractGrpcTest extends InstrumentationSpecification {
"${SemanticAttributes.RPC_SERVICE.key}" "example.Greeter"
"${SemanticAttributes.RPC_METHOD.key}" "SayHello"
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
- // "localhost" on linux, "127.0.0.1" on windows
- "${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == "127.0.0.1" }
+ // 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.key}" { it == "localhost" || it == null }
"${SemanticAttributes.NET_PEER_PORT.key}" Long
"${SemanticAttributes.NET_TRANSPORT.key}" SemanticAttributes.NetTransportValues.IP_TCP
"${SemanticAttributes.RPC_GRPC_STATUS_CODE.key}" Status.Code.OK.value()
@@ -261,8 +261,8 @@ abstract class AbstractGrpcTest extends InstrumentationSpecification {
"${SemanticAttributes.RPC_SERVICE.key}" "example.Greeter"
"${SemanticAttributes.RPC_METHOD.key}" "SayHello"
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
- // "localhost" on linux, "127.0.0.1" on windows
- "${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == "127.0.0.1" }
+ // 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.key}" { it == "localhost" || it == null }
"${SemanticAttributes.NET_PEER_PORT.key}" Long
"${SemanticAttributes.NET_TRANSPORT.key}" SemanticAttributes.NetTransportValues.IP_TCP
"${SemanticAttributes.RPC_GRPC_STATUS_CODE.key}" Status.Code.OK.value()
@@ -394,8 +394,8 @@ abstract class AbstractGrpcTest extends InstrumentationSpecification {
"${SemanticAttributes.RPC_SERVICE.key}" "example.Greeter"
"${SemanticAttributes.RPC_METHOD.key}" "SayHello"
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
- // "localhost" on linux, "127.0.0.1" on windows
- "${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == "127.0.0.1" }
+ // 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.key}" { it == "localhost" || it == null }
"${SemanticAttributes.NET_PEER_PORT.key}" Long
"${SemanticAttributes.NET_TRANSPORT.key}" SemanticAttributes.NetTransportValues.IP_TCP
"${SemanticAttributes.RPC_GRPC_STATUS_CODE.key}" Status.Code.OK.value()
@@ -487,8 +487,8 @@ abstract class AbstractGrpcTest extends InstrumentationSpecification {
"${SemanticAttributes.RPC_SERVICE.key}" "example.Greeter"
"${SemanticAttributes.RPC_METHOD.key}" "SayHello"
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
- // "localhost" on linux, "127.0.0.1" on windows
- "${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == "127.0.0.1" }
+ // 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.key}" { it == "localhost" || it == null }
"${SemanticAttributes.NET_PEER_PORT.key}" Long
"${SemanticAttributes.NET_TRANSPORT}" SemanticAttributes.NetTransportValues.IP_TCP
"${SemanticAttributes.RPC_GRPC_STATUS_CODE}" grpcStatus.code.value()
@@ -585,8 +585,8 @@ abstract class AbstractGrpcTest extends InstrumentationSpecification {
"${SemanticAttributes.RPC_SERVICE.key}" "example.Greeter"
"${SemanticAttributes.RPC_METHOD.key}" "SayHello"
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
- // "localhost" on linux, "127.0.0.1" on windows
- "${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == "127.0.0.1" }
+ // 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.key}" { it == "localhost" || it == null }
"${SemanticAttributes.NET_PEER_PORT.key}" Long
"${SemanticAttributes.NET_TRANSPORT.key}" SemanticAttributes.NetTransportValues.IP_TCP
}
@@ -765,8 +765,8 @@ abstract class AbstractGrpcTest extends InstrumentationSpecification {
"${SemanticAttributes.RPC_SERVICE.key}" "example.Greeter"
"${SemanticAttributes.RPC_METHOD.key}" "SayHello"
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
- // "localhost" on linux, "127.0.0.1" on windows
- "${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == "127.0.0.1" }
+ // 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.key}" { it == "localhost" || it == null }
"${SemanticAttributes.NET_PEER_PORT.key}" Long
"${SemanticAttributes.NET_TRANSPORT.key}" SemanticAttributes.NetTransportValues.IP_TCP
"${SemanticAttributes.RPC_GRPC_STATUS_CODE.key}" Status.OK.code.value()
@@ -896,8 +896,8 @@ abstract class AbstractGrpcTest extends InstrumentationSpecification {
"${SemanticAttributes.RPC_SERVICE.key}" "example.Greeter"
"${SemanticAttributes.RPC_METHOD.key}" "SayHello"
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
- // "localhost" on linux, "127.0.0.1" on windows
- "${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == "127.0.0.1" }
+ // 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.key}" { it == "localhost" || it == null }
"${SemanticAttributes.NET_PEER_PORT.key}" Long
"${SemanticAttributes.NET_TRANSPORT.key}" SemanticAttributes.NetTransportValues.IP_TCP
}
@@ -1010,8 +1010,8 @@ abstract class AbstractGrpcTest extends InstrumentationSpecification {
"${SemanticAttributes.RPC_SERVICE.key}" "grpc.reflection.v1alpha.ServerReflection"
"${SemanticAttributes.RPC_METHOD.key}" "ServerReflectionInfo"
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
- // "localhost" on linux, "127.0.0.1" on windows
- "${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == "127.0.0.1" }
+ // 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.key}" { it == "localhost" || it == null }
"${SemanticAttributes.NET_PEER_PORT.key}" Long
"${SemanticAttributes.NET_TRANSPORT.key}" SemanticAttributes.NetTransportValues.IP_TCP
"${SemanticAttributes.RPC_GRPC_STATUS_CODE.key}" Status.OK.code.value()
@@ -1118,7 +1118,8 @@ abstract class AbstractGrpcTest extends InstrumentationSpecification {
"${SemanticAttributes.RPC_SERVICE.key}" "example.Greeter"
"${SemanticAttributes.RPC_METHOD.key}" "SayHello"
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
- "${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == "127.0.0.1" }
+ // 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.key}" { it == "localhost" || it == null }
"${SemanticAttributes.NET_PEER_PORT.key}" Long
"${SemanticAttributes.NET_TRANSPORT.key}" SemanticAttributes.NetTransportValues.IP_TCP
"${SemanticAttributes.RPC_GRPC_STATUS_CODE.key}" Status.Code.OK.value()

MODIFY
instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy
instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy
@@ -145,8 +145,8 @@ class UndertowServerTest extends HttpServerTest<Undertow> implements AgentTestTr
"${SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH}" Long
"${SemanticAttributes.HTTP_SCHEME}" "http"
"${SemanticAttributes.HTTP_TARGET}" "/sendResponse"
- // "localhost" on linux, "127.0.0.1" on windows
- "${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == "127.0.0.1" }
+ // 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.key}" { it == "localhost" || it == null }
"${SemanticAttributes.NET_TRANSPORT}" SemanticAttributes.NetTransportValues.IP_TCP
}
}
@@ -200,8 +200,8 @@ class UndertowServerTest extends HttpServerTest<Undertow> implements AgentTestTr
"${SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH}" Long
"${SemanticAttributes.HTTP_SCHEME}" "http"
"${SemanticAttributes.HTTP_TARGET}" "/sendResponseWithException"
- // "localhost" on linux, "127.0.0.1" on windows
- "${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == "127.0.0.1" }
+ // 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.key}" { it == "localhost" || it == null }
"${SemanticAttributes.NET_TRANSPORT}" SemanticAttributes.NetTransportValues.IP_TCP
}
}

MODIFY
testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy
testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy
@@ -598,8 +598,8 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
"${SemanticAttributes.HTTP_SERVER_NAME}" String
}
if (extraAttributes.contains(SemanticAttributes.NET_PEER_NAME)) {
- // "localhost" on linux, "127.0.0.1" on windows
- "${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == "127.0.0.1" }
+ // 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.key}" { it == "localhost" || it == null }
}
if (extraAttributes.contains(SemanticAttributes.NET_TRANSPORT)) {
"${SemanticAttributes.NET_TRANSPORT}" IP_TCP

Fix some tests on windows (#4288)