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.
- Add the Nuget package MiniProfiler.RavenDb to your application
- Add the Raven.Client.MvcIntegration dll which can be found in the Client folder when you download the source for RavenDB
- 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(); }
- 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);
- 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:-
and this:-
while with the RavenDB profiler we see something like this:-
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.
