1717package com .navercorp .pinpoint .plugin .mongodb4 ;
1818
1919import com .mongodb .MongoTimeoutException ;
20+ import com .mongodb .ReadConcern ;
21+ import com .mongodb .ReadPreference ;
2022import com .mongodb .WriteConcern ;
2123import com .mongodb .client .result .DeleteResult ;
2224import com .mongodb .client .result .InsertOneResult ;
2325import com .mongodb .client .result .UpdateResult ;
26+ import com .mongodb .internal .operation .AsyncReadOperation ;
27+ import com .mongodb .internal .operation .AsyncWriteOperation ;
28+ import com .mongodb .reactivestreams .client .ClientSession ;
2429import com .mongodb .reactivestreams .client .MongoCollection ;
2530import com .mongodb .reactivestreams .client .MongoDatabase ;
31+ import com .mongodb .reactivestreams .client .internal .OperationExecutorImpl ;
2632import com .navercorp .pinpoint .bootstrap .plugin .test .ExpectedAnnotation ;
2733import com .navercorp .pinpoint .bootstrap .plugin .test .PluginTestVerifier ;
2834import com .navercorp .pinpoint .bootstrap .plugin .test .PluginTestVerifierHolder ;
@@ -148,7 +154,7 @@ private Method getMethod(Class<?> mongoDatabaseImpl, String name, Class<?>... pa
148154 }
149155 }
150156
151- public void insertComlexBsonValueData34 (PluginTestVerifier verifier , String address , MongoCollection <Document > collection , Class <?> mongoDatabaseImpl , String collectionInfo , String collectionOption ) {
157+ public void insertComlexBsonValueData34 (PluginTestVerifier verifier , String address , MongoCollection <Document > collection , Class <?> mongoDatabaseImpl , String collectionInfo , String collectionOption ) throws Exception {
152158 //insert Data
153159 Document document = createComplexDocument ();
154160 document .append ("decimal128" , new BsonDecimal128 (new Decimal128 (55 )));
@@ -163,16 +169,17 @@ public void insertComlexBsonValueData34(PluginTestVerifier verifier, String addr
163169 Method insertOneMethod = getMethod (mongoDatabaseImpl , "insertOne" , Object .class );
164170 NormalizedBson parsedBson = parseBson (document );
165171
166- // execute
167- verifier .verifyTrace (event (MONGO_REACTIVE ));
168-
169172 verifier .verifyTrace (event (MONGO_EXECUTE_QUERY , insertOneMethod , null , address , null
170173 , new ExpectedAnnotation (MongoConstants .MONGO_COLLECTION_INFO .getName (), collectionInfo )
171174 , new ExpectedAnnotation (MongoConstants .MONGO_COLLECTION_OPTION .getName (), collectionOption )
172175 , new ExpectedAnnotation (MongoConstants .MONGO_JSON_DATA .getName (), new StringStringValue (parsedBson .getNormalizedBson (), parsedBson .getParameter ()))));
176+
177+ Method executeMethod = OperationExecutorImpl .class .getDeclaredMethod ("execute" , AsyncWriteOperation .class , ReadConcern .class , ClientSession .class );
178+ // execute
179+ verifier .verifyTrace (event (MONGO_REACTIVE , executeMethod ));
173180 }
174181
175- public void insertData (PluginTestVerifier verifier , String address , MongoCollection <Document > collection , Class <?> mongoDatabaseImpl , String collectionInfo , String collectionOption ) {
182+ public void insertData (PluginTestVerifier verifier , String address , MongoCollection <Document > collection , Class <?> mongoDatabaseImpl , String collectionInfo , String collectionOption ) throws Exception {
176183 //insert Data
177184 Document doc = new Document ("name" , "Roy" ).append ("company" , "Naver" );
178185 ObservableSubscriber <InsertOneResult > sub = new ObservableSubscriber <>();
@@ -185,16 +192,16 @@ public void insertData(PluginTestVerifier verifier, String address, MongoCollect
185192 Method insertOneMethod = getMethod (mongoDatabaseImpl , "insertOne" , Object .class );
186193 NormalizedBson parsedBson = parseBson (doc );
187194
188- // execute
189- verifier .verifyTrace (event (MONGO_REACTIVE ));
190-
191195 verifier .verifyTrace (event (MONGO_EXECUTE_QUERY , insertOneMethod , null , address , null
192196 , new ExpectedAnnotation (MongoConstants .MONGO_COLLECTION_INFO .getName (), collectionInfo )
193197 , new ExpectedAnnotation (MongoConstants .MONGO_COLLECTION_OPTION .getName (), collectionOption )
194198 , new ExpectedAnnotation (MongoConstants .MONGO_JSON_DATA .getName (), new StringStringValue (parsedBson .getNormalizedBson (), parsedBson .getParameter ()))));
199+
200+ Method executeMethod = OperationExecutorImpl .class .getDeclaredMethod ("execute" , AsyncWriteOperation .class , ReadConcern .class , ClientSession .class );
201+ verifier .verifyTrace (event (MONGO_REACTIVE , executeMethod ));
195202 }
196203
197- public void updateData (PluginTestVerifier verifier , String address , MongoCollection <Document > collection , Class <?> mongoDatabaseImpl ) {
204+ public void updateData (PluginTestVerifier verifier , String address , MongoCollection <Document > collection , Class <?> mongoDatabaseImpl ) throws Exception {
198205 //update Data
199206 Document doc = new Document ("name" , "Roy" ).append ("company" , "Naver" );
200207 Document doc2 = new Document ("$set" , new Document ("name" , "Roy3" ));
@@ -208,17 +215,16 @@ public void updateData(PluginTestVerifier verifier, String address, MongoCollect
208215 Method updateOne = getMethod (mongoDatabaseImpl , "updateOne" , Bson .class , Bson .class );
209216 NormalizedBson parsedBson = parseBson (doc , doc2 );
210217
211- // execute
212- verifier .verifyTrace (event (MONGO_REACTIVE ));
213-
214218 verifier .verifyTrace (event (MONGO_EXECUTE_QUERY , updateOne , null , address , null
215219 , new ExpectedAnnotation (MongoConstants .MONGO_COLLECTION_INFO .getName (), "customers" )
216220 , new ExpectedAnnotation (MongoConstants .MONGO_COLLECTION_OPTION .getName (), "MAJORITY" )
217221 , new ExpectedAnnotation (MongoConstants .MONGO_JSON_DATA .getName (), new StringStringValue (parsedBson .getNormalizedBson (), parsedBson .getParameter ()))));
218- }
219222
223+ Method executeMethod = OperationExecutorImpl .class .getDeclaredMethod ("execute" , AsyncWriteOperation .class , ReadConcern .class , ClientSession .class );
224+ verifier .verifyTrace (event (MONGO_REACTIVE , executeMethod ));
225+ }
220226
221- public void readData (PluginTestVerifier verifier , String address , MongoCollection <Document > collection , Class <?> mongoDatabaseImpl ) {
227+ public void readData (PluginTestVerifier verifier , String address , MongoCollection <Document > collection , Class <?> mongoDatabaseImpl ) throws Exception {
222228 //read data
223229 ObservableSubscriber <Document > sub = new ObservableSubscriber <>();
224230 collection .find ().subscribe (sub );
@@ -233,14 +239,15 @@ public void readData(PluginTestVerifier verifier, String address, MongoCollectio
233239 , new ExpectedAnnotation (MongoConstants .MONGO_COLLECTION_INFO .getName (), "customers" )
234240 , new ExpectedAnnotation (MongoConstants .MONGO_COLLECTION_OPTION .getName (), "secondaryPreferred" )));
235241
236- assertResultSize ("Unexpected read data" , 2 , sub );
242+ Method executeMethod = OperationExecutorImpl .class .getDeclaredMethod ("execute" , AsyncReadOperation .class , ReadPreference .class , ReadConcern .class , ClientSession .class );
243+ verifier .verifyTrace (event (MONGO_REACTIVE , executeMethod ));
237244 }
238245
239246 private void assertResultSize (String message , int expected , ObservableSubscriber <Document > subscriber ) {
240247 Assert .assertEquals (message , expected , subscriber .getResults ().size ());
241248 }
242249
243- public void deleteData (PluginTestVerifier verifier , String address , MongoCollection <Document > collection , Class <?> mongoDatabaseImpl ) {
250+ public void deleteData (PluginTestVerifier verifier , String address , MongoCollection <Document > collection , Class <?> mongoDatabaseImpl ) throws Exception {
244251 //delete data
245252 Document doc = new Document ("name" , "Roy3" );
246253 ObservableSubscriber <DeleteResult > sub = new ObservableSubscriber <>();
@@ -253,18 +260,16 @@ public void deleteData(PluginTestVerifier verifier, String address, MongoCollect
253260 Method deleteMany = getMethod (mongoDatabaseImpl , "deleteMany" , Bson .class );
254261 NormalizedBson parsedBson = parseBson (doc );
255262
256- // execute
257- verifier .verifyTrace (event (MONGO_REACTIVE ));
258-
259263 verifier .verifyTrace (event (MONGO_EXECUTE_QUERY , deleteMany , null , address , null
260264 , new ExpectedAnnotation (MongoConstants .MONGO_COLLECTION_INFO .getName (), "customers" )
261265 , new ExpectedAnnotation (MongoConstants .MONGO_COLLECTION_OPTION .getName (), "MAJORITY" )
262266 , new ExpectedAnnotation (MongoConstants .MONGO_JSON_DATA .getName (), new StringStringValue (parsedBson .getNormalizedBson (), parsedBson .getParameter ()))));
263267
264- Assert .assertEquals ("unexcepted delete count" , 1 , sub .getResults ().get (0 ).getDeletedCount ());
268+ Method executeMethod = OperationExecutorImpl .class .getDeclaredMethod ("execute" , AsyncWriteOperation .class , ReadConcern .class , ClientSession .class );
269+ verifier .verifyTrace (event (MONGO_REACTIVE , executeMethod ));
265270 }
266271
267- public void filterData (PluginTestVerifier verifier , String address , MongoCollection <Document > collection , Class <?> mongoDatabaseImpl ) {
272+ public void filterData (PluginTestVerifier verifier , String address , MongoCollection <Document > collection , Class <?> mongoDatabaseImpl ) throws Exception {
268273 Method find = getMethod (mongoDatabaseImpl , "find" , Bson .class );
269274 Bson bson = eq ("name" , "Roy3" );
270275 NormalizedBson parsedBson = parseBson (bson );
@@ -276,18 +281,16 @@ public void filterData(PluginTestVerifier verifier, String address, MongoCollect
276281 } catch (Throwable throwable ) {
277282 }
278283
279- // execute
280- verifier .verifyTrace (event (MONGO_REACTIVE ));
281-
282284 verifier .verifyTrace (event (MONGO_EXECUTE_QUERY , find , null , address , null
283285 , new ExpectedAnnotation (MongoConstants .MONGO_COLLECTION_INFO .getName (), "customers" )
284286 , new ExpectedAnnotation (MongoConstants .MONGO_COLLECTION_OPTION .getName (), "secondaryPreferred" )
285287 , new ExpectedAnnotation (MongoConstants .MONGO_JSON_DATA .getName (), new StringStringValue (parsedBson .getNormalizedBson (), parsedBson .getParameter ()))));
286288
287- assertResultSize ("Unexpected filter data" , 1 , sub );
289+ Method executeMethod = OperationExecutorImpl .class .getDeclaredMethod ("execute" , AsyncReadOperation .class , ReadPreference .class , ReadConcern .class , ClientSession .class );
290+ verifier .verifyTrace (event (MONGO_REACTIVE , executeMethod ));
288291 }
289292
290- public void filterData2 (PluginTestVerifier verifier , String address , MongoCollection <Document > collection , Class <?> mongoDatabaseImpl ) {
293+ public void filterData2 (PluginTestVerifier verifier , String address , MongoCollection <Document > collection , Class <?> mongoDatabaseImpl ) throws Exception {
291294 Method find = getMethod (mongoDatabaseImpl , "find" , Bson .class );
292295 Bson bson = and (exists ("name" ), nin ("name" , 5 , 15 ));
293296 NormalizedBson parsedBson = parseBson (bson );
@@ -299,15 +302,13 @@ public void filterData2(PluginTestVerifier verifier, String address, MongoCollec
299302 } catch (Throwable throwable ) {
300303 }
301304
302- // execute
303- verifier .verifyTrace (event (MONGO_REACTIVE ));
304-
305305 verifier .verifyTrace (event (MONGO_EXECUTE_QUERY , find , null , address , null
306306 , new ExpectedAnnotation (MongoConstants .MONGO_COLLECTION_INFO .getName (), "customers" )
307307 , new ExpectedAnnotation (MongoConstants .MONGO_COLLECTION_OPTION .getName (), "secondaryPreferred" )
308308 , new ExpectedAnnotation (MongoConstants .MONGO_JSON_DATA .getName (), new StringStringValue (parsedBson .getNormalizedBson (), parsedBson .getParameter ()))));
309309
310- assertResultSize ("Unexpected filter data2" , 1 , sub );
310+ Method executeMethod = OperationExecutorImpl .class .getDeclaredMethod ("execute" , AsyncReadOperation .class , ReadPreference .class , ReadConcern .class , ClientSession .class );
311+ verifier .verifyTrace (event (MONGO_REACTIVE , executeMethod ));
311312 }
312313
313314 private static class ObservableSubscriber <T > implements Subscriber <T > {
0 commit comments