MongoDB is not being profiled on tiny test case


I have correct profiling with SQL and regular steps and custom steps. However the system doesn’t seem to be logging MongoDB calls at all.

I call this method 5 times every page load.

public class SomeMongoSheet
    public void DoMongo()

        var client = new MongoClient("mongodb://XXX-XXX:12312");
        var mongoServer = new ProfiledMongoServer(client.GetServer());
        var db = mongoServer.GetDatabase("XXX");
        var collection = db.GetCollection<SavedSearchCriteria>("SavedSearchCriteria");

        Guid? id = Guid.Parse("6316e418-00f5-4dc0-bedf-935ddf4d53db");

        var bsonId = BsonValue.Create(id);
        var queryById = Query.EQ("_id", bsonId);
        var x = collection.FindOne(queryById);

This is giving nothing in the output related to mongo. and “x” is filled in appropriately in debugging.

Anyone know what I did wrong?


So I figured out why this is happening. The miniprofiler driver for mongodb only implements one query method. Fairly sad. We just aren’t going to use the mongodb driver for miniprofiler. Going to use customtimings wrapped around our mongo calls instead. And the one I’m using isn’t wrapped. The only one you can use is FindAs<>


The mongodb driver for miniprofiler was submitted by a community member (it is not actually used at Stack Exchange). If you would like to submit a PR to include any other extensions (ie: other query methods) then I would be happy to include it.


What about to upgrade the MongoDB .NET driver version to a newer one?