3333import io .opentelemetry .api .common .AttributeKey ;
3434import io .opentelemetry .api .common .Attributes ;
3535import io .opentelemetry .api .trace .SpanKind ;
36+ import io .opentelemetry .instrumentation .api .internal .SemconvStability ;
3637import io .opentelemetry .instrumentation .test .utils .PortUtils ;
38+ import io .opentelemetry .sdk .testing .assertj .AttributeAssertion ;
3739import io .opentelemetry .sdk .trace .data .StatusData ;
3840import java .net .InetAddress ;
3941import java .net .UnknownHostException ;
42+ import java .util .ArrayList ;
43+ import java .util .Arrays ;
44+ import java .util .List ;
4045import java .util .Map ;
4146import java .util .concurrent .CancellationException ;
4247import java .util .concurrent .CompletableFuture ;
@@ -413,6 +418,17 @@ void testCommandCompletesExceptionally() {
413418 assertThat (completedExceptionally ).isTrue ();
414419 });
415420
421+ List <AttributeAssertion > assertions =
422+ new ArrayList <>(
423+ Arrays .asList (
424+ equalTo (maybeStable (DB_SYSTEM ), "redis" ),
425+ equalTo (maybeStable (DB_STATEMENT ), "DEL key1 key2" ),
426+ equalTo (maybeStable (DB_OPERATION ), "DEL" )));
427+
428+ if (SemconvStability .emitStableDatabaseSemconv ()) {
429+ assertions .add (equalTo (ERROR_TYPE , "java.lang.IllegalStateException" ));
430+ }
431+
416432 testing .waitAndAssertTraces (
417433 trace ->
418434 trace .hasSpansSatisfyingExactly (
@@ -421,11 +437,7 @@ void testCommandCompletesExceptionally() {
421437 .hasKind (SpanKind .CLIENT )
422438 .hasStatus (StatusData .error ())
423439 .hasException (new IllegalStateException ("TestException" ))
424- .hasAttributesSatisfyingExactly (
425- equalTo (maybeStable (DB_SYSTEM ), "redis" ),
426- equalTo (maybeStable (DB_STATEMENT ), "DEL key1 key2" ),
427- equalTo (maybeStable (DB_OPERATION ), "DEL" ),
428- equalTo (ERROR_TYPE , "java.lang.IllegalStateException" ))));
440+ .hasAttributesSatisfyingExactly (assertions )));
429441 }
430442
431443 @ Test
0 commit comments