HTTPS SSH

ServiceStack's MiniProfiler toolkit

Overview

This project intends to provide tools for collecting & analyzing profiling results of ServiceStack-based apps.

Not only this makes profiling possible in the scenario when no built-in web-frontend is available (like Single Page Applications), but also has several advantages over it:

  • collects & persists the results
  • allows the "background" profiling (example: production environment)
  • it's better to analyze large amounts of collected profiling results, not just focusing on single execution timings
  • helps finding time-consuming queries

Technical overview

The project consist of two main components:

  • MiniProfiler RemoteStorage - currently implemented only for ServiceStack's built in version of MiniProfiler.
  • Analyzer: Collecting & analyzing service + it's AngularJS-based front end

It'd be possible to support "pure" StackExchange MiniProfiler as well, although that would require me to provide the Analyzer in binary form (otherwise it'd be only available to registered customers of ServiceStack - license key is required here)

Each profiling result is being serialized into DTO hierarchy and asynchronously (background thread) sent to the Analyzer service, where it's being persisted in the SQLite database.

Dependencies

  • RemoteStorage:

    • AutoMapper
    • ServiceStack.Client 4+
  • Analyzer:

    • ServiceStack v.4.0.31 (only available through MyGet as of 27-08-2014. The version is important as it includes fix for serious MiniProfiler bug)
    • NHibernate
    • SQLite

Installation

Analyzer

Checkout the repository and build MiniProfiling.Backend.SelfHost (VisualStudio 2013 preferred). Currently the Analyzer fits under 10 DTO's limit so you don't have to provide ServiceStack license yet (although this will likely change in the near future)

Binary distribution is not available as for now.

RemoteStorage for ServiceStack's built-in profiling

First of all, make sure you have ServiceStack built-in profiling set up and running properly.

Install the Migajek.MiniProfiling.ServiceStack.RemoteStorage NuGet package into the project you want to profile. In the AppHost Configure method, add the plugin:

Plugins.Add(new Migajek.Profiling.ServiceStackProfiler.MiniProfilingToolkit("http://url/", "ProjectName"));

The first argument is the address at which Analyzer is available. The second argument is the project name - any name you choose to group the results and distinguish from other projects in the same database.

Usage

Once installed, run the Analyzer and point your browser at http://localhost:8080/ You can analyze the already collected data or keep an eye on live execution log on the project's Results view.

Screenshots

Projects dashboard

MiniProfiler toolkit

Top queries

Profiling NHibernate queries

Profiling results

ServiceStack profiling

Individual result timings

C# profiling

Individual query preview

NHibernate profiling query

Known issues & TODO

  • store timing/sql counts in the domain models, don't calculate them
  • compatibility with StackExchange MiniProfiler
  • preview SQL queries executed in specific steps of selected result.
  • introduce per-project key-based authentication for RemoteStorage & credentials for Analyzer ?

  • top queries query occurence might not work as expected when using ServiceStack's OrmLite, because OrmLite binds parameters values earlier than expected by MiniProfiler. This results in the query command containing already binded parameters when sending the data to the Analyzer.