33
33
import io .opentelemetry .api .common .AttributeKey ;
34
34
import io .opentelemetry .api .common .Attributes ;
35
35
import io .opentelemetry .api .trace .SpanKind ;
36
+ import io .opentelemetry .instrumentation .api .internal .SemconvStability ;
36
37
import io .opentelemetry .instrumentation .test .utils .PortUtils ;
38
+ import io .opentelemetry .sdk .testing .assertj .AttributeAssertion ;
37
39
import io .opentelemetry .sdk .trace .data .StatusData ;
38
40
import java .net .InetAddress ;
39
41
import java .net .UnknownHostException ;
42
+ import java .util .ArrayList ;
43
+ import java .util .Arrays ;
44
+ import java .util .List ;
40
45
import java .util .Map ;
41
46
import java .util .concurrent .CancellationException ;
42
47
import java .util .concurrent .CompletableFuture ;
@@ -413,6 +418,17 @@ void testCommandCompletesExceptionally() {
413
418
assertThat (completedExceptionally ).isTrue ();
414
419
});
415
420
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
+
416
432
testing .waitAndAssertTraces (
417
433
trace ->
418
434
trace .hasSpansSatisfyingExactly (
@@ -421,11 +437,7 @@ void testCommandCompletesExceptionally() {
421
437
.hasKind (SpanKind .CLIENT )
422
438
.hasStatus (StatusData .error ())
423
439
.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 )));
429
441
}
430
442
431
443
@ Test
0 commit comments