@@ -115,6 +115,12 @@ void testCassandra() {
115115 CamelContext camelContext = appContext .getBean (CamelContext .class );
116116 ProducerTemplate template = camelContext .createProducerTemplate ();
117117
118+ // warm up: force the cassandra session initialization (including "USE keyspace")
119+ // so that the keyspace-switching span doesn't interfere with the test assertion
120+ template .requestBody ("direct:input" , (Object ) null );
121+ testing .waitForTraces (1 );
122+ testing .clearData ();
123+
118124 template .requestBody ("direct:input" , (Object ) null );
119125
120126 if (emitStableDatabaseSemconv ()) {
@@ -142,22 +148,7 @@ void testCassandra() {
142148 equalTo (
143149 DB_QUERY_TEXT ,
144150 "select * from test.users where id=1 ALLOW FILTERING" ),
145- equalTo (DB_QUERY_SUMMARY , "SELECT test.users" ))),
146- trace ->
147- trace .hasSpansSatisfyingExactly (
148- span ->
149- span .hasName ("USE test" )
150- .hasKind (SpanKind .CLIENT )
151- .hasAttributesSatisfyingExactly (
152- satisfies (NETWORK_TYPE , val -> val .isInstanceOf (String .class )),
153- equalTo (SERVER_ADDRESS , host ),
154- equalTo (SERVER_PORT , cassandraPort ),
155- satisfies (
156- NETWORK_PEER_ADDRESS , val -> val .isInstanceOf (String .class )),
157- equalTo (NETWORK_PEER_PORT , cassandraPort ),
158- equalTo (DB_SYSTEM_NAME , "cassandra" ),
159- equalTo (DB_QUERY_TEXT , "USE test" ),
160- equalTo (DB_QUERY_SUMMARY , "USE test" ))));
151+ equalTo (DB_QUERY_SUMMARY , "SELECT test.users" ))));
161152 } else {
162153 testing .waitAndAssertTraces (
163154 trace ->
@@ -185,10 +176,7 @@ void testCassandra() {
185176 span ->
186177 span .hasName ("SELECT test.users" )
187178 .hasKind (SpanKind .CLIENT )
188- .hasParent (trace .getSpan (1 ))),
189- trace ->
190- trace .hasSpansSatisfyingExactly (
191- span -> span .hasName ("DB Query" ).hasKind (SpanKind .CLIENT )));
179+ .hasParent (trace .getSpan (1 ))));
192180 }
193181 }
194182}
0 commit comments