Help Docs

Custom Instrumentation via .NET agent API

Site24x7's .NET agent API allows you to track application methods in your .NET application. You can monitor the performance of your application methods or a block of code by including the agent API inside the methods or classes that need to be monitored.

This will be supported from the agent version 5.6.0

Follow the below-given instructions to instrument.

Installation Instructions:

  1. Install APM Insight .NET agent or APM Insight .NET Core agent based on your application environment.
  2. Download or reference the package Site24x7.Agent.Api from the NuGet package manager to your application project.
    Note: The API has a class named Site24x7.Agent.Api  to track the performance of the application code. 
  3. You can use the using block to create an instance of the class Site24x7.Agent.Api  like Site24x7.Agent.Api(object thisObject, string methodName, string componentName).

Parameter Name

Description

 thisObject

The this object  that is used to get the name of the current object type.

 methodName

The name  of the method that is displayed in trace details.

 componentName

The name  of the component that determines the action or service.

Syntax:

The following method illustrates how to add a snippet:

public int YourMethod(string param1, string param2, bool param3)
{
          using (var api = new Site24x7.Agent.Api(this, "YourMethodName", "YourComponentName"))
          {
                    //Your application code goes here..
                    ..............................
          }
}

Example:

public int ConvertToRupee(string param1, string param2, bool param3)
{
         using (var api = new Site24x7.Agent.Api(this, "ConvertToRupee", "CONVERTER"))
         {
                   // Your application code goes here
                   ..............................
         }
}

The execution time of the code inside the using block will be calculated and displayed under the method name ConvertToRupee.

Before instrumentation:

Before instrumentation

After instrumentation:

After instrumentation

Was this document helpful?

Shortlink has been copied!