Custom parameter support via .NET Agent API

.NET Agent API helps to track the user defined methods in the web application. It monitors performance of specific methods in the web application DLL along with the entire execution time of the specified methods.

Specific method level parameter values can be tracked using this API. This gives deeper visibility into your own application methods. 

Configure API for .NET applications:

To configure the API:

  1. Download the package Site24x7.DotNetAgent.Api from NuGet package manager
  2. Add a reference to the library DotNetAgent.Api.dll to your web application project
  3. The API contains a class named CustomTracker to track the performance of a method
  4. The method AddCustomParameter(string, object) tracks parameters' values in a method
  5. Define parameter name and value in string and object respectively to track parameter values

Example:

The following method illustrates how the parameters are tracked via API

public int UserLogin(string email, string sessionKey, bool isExternal)


{

DotNetAgent.Api.CustomTracker.AddCustomParameter("ReportName", "Employee Report");
DotNetAgent.Api.CustomTracker.AddCustomParameter("reportId", 2452);

 
AccountBL objAdmin = new AccountBL();
string EmpName = string.Empty;
int retcode = objAdmin.LogIn(email, sessionKey, Session.SessionID, isExternal, out int EmpId, out EmpName);
 
if (retcode == 0)
{
Session["EmpName"] = EmpName;
Session["EmpId"] = EmpId;
Session["isAuthenticated"] = true;
}
}

The added parameter values will be displayed under the Request parameters section of Trace details tab as follows:

 


Configure API for .NET Core applications

To configure the API:

  1. Add the package Site24x7.DotNetCoreAgent.Api from NuGet package manager to your web application project.
  2. The API contains a class named Site24x7.Agent.Api to track the Custom Params of a transaction.
  3. The method AddCustomParameter(string, object) tracks parameters' values in a method.
  4. Define the parameter name and value in string and object fields respectively to track parameter values. 

Example:

The following method illustrates how the parameters are tracked via API

public int UserLogin(string email, string sessionKey, bool isExternal)


{

Site24x7.Agent.Api.AddCustomParameter("ReportName", "Employee Report");


Site24x7.Agent.Api.AddCustomParameter("reportId", 2452);


AccountBL objAdmin = new AccountBL();


string EmpName = string.Empty;


int retcode = objAdmin.LogIn(email, sessionKey, Session.SessionID, isExternal, out int EmpId, out EmpName);


if (retcode == 0)


{

Session["EmpName"] = EmpName;

Session["EmpId"] = EmpId;

Session["isAuthenticated"] = true;


}
}

Details on the added parameter values will be displayed under the Request Headers section of the Trace tab as follows:

Was this document helpful?
Thanks for taking the time to share your feedback. We’ll use your feedback to improve our online help resources.