55
66package io .opentelemetry .javaagent .instrumentation .rabbitmq ;
77
8- import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .assertThat ;
8+ import static io .opentelemetry .api .common .AttributeKey .stringKey ;
9+ import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .equalTo ;
10+ import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .satisfies ;
911import static io .opentelemetry .semconv .NetworkAttributes .NETWORK_PEER_ADDRESS ;
1012import static io .opentelemetry .semconv .NetworkAttributes .NETWORK_PEER_PORT ;
1113import static io .opentelemetry .semconv .NetworkAttributes .NETWORK_TYPE ;
1214import static io .opentelemetry .semconv .incubating .MessagingIncubatingAttributes .MESSAGING_SYSTEM ;
13- import static org .junit .jupiter .api .Assertions .assertNotNull ;
15+ import static io .opentelemetry .semconv .incubating .MessagingIncubatingAttributes .MessagingSystemIncubatingValues .RABBITMQ ;
16+ import static org .assertj .core .api .Assertions .assertThat ;
1417
15- import io .opentelemetry .api .common .AttributeKey ;
1618import io .opentelemetry .api .trace .SpanKind ;
1719import io .opentelemetry .instrumentation .testing .junit .AgentInstrumentationExtension ;
1820import io .opentelemetry .instrumentation .testing .junit .InstrumentationExtension ;
19- import org .junit .jupiter .api .Assertions ;
2021import org .junit .jupiter .api .Test ;
22+ import org .junit .jupiter .api .condition .DisabledIfSystemProperty ;
2123import org .junit .jupiter .api .extension .RegisterExtension ;
2224import reactor .rabbitmq .ExchangeSpecification ;
2325import reactor .rabbitmq .RabbitFlux ;
2426import reactor .rabbitmq .Sender ;
2527import reactor .rabbitmq .SenderOptions ;
2628
29+ @ DisabledIfSystemProperty (
30+ named = "testLatestDeps" ,
31+ matches = "true" ,
32+ disabledReason =
33+ "reactor-rabbitmq 1.5.6 (and earlier) still calls `void useNio()` which was removed in 5.27.0" )
2734class ReactorRabbitMqTest extends AbstractRabbitMqTest {
2835 @ RegisterExtension
2936 private static final InstrumentationExtension testing = AgentInstrumentationExtension .create ();
@@ -33,33 +40,24 @@ void testShouldNotFailDeclaringExchange() {
3340 Sender sender =
3441 RabbitFlux .createSender (new SenderOptions ().connectionFactory (connectionFactory ));
3542
36- try {
37- sender .declareExchange (ExchangeSpecification .exchange ("testExchange" )).block ();
38- } catch (RuntimeException e ) {
39- Assertions .fail ("Should not fail declaring exchange" , e );
40- }
43+ sender .declareExchange (ExchangeSpecification .exchange ("testExchange" )).block ();
4144
4245 testing .waitAndAssertTraces (
4346 trace ->
4447 trace .hasSpansSatisfyingExactly (
45- span -> {
46- span .hasName ("exchange.declare" )
47- .hasKind (SpanKind .CLIENT )
48- .hasAttribute (MESSAGING_SYSTEM , "rabbitmq" )
49- .hasAttribute (AttributeKey .stringKey ("rabbitmq.command" ), "exchange.declare" )
50- .hasAttributesSatisfying (
51- attributes ->
52- assertThat (attributes )
53- .satisfies (
54- attrs -> {
55- String peerAddr = attrs .get (NETWORK_PEER_ADDRESS );
56- assertThat (peerAddr ).isIn (rabbitMqIp , null );
57-
58- String networkType = attrs .get (NETWORK_TYPE );
59- assertThat (networkType ).isIn ("ipv4" , "ipv6" , null );
60-
61- assertNotNull (attrs .get (NETWORK_PEER_PORT ));
62- }));
63- }));
48+ span ->
49+ span .hasName ("exchange.declare" )
50+ .hasKind (SpanKind .CLIENT )
51+ .hasAttributesSatisfyingExactly (
52+ equalTo (MESSAGING_SYSTEM , RABBITMQ ),
53+ equalTo (stringKey ("rabbitmq.command" ), "exchange.declare" ),
54+ satisfies (
55+ NETWORK_PEER_ADDRESS ,
56+ addr -> addr .satisfies (a -> assertThat (a ).isIn (rabbitMqIp , null ))),
57+ satisfies (
58+ NETWORK_TYPE ,
59+ type ->
60+ type .satisfies (t -> assertThat (t ).isIn ("ipv4" , "ipv6" , null ))),
61+ satisfies (NETWORK_PEER_PORT , port -> assertThat (port ).isNotNull ()))));
6462 }
6563}
0 commit comments