Profiling your RavenDB MVC application

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:-
    [sourcecode language=”csharp”] protected void Application_BeginRequest()
    if (Request.IsLocal)

    and then :-

    [sourcecode language=”csharp”] protected void Application_EndRequest()
  4. Add the following to your global.asa.cs file in the Application_Start event:- [sourcecode language=”csharp”] Raven.Client.MvcIntegration.RavenProfiler.InitializeFor(Store);
  5. Lastly add the following lines into your _Layout.cshtml file in the Shared folder, under Views:- [sourcecode language=”csharp”] @MvcMiniProfiler.MiniProfiler.RenderIncludes()

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:-


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.