1010import static org .assertj .core .api .Assertions .assertThat ;
1111import static org .awaitility .Awaitility .await ;
1212
13+ import io .opentelemetry .api .common .AttributeKey ;
1314import io .opentelemetry .instrumentation .testing .internal .AutoCleanupExtension ;
1415import io .opentelemetry .instrumentation .testing .junit .AgentInstrumentationExtension ;
1516import io .opentelemetry .instrumentation .testing .junit .InstrumentationExtension ;
@@ -38,6 +39,9 @@ public class RediscalaClientTest {
3839
3940 private static GenericContainer <?> redisServer ;
4041
42+ @ SuppressWarnings ("deprecation" ) // DB_OPERATION is deprecated
43+ public static final AttributeKey <String > DB_OPERATION = DbIncubatingAttributes .DB_OPERATION ;
44+
4145 private static String host ;
4246 private static int port ;
4347 private static Object system ;
@@ -47,7 +51,7 @@ public class RediscalaClientTest {
4751 static void setUp () throws Exception {
4852 redisServer = new GenericContainer <>("redis:6.2.3-alpine" ).withExposedPorts (6379 );
4953 redisServer .start ();
50- cleanup .deferCleanup (redisServer ::stop );
54+ // cleanup.deferCleanup(redisServer::stop);
5155
5256 host = redisServer .getHost ();
5357 port = redisServer .getMappedPort (6379 );
@@ -97,7 +101,7 @@ static void tearDown() throws Exception {
97101 }
98102
99103 @ Test
100- void testGetCommand () throws Exception {
104+ void testGetCommand () {
101105 Pair <Future <Object >, Future <Option <String >>> result =
102106 testing .runWithSpan (
103107 "parent" ,
@@ -131,20 +135,20 @@ void testGetCommand() throws Exception {
131135 span .hasName ("SET" )
132136 .hasKind (CLIENT )
133137 .hasParent (trace .getSpan (0 ))
134- .hasAttributesSatisfying (
138+ .hasAttributesSatisfyingExactly (
135139 equalTo (DbIncubatingAttributes .DB_SYSTEM , "redis" ),
136- equalTo (DbIncubatingAttributes . DB_OPERATION_NAME , "SET" )),
140+ equalTo (DB_OPERATION , "SET" )),
137141 span ->
138142 span .hasName ("GET" )
139143 .hasKind (CLIENT )
140- .hasParent (trace .getSpan (1 ))
141- .hasAttributesSatisfying (
144+ .hasParent (trace .getSpan (0 ))
145+ .hasAttributesSatisfyingExactly (
142146 equalTo (DbIncubatingAttributes .DB_SYSTEM , "redis" ),
143- equalTo (DbIncubatingAttributes . DB_OPERATION_NAME , "GET" ))));
147+ equalTo (DB_OPERATION , "GET" ))));
144148 }
145149
146150 @ Test
147- public void testSetCommand () throws Exception {
151+ public void testSetCommand () {
148152 ByteStringSerializer <String > serializer = ByteStringSerializer$ .MODULE$ .String ();
149153
150154 Future <Object > value =
@@ -171,6 +175,6 @@ public void testSetCommand() throws Exception {
171175 .hasParent (trace .getSpan (0 ))
172176 .hasAttributesSatisfying (
173177 equalTo (DbIncubatingAttributes .DB_SYSTEM , "redis" ),
174- equalTo (DbIncubatingAttributes . DB_OPERATION_NAME , "SET" ))));
178+ equalTo (DB_OPERATION , "SET" ))));
175179 }
176180}
0 commit comments