Retrace will reach End of Life on March 31, 2027. Click here to learn more.

How to Use Retrace Tracked Functions to Monitor Your Code

By: mwatson
  |  August 23, 2017
How to Use Retrace Tracked Functions to Monitor Your Code

Our goal at Stackify has always been to provide developers a simple way to monitor the performance of their applications. By default, Retrace tracks the performance of dozens of different common application dependencies and frameworks. This includes things like SQL databases, MongoDB, Elasticsearch, Redis, external REST services, and much more.

Full list of supported frameworks: .NET or Java

But what if you want to track something else?

This is where Tracked Functions is really powerful.

Top 3 Reasons to Use Tracked Functions

There are probably endless ways you could use Tracked Functions. I can think of three different categories that they should all fall under.

1. Track time spent on sub-transactions as part of a larger transaction

Retrace automatically tracks how long web requests take (and non-web with a little work). But what if you want to break that down further?

Let’s pretend you have a web application that receives uploaded files and processes them.

  1. Reads incoming file that is uploaded, cleans it up, validates it, and appends some additional data
  2. Writes the file to blob storage somewhere
  3. Writes a message to a queue to tell something else to process this

If you wanted more granularity around how long step 1 takes, tracked functions could help. All you would need to do is tell Retrace to track that block of code. Retrace would then report every time it happens and how long it takes. This would give you better visibility in to know how long that specific step of the entire process takes.

2. Track time spent on unsupported application dependency

Retrace automatically tracks dozens of common application dependencies. However, it will never support everything.

Let’s pretend you are writing a .NET application that uses OpenTSDB for storing time series data. You could use Tracked Functions to track the usage and performance of it.

3. Track different queries or operations of framework

Retrace provides great reporting around SQL queries. Unfortunately, that doesn’t work for things like Elasticsearch or MongoDB (at this time).

At Stackify we use Elasticsearch and wanted to report around how often we call specific queries and how long they take. We are able to accomplish this with Tracked Functions.

Our code that executes searches against Elasticsearch is in a central location. With a couple lines of code, we were able to instrument our code and report our queries to Retrace.

How to Use Retrace Tracked Functions

The implementation is a little different depending on which programming language you are using.

Tracked Functions with .NET

To utilize Tracked Functions, you must add our StackifyLib nuget package to your project. You then surround your code as shown below with our tracer.

var tracer = StackifyLib.ProfileTracer.CreateAsTrackedFunction("Name the block of code"); 
tracer.Exec(() => 
{ 
   //Do some stuff 
});

Tracked Functions with Java

For Java, you can implement Tracked Functions by decorating the methods in your code or via a configuration file. See our docs for more details.

{
 "Class": “com.company.SampleController",
 "Method": “testMethod",
 "TrackedFunction": true,
 "TrackedFunctionName": "Tracked Function Test {{ClassName}}.{{MethodName}}"
}

Tracked Functions Reporting

Within the application dashboard for each of your applications, you can access Tracked Functions. It will show a list of all the Tracked Functions currently being tracked for your application.

Tracked Functions List in Retrace
Tracked Functions List in Retrace

If you select a specific web request or transaction, you can then see how that tracked function impacts the performance of that request.

Tracked Functions by Request Performance Breakdown
Tracked Functions by Request Performance Breakdown

You can also see the tracked functions within the traces that are collected.

Retrace Tracked Function in Trace
Retrace Tracked Function in Trace

Summary

Retrace provides a wide array of application monitoring capabilities. Tracked Functions allows you to get very granular in tracking the performance of your code. Hopefully, this article gives you a good review of why you would use them and some of the benefits.

Improve Your Code with Retrace APM

Stackify's APM tools are used by thousands of .NET, Java, PHP, Node.js, Python, & Ruby developers all over the world.
Explore Retrace's product features to learn more.

Learn More
indobet toto slot toto toto bobatoto daftar logototo patentoto situs toto slot 4D toto bayitoto popotogel prize hongkong malam ini joker11 lingkartoto depo 5k panen100 semibola slot sbobet88 sbobet88 https://nolimithoki.dev/ dinasti33 slot slot88 slot jepang slot depo 5k https://www.juara288.asia/ slot 4d toto toto situs toto flokitoto slot gacor logototo slot depo 5k bobatoto bobatoto bobatoto sontogel mpo slot situs toto slot situs slot bobatoto kari4d kari4d kari4d kari4d pascol4d pascol4d pascol4d slot gacor bento11 link slot gacor toto toto slot toto situs slot situs slot situs slot https://www.asupan188.dev/ slot gacor gampang menang toto slot gacor bwo303 situs toto toto slot slot gacor slot88 slot gacor situs slot link slot slot gacor pucuk4d PASCOL4D situs slot link slot pajaktoto slotvip situs toto toto slot situs slot situs slot situs slot toto slot gacor slot777 situs slot link slot situs judi bola POPOTOGEL : Situs Resmi Bandar Toto Togel Macau dengan Prediksi Gokil Pasti Akurat link slot slot gacor situs slot slot gacor slot gacor situs slot link slot gacor Slot88 Slot88 slot gacor situs toto toto slot pulsa slot777 link slot gacor situs gacor slot gacor leon188 slot gacor bandarqq slot gacor slot gacor Slot88 slot gacor Slot88 situs slot slot gacor poker online slot88 Slot88 slot gacor slot terbaru slot gacor situs gacor situs slot slot gacor situs slot Situs Slot POPOTOGEL: Regulasi Bandar Situs Togel Resmi & Bola Mix Parlay Asia Terpercaya StreamEast Jpmania slot resmi slot slot resmi slot bayitoto patentoto link gacor slot gacor kari4d slot demo slot gacor AMANAHTOTO slot gacor slot gacor StreamEast AMANAHTOTO pascol4d kari4d AMANAHTOTO kari4d bragatoto dokter88 slot gacor slot game patentoto pucuk4d rokokbet rokokbet kari4d
indobet toto slot toto toto bobatoto daftar logototo patentoto situs toto slot 4D toto bayitoto popotogel prize hongkong malam ini joker11 lingkartoto depo 5k panen100 semibola slot sbobet88 sbobet88 https://nolimithoki.dev/ dinasti33 slot slot88 slot jepang slot depo 5k https://www.juara288.asia/ slot 4d toto toto situs toto flokitoto slot gacor logototo slot depo 5k bobatoto bobatoto bobatoto sontogel mpo slot situs toto slot situs slot bobatoto kari4d kari4d kari4d kari4d pascol4d pascol4d pascol4d slot gacor bento11 link slot gacor toto toto slot toto situs slot situs slot situs slot https://www.asupan188.dev/ slot gacor gampang menang toto slot gacor bwo303 situs toto toto slot slot gacor slot88 slot gacor situs slot link slot slot gacor pucuk4d PASCOL4D situs slot link slot pajaktoto slotvip situs toto toto slot situs slot situs slot situs slot toto slot gacor slot777 situs slot link slot situs judi bola POPOTOGEL : Situs Resmi Bandar Toto Togel Macau dengan Prediksi Gokil Pasti Akurat link slot slot gacor situs slot slot gacor slot gacor situs slot link slot gacor Slot88 Slot88 slot gacor situs toto toto slot pulsa slot777 link slot gacor situs gacor slot gacor leon188 slot gacor bandarqq slot gacor slot gacor Slot88 slot gacor Slot88 situs slot slot gacor poker online slot88 Slot88 slot gacor slot terbaru slot gacor situs gacor situs slot slot gacor situs slot Situs Slot POPOTOGEL: Regulasi Bandar Situs Togel Resmi & Bola Mix Parlay Asia Terpercaya StreamEast Jpmania slot resmi slot slot resmi slot bayitoto patentoto link gacor slot gacor kari4d slot demo slot gacor AMANAHTOTO slot gacor slot gacor StreamEast AMANAHTOTO pascol4d kari4d AMANAHTOTO kari4d bragatoto dokter88 slot gacor slot game patentoto pucuk4d rokokbet rokokbet kari4d