31
31
import com .lambdaworks .redis .protocol .AsyncCommand ;
32
32
import io .opentelemetry .api .common .Attributes ;
33
33
import io .opentelemetry .api .trace .SpanKind ;
34
+ import io .opentelemetry .instrumentation .api .internal .SemconvStability ;
34
35
import io .opentelemetry .instrumentation .test .utils .PortUtils ;
35
36
import io .opentelemetry .instrumentation .testing .internal .AutoCleanupExtension ;
36
37
import io .opentelemetry .instrumentation .testing .junit .AgentInstrumentationExtension ;
37
38
import io .opentelemetry .instrumentation .testing .junit .InstrumentationExtension ;
39
+ import io .opentelemetry .sdk .testing .assertj .AttributeAssertion ;
38
40
import io .opentelemetry .sdk .trace .data .StatusData ;
41
+ import java .util .ArrayList ;
42
+ import java .util .Arrays ;
43
+ import java .util .List ;
39
44
import java .util .Map ;
40
45
import java .util .concurrent .CancellationException ;
41
46
import java .util .concurrent .CompletableFuture ;
@@ -413,6 +418,15 @@ 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_OPERATION ), "DEL" )));
426
+ if (SemconvStability .emitStableDatabaseSemconv ()) {
427
+ assertions .add (equalTo (ERROR_TYPE , "java.lang.IllegalStateException" ));
428
+ }
429
+
416
430
testing .waitAndAssertTraces (
417
431
trace ->
418
432
trace .hasSpansSatisfyingExactly (
@@ -421,10 +435,7 @@ void testCommandCompletesExceptionally() {
421
435
.hasKind (SpanKind .CLIENT )
422
436
.hasStatus (StatusData .error ())
423
437
.hasException (new IllegalStateException ("TestException" ))
424
- .hasAttributesSatisfyingExactly (
425
- equalTo (maybeStable (DB_SYSTEM ), "redis" ),
426
- equalTo (maybeStable (DB_OPERATION ), "DEL" ),
427
- equalTo (ERROR_TYPE , "java.lang.IllegalStateException" ))));
438
+ .hasAttributesSatisfyingExactly (assertions )));
428
439
}
429
440
430
441
@ Test
0 commit comments