Use containerIpAddress instead of hard-coded 127.0.0.1 in rabbit tests (#4745)
* Use containerIpAddress instead of hard-coded 127.0.0.1 in rabbit tests * Fix a situation where testcontainers returns 'localhost' instead of IP * Fix a situation where testcontainers returns 'localhost' instead of IP * Don't use the getContainerIpAddress() method, it'll be deprecated anyways
This commit is contained in:
parent
95f3d37b3f
commit
f948ef8051
|
@ -23,6 +23,7 @@ import org.springframework.amqp.rabbit.connection.CachingConnectionFactory
|
|||
import org.springframework.amqp.rabbit.core.RabbitAdmin
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate
|
||||
|
||||
import static com.google.common.net.InetAddresses.isInetAddress
|
||||
import static io.opentelemetry.api.trace.SpanKind.CLIENT
|
||||
import static io.opentelemetry.api.trace.SpanKind.CONSUMER
|
||||
import static io.opentelemetry.api.trace.SpanKind.PRODUCER
|
||||
|
@ -340,7 +341,7 @@ class RabbitMqTest extends AgentInstrumentationSpecification implements WithRabb
|
|||
|
||||
attributes {
|
||||
"${SemanticAttributes.NET_PEER_NAME.key}" { it == null || it instanceof String }
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" { "127.0.0.1" }
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" { it == null || isInetAddress(it as String) }
|
||||
"${SemanticAttributes.NET_PEER_PORT.key}" { it == null || it instanceof Long }
|
||||
|
||||
"${SemanticAttributes.MESSAGING_SYSTEM.key}" "rabbitmq"
|
||||
|
|
|
@ -10,6 +10,8 @@ import reactor.rabbitmq.ExchangeSpecification
|
|||
import reactor.rabbitmq.RabbitFlux
|
||||
import reactor.rabbitmq.SenderOptions
|
||||
|
||||
import static com.google.common.net.InetAddresses.isInetAddress
|
||||
|
||||
class ReactorRabbitMqTest extends AgentInstrumentationSpecification implements WithRabbitMqTrait {
|
||||
|
||||
def setupSpec() {
|
||||
|
@ -38,7 +40,7 @@ class ReactorRabbitMqTest extends AgentInstrumentationSpecification implements W
|
|||
kind SpanKind.CLIENT
|
||||
attributes {
|
||||
"${SemanticAttributes.NET_PEER_NAME.key}" { it == null || it instanceof String }
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" String
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" { isInetAddress(it as String) }
|
||||
"${SemanticAttributes.NET_PEER_PORT.key}" { it == null || it instanceof Long }
|
||||
"${SemanticAttributes.MESSAGING_SYSTEM.key}" "rabbitmq"
|
||||
"${SemanticAttributes.MESSAGING_DESTINATION_KIND.key}" "queue"
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
|
||||
|
||||
import static com.google.common.net.InetAddresses.isInetAddress
|
||||
import static io.opentelemetry.api.trace.SpanKind.CLIENT
|
||||
import static io.opentelemetry.api.trace.SpanKind.CONSUMER
|
||||
import static io.opentelemetry.api.trace.SpanKind.PRODUCER
|
||||
|
@ -48,7 +49,7 @@ class SpringIntegrationAndRabbitTest extends AgentInstrumentationSpecification i
|
|||
kind CLIENT
|
||||
attributes {
|
||||
"${SemanticAttributes.NET_PEER_NAME.key}" { it == null || it == "localhost" }
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" { isInetAddress(it as String) }
|
||||
"${SemanticAttributes.NET_PEER_PORT.key}" { it == null || it instanceof Long }
|
||||
"${SemanticAttributes.MESSAGING_SYSTEM.key}" "rabbitmq"
|
||||
"${SemanticAttributes.MESSAGING_DESTINATION_KIND.key}" "queue"
|
||||
|
@ -62,7 +63,7 @@ class SpringIntegrationAndRabbitTest extends AgentInstrumentationSpecification i
|
|||
attributes {
|
||||
// "localhost" on linux, null on windows
|
||||
"${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == null }
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" { isInetAddress(it as String) }
|
||||
"${SemanticAttributes.NET_PEER_PORT.key}" Long
|
||||
"${SemanticAttributes.MESSAGING_SYSTEM.key}" "rabbitmq"
|
||||
"${SemanticAttributes.MESSAGING_DESTINATION.key}" "testTopic"
|
||||
|
@ -117,7 +118,7 @@ class SpringIntegrationAndRabbitTest extends AgentInstrumentationSpecification i
|
|||
attributes {
|
||||
// "localhost" on linux, null on windows
|
||||
"${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == null }
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" { isInetAddress(it as String) }
|
||||
"${SemanticAttributes.NET_PEER_PORT.key}" Long
|
||||
"${SemanticAttributes.MESSAGING_SYSTEM.key}" "rabbitmq"
|
||||
"${SemanticAttributes.MESSAGING_DESTINATION_KIND.key}" "queue"
|
||||
|
|
|
@ -19,6 +19,7 @@ import spock.lang.Shared
|
|||
|
||||
import java.time.Duration
|
||||
|
||||
import static com.google.common.net.InetAddresses.isInetAddress
|
||||
import static io.opentelemetry.api.trace.SpanKind.CLIENT
|
||||
import static io.opentelemetry.api.trace.SpanKind.CONSUMER
|
||||
import static io.opentelemetry.api.trace.SpanKind.PRODUCER
|
||||
|
@ -84,7 +85,7 @@ class ContextPropagationTest extends AgentInstrumentationSpecification {
|
|||
attributes {
|
||||
// "localhost" on linux, null on windows
|
||||
"${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == null }
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" { isInetAddress(it as String) }
|
||||
"${SemanticAttributes.NET_PEER_PORT.key}" Long
|
||||
"${SemanticAttributes.MESSAGING_SYSTEM.key}" "rabbitmq"
|
||||
"${SemanticAttributes.MESSAGING_DESTINATION.key}" "<default>"
|
||||
|
@ -135,7 +136,7 @@ class ContextPropagationTest extends AgentInstrumentationSpecification {
|
|||
attributes {
|
||||
// "localhost" on linux, null on windows
|
||||
"${SemanticAttributes.NET_PEER_NAME.key}" { it == "localhost" || it == null }
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" { isInetAddress(it as String) }
|
||||
"${SemanticAttributes.NET_PEER_PORT.key}" Long
|
||||
"${SemanticAttributes.MESSAGING_SYSTEM.key}" "rabbitmq"
|
||||
"${SemanticAttributes.MESSAGING_DESTINATION_KIND.key}" "queue"
|
||||
|
|
|
@ -45,11 +45,12 @@ dependencies {
|
|||
// Needs to be api dependency due to Spock restriction.
|
||||
api("org.awaitility:awaitility")
|
||||
|
||||
api("com.google.guava:guava")
|
||||
|
||||
compileOnly(project(path = ":testing:armeria-shaded-for-testing", configuration = "shadow"))
|
||||
|
||||
implementation("io.opentelemetry.proto:opentelemetry-proto")
|
||||
|
||||
implementation("com.google.guava:guava")
|
||||
implementation("net.bytebuddy:byte-buddy")
|
||||
implementation("org.slf4j:slf4j-api")
|
||||
implementation("ch.qos.logback:logback-classic")
|
||||
|
|
Loading…
Reference in New Issue