How to use Prefix to profile your own custom code

Matt Watson Stackify Product & Company Updates Leave a Comment

Today’s desktops and servers are amazingly fast. For most developers and apps, their actual code takes nearly ZERO time to execute. Almost all of the time is spent executing a database query, connecting to web service, etc. This is also why asynchronous programming is so important and has become so popular. Our goal with Prefix and the Stackify APM is to track all of the time that your app spends performing common operations.

Prefix is powered by profiling the .NET CLR. This enables us to do some pretty amazing things like automatically instrumenting and tracking the performance of dozens of common frameworks, including SQL queries, web service calls, logging, cache calls, queuing, and much more. However, Prefix & the Stackify APM, Retrace, will never be able to track the performance of everything; they both provide the ability for you to customize what methods are being tracked by our profiler.

Configuring custom profiling

The Stackify .NET profiler automatically profiles hundreds of methods. We provide a simple mechanism via a JSON file that you can create to specify additional custom methods. For example, let’s pretend that Prefix didn’t support tracking calls to Elasticsearch via the Nest library (it really does). Some simple JSON like this is all you would need to tell Prefix how to track this new method:

[{“Class”: “Nest.ElasticClient”, “Method”: “DoRequest”}]

You can also configure Prefix to track methods in your own projects and code. It is possible to use wildcards to track every class or method within a namespace even. Be careful though – tracking too many methods can bring your web server to a halt. Tracking something like System.* would instantly cause IIS to hang.

See our docs to learn more about configuring custom profiling

Video walkthrough

To learn even more, please watch this video:


Get Prefix Power on a server!
Get Prefix Power on a server!

About Matt Watson

Matt is the Founder & CEO of Stackify. He has been a developer/hacker for over 15 years and loves solving hard problems with code. While working in IT management he realized how much of his time was wasted trying to put out production fires without the right tools. He founded Stackify in 2012 to create an easy to use set of tools for developers.