Tags

, ,

Your application is starting to take shape and you want to be able to quickly see what’s going on when using RavenDB.

Step forward the in-built profiling dll which is very easy to set up and get going with, lets implement that along with MiniProfiler.

  1. Add the Nuget package MiniProfiler.RavenDb to your application
  2. Add the Raven.Client.MvcIntegration dll which can be found in the Client folder when you download the source for RavenDB
  3. Add the following to your global.asa.cs file:-
    protected void Application_BeginRequest()
    {
        if (Request.IsLocal)
        {
            MiniProfiler.Start();
        }
    }
    

    and then :-

    protected void Application_EndRequest()
    {
        MiniProfiler.Stop();
    }
    
  4. Add the following to your global.asa.cs file in the Application_Start event:-
    Raven.Client.MvcIntegration.RavenProfiler.InitializeFor(Store);
    MvcMiniProfiler.RavenDb.Profiler.AttachTo((DocumentStore)Store);
    
  5. Lastly add the following lines into your _Layout.cshtml file in the Shared folder, under Views:-
    @MvcMiniProfiler.MiniProfiler.RenderIncludes()
    @Raven.Client.MvcIntegration.RavenProfiler.CurrentRequestSessions()
    

That’s it – you have now adedd the built in profiler and MiniProfiler for RavenDB, run your application and you can
see that in the top left hand corner you can view the details of whats going on in both profilers:-

MiniProfiler for RavenDB looks like this:-

MiniProfiler

and this:-

MiniProfiler 2

while with the RavenDB profiler we see something like this:-

RavenDB Profiler

The in-built profiler from RavenDB shows us how long the query took, the status, result, Method, Url, Query and Actions as well as the actual request details.

All in all both profilers are very hand and very easy to install – go get them installed.