-
Notifications
You must be signed in to change notification settings - Fork 905
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix UnsupportedOperationException happening when reactor-rabbitmq is …
…used (#3381)
- Loading branch information
Mateusz Rzeszutek
authored
Jun 22, 2021
1 parent
0788a03
commit 2c2c19d
Showing
5 changed files
with
96 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
instrumentation/rabbitmq-2.7/javaagent/src/test/groovy/ReactorRabbitMqTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import io.opentelemetry.api.trace.SpanKind | ||
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification | ||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes | ||
import reactor.rabbitmq.ExchangeSpecification | ||
import reactor.rabbitmq.RabbitFlux | ||
import reactor.rabbitmq.SenderOptions | ||
|
||
class ReactorRabbitMqTest extends AgentInstrumentationSpecification implements WithRabbitMqTrait { | ||
|
||
def setupSpec() { | ||
startRabbit() | ||
} | ||
|
||
def cleanupSpec() { | ||
stopRabbit() | ||
} | ||
|
||
def "should not fail declaring exchange"() { | ||
given: | ||
def sender = RabbitFlux.createSender(new SenderOptions().connectionFactory(connectionFactory)) | ||
|
||
when: | ||
sender.declareExchange(ExchangeSpecification.exchange("testExchange")) | ||
.block() | ||
|
||
then: | ||
noExceptionThrown() | ||
|
||
assertTraces(1) { | ||
trace(0, 1) { | ||
span(0) { | ||
name 'exchange.declare' | ||
kind SpanKind.CLIENT | ||
attributes { | ||
"${SemanticAttributes.NET_PEER_NAME.key}" { it == null || it instanceof String } | ||
"${SemanticAttributes.NET_PEER_IP.key}" String | ||
"${SemanticAttributes.NET_PEER_PORT.key}" { it == null || it instanceof Long } | ||
"${SemanticAttributes.MESSAGING_SYSTEM.key}" "rabbitmq" | ||
"${SemanticAttributes.MESSAGING_DESTINATION_KIND.key}" "queue" | ||
"rabbitmq.command" "exchange.declare" | ||
} | ||
} | ||
} | ||
} | ||
|
||
cleanup: | ||
sender?.close() | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
instrumentation/rabbitmq-2.7/javaagent/src/test/groovy/WithRabbitMqTrait.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import com.rabbitmq.client.ConnectionFactory | ||
import java.time.Duration | ||
import org.testcontainers.containers.GenericContainer | ||
|
||
trait WithRabbitMqTrait { | ||
|
||
static GenericContainer rabbitMqContainer | ||
static ConnectionFactory connectionFactory | ||
|
||
def startRabbit() { | ||
rabbitMqContainer = new GenericContainer('rabbitmq:latest') | ||
.withExposedPorts(5672) | ||
.withStartupTimeout(Duration.ofSeconds(120)) | ||
rabbitMqContainer.start() | ||
|
||
connectionFactory = new ConnectionFactory( | ||
host: rabbitMqContainer.containerIpAddress, | ||
port: rabbitMqContainer.getMappedPort(5672) | ||
) | ||
} | ||
|
||
def stopRabbit() { | ||
rabbitMqContainer?.stop() | ||
} | ||
} |