Question

I'd like to collect performance metrics for each of my ServiceStack services, and write a service that reports these metrics. Specifically, I would ultimately like to render a report similar to this:

Service Name    Fastest time    Median time    Slowest time   Access count
---------------------------------------------------------------------------
GetCustomer         5 ms           8 ms           1001 ms       12345
ListMonkeys       123 ms         200 ms            228 ms         999

I think I know how to do this using request/response filters, but perhaps there's an existing mechanism for doing this ?

Was it helpful?

Solution

I would try looking at ServiceStacks embedded mini-profiler and change the profiling condition (in global.asax begin_request) to always run, or perhaps run for a random selection of 10% or 15% of all requests.

Then you should enable the MiniProfiler's persistent storage, however, the namespaces / properties in the ServiceStack embedded version might differ slightly from this example.

Lastly, I would look at the MVC mini profiler dashboard drop in at Github. If you're not using ASP.net MVC at least the PerformanceController.cs can give you a pretty good idea of how to structure your SQL calls. Disclaimer: the controller is using some statistical functions which are only present in Oracle, Microsoft SQL and PostgreSQL (to my knowledge) so if you're using MySQL you might have to code some logic on the application side instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top