Search in sources :

Example 1 with NormalizedBson

use of com.navercorp.pinpoint.plugin.mongo.NormalizedBson in project pinpoint by naver.

the class MongoCUDSessionInterceptor method doInAfterTrace.

@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
    if (collectJson) {
        final boolean success = InterceptorUtils.isSuccess(throwable);
        if (success) {
            if (args != null) {
                NormalizedBson parsedBson = MongoUtil.parseBson(args, traceBsonBindValue);
                MongoUtil.recordParsedBson(recorder, parsedBson);
            }
        }
    }
    recorder.recordException(throwable);
    if (isAsynchronousInvocation(target, args, result, throwable)) {
        // Trace to Disposable object
        final AsyncContext asyncContext = recorder.recordNextAsyncContext();
        ((AsyncContextAccessor) (result))._$PINPOINT$_setAsyncContext(asyncContext);
        if (isDebug) {
            logger.debug("Set AsyncContext {}, result={}", asyncContext, result);
        }
    }
}
Also used : NormalizedBson(com.navercorp.pinpoint.plugin.mongo.NormalizedBson) AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext)

Example 2 with NormalizedBson

use of com.navercorp.pinpoint.plugin.mongo.NormalizedBson in project pinpoint by naver.

the class MongoDBITBase method updateData.

public void updateData(PluginTestVerifier verifier, MongoCollection<Document> collection, Class<?> mongoDatabaseImpl) {
    // update Data
    Document doc = new Document("name", "Roy").append("company", "Naver");
    Document doc2 = new Document("$set", new Document("name", "Roy3"));
    collection.updateOne(doc, doc2);
    Method updateOne = getMethod(mongoDatabaseImpl, "updateOne", Bson.class, Bson.class);
    NormalizedBson parsedBson = parseBson(doc, doc2);
    verifier.verifyTrace(event(MONGO_EXECUTE_QUERY, updateOne, null, MongoDBITConstants.MONGODB_ADDRESS, null, new ExpectedAnnotation(MongoConstants.MONGO_COLLECTION_INFO.getName(), "customers"), new ExpectedAnnotation(MongoConstants.MONGO_COLLECTION_OPTION.getName(), "MAJORITY"), new ExpectedAnnotation(MongoConstants.MONGO_JSON_DATA.getName(), new StringStringValue(parsedBson.getNormalizedBson(), parsedBson.getParameter()))));
}
Also used : ExpectedAnnotation(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation) StringStringValue(com.navercorp.pinpoint.common.util.StringStringValue) NormalizedBson(com.navercorp.pinpoint.plugin.mongo.NormalizedBson) Method(java.lang.reflect.Method) Document(org.bson.Document) BsonDocument(org.bson.BsonDocument)

Example 3 with NormalizedBson

use of com.navercorp.pinpoint.plugin.mongo.NormalizedBson in project pinpoint by naver.

the class MongoDBITBase method filterData.

public void filterData(PluginTestVerifier verifier, MongoCollection<Document> collection, Class<?> mongoDatabaseImpl) {
    Method find = getMethod(mongoDatabaseImpl, "find", Bson.class);
    Bson bson = eq("name", "Roy3");
    NormalizedBson parsedBson = parseBson(bson);
    MongoCursor<Document> cursor = collection.find(bson).iterator();
    verifier.verifyTrace(event(MONGO_EXECUTE_QUERY, find, null, MongoDBITConstants.MONGODB_ADDRESS, null, new ExpectedAnnotation(MongoConstants.MONGO_COLLECTION_INFO.getName(), "customers"), new ExpectedAnnotation(MongoConstants.MONGO_COLLECTION_OPTION.getName(), "secondaryPreferred"), new ExpectedAnnotation(MongoConstants.MONGO_JSON_DATA.getName(), new StringStringValue(parsedBson.getNormalizedBson(), parsedBson.getParameter()))));
    assertResultSize(1, cursor);
}
Also used : ExpectedAnnotation(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation) StringStringValue(com.navercorp.pinpoint.common.util.StringStringValue) NormalizedBson(com.navercorp.pinpoint.plugin.mongo.NormalizedBson) Method(java.lang.reflect.Method) Document(org.bson.Document) BsonDocument(org.bson.BsonDocument) Bson(org.bson.conversions.Bson) NormalizedBson(com.navercorp.pinpoint.plugin.mongo.NormalizedBson)

Example 4 with NormalizedBson

use of com.navercorp.pinpoint.plugin.mongo.NormalizedBson in project pinpoint by naver.

the class MongoDBITBase method insertComlexBsonValueData34.

public void insertComlexBsonValueData34(PluginTestVerifier verifier, MongoCollection<Document> collection, Class<?> mongoDatabaseImpl, String collectionInfo, String collectionOption) {
    // insert Data
    Document document = createComplexDocument();
    document.append("decimal128", new BsonDecimal128(new Decimal128(55)));
    collection.insertOne(document);
    Method insertOneMethod = getMethod(mongoDatabaseImpl, "insertOne", Object.class);
    NormalizedBson parsedBson = parseBson(document);
    verifier.verifyTrace(event(MONGO_EXECUTE_QUERY, insertOneMethod, null, MongoDBITConstants.MONGODB_ADDRESS, null, new ExpectedAnnotation(MongoConstants.MONGO_COLLECTION_INFO.getName(), collectionInfo), new ExpectedAnnotation(MongoConstants.MONGO_COLLECTION_OPTION.getName(), collectionOption), new ExpectedAnnotation(MongoConstants.MONGO_JSON_DATA.getName(), new StringStringValue(parsedBson.getNormalizedBson(), parsedBson.getParameter()))));
}
Also used : ExpectedAnnotation(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation) BsonDecimal128(org.bson.BsonDecimal128) StringStringValue(com.navercorp.pinpoint.common.util.StringStringValue) NormalizedBson(com.navercorp.pinpoint.plugin.mongo.NormalizedBson) BsonDecimal128(org.bson.BsonDecimal128) Decimal128(org.bson.types.Decimal128) Method(java.lang.reflect.Method) Document(org.bson.Document) BsonDocument(org.bson.BsonDocument)

Example 5 with NormalizedBson

use of com.navercorp.pinpoint.plugin.mongo.NormalizedBson in project pinpoint by naver.

the class MongoDBITBase method deleteData.

public void deleteData(PluginTestVerifier verifier, MongoCollection<Document> collection, Class<?> mongoDatabaseImpl) {
    // delete data
    Document doc = new Document("name", "Roy3");
    DeleteResult deleteResult = collection.deleteMany(doc);
    Method deleteMany = getMethod(mongoDatabaseImpl, "deleteMany", Bson.class);
    NormalizedBson parsedBson = parseBson(doc);
    verifier.verifyTrace(event(MONGO_EXECUTE_QUERY, deleteMany, null, MongoDBITConstants.MONGODB_ADDRESS, null, new ExpectedAnnotation(MongoConstants.MONGO_COLLECTION_INFO.getName(), "customers"), new ExpectedAnnotation(MongoConstants.MONGO_COLLECTION_OPTION.getName(), "MAJORITY"), new ExpectedAnnotation(MongoConstants.MONGO_JSON_DATA.getName(), new StringStringValue(parsedBson.getNormalizedBson(), parsedBson.getParameter()))));
    Assert.assertEquals(1, deleteResult.getDeletedCount());
}
Also used : ExpectedAnnotation(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation) StringStringValue(com.navercorp.pinpoint.common.util.StringStringValue) NormalizedBson(com.navercorp.pinpoint.plugin.mongo.NormalizedBson) Method(java.lang.reflect.Method) Document(org.bson.Document) BsonDocument(org.bson.BsonDocument) DeleteResult(com.mongodb.client.result.DeleteResult)

Aggregations

NormalizedBson (com.navercorp.pinpoint.plugin.mongo.NormalizedBson)9 ExpectedAnnotation (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation)7 StringStringValue (com.navercorp.pinpoint.common.util.StringStringValue)7 Method (java.lang.reflect.Method)7 BsonDocument (org.bson.BsonDocument)7 Document (org.bson.Document)7 AsyncContextAccessor (com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor)2 AsyncContext (com.navercorp.pinpoint.bootstrap.context.AsyncContext)2 Bson (org.bson.conversions.Bson)2 DeleteResult (com.mongodb.client.result.DeleteResult)1 BsonDecimal128 (org.bson.BsonDecimal128)1 Decimal128 (org.bson.types.Decimal128)1