On this page:

Related pages:

Your Rating:
Results:
PatheticBadOKGoodOutstanding!
2 rates

Business Transaction Definition

You define a custom business transaction using the StartBusinessTransaction and StopBusinessTransaction SDK calls.

A downstream transaction in a distributed transaction cannot start until its upstream transaction has made its exit call.

The order of transactions respects the nonlinear nature of .NET applications. An upstream transaction might end immediately after its exit call completes or sometime later. It is not necessary for an upstream transaction to end before or after its downstream transaction starts or ends. A downstream transaction can end before its upstream transactions have ended.

Sample Business Transaction Creation

This example shows how you use the StartBusinessTransaction and StopBusinessTransaction SDK calls to define the entry point and exit point of a business transaction. 

using AppDynamics;
...
namespace coremvc.Controllers
{
   public class HomeController : Controller
   {
      public IActionResult SomePage()
      {
//define start of an ASP_DOTNET type business transaction named DemoBT
          var currCtxId = AgentSDK.StartBusinessTransaction("DemoBT", "ASP_DOTNET", "");
          // Code here calls to other ASP_DOTNET component
			...
          AgentSDK.StopBusinessTransaction(currCtxId);
          return View();
       }
       ...

 

Exit Call Management

An exit call is either a custom exit call or an automatically detected exit call. A transaction needs its exit call object to create correlation information to provide to a downstream transaction that needs to correlate with it.

Custom Exit Calls

If you want an exit call to be reported to the Controller, and it is not automatically detected by the agent, create a custom exit call with CreateExitCall( ) and then define the start and end of the exit call —startExitCall() and endExitCall(). Use AddIdentifyingPropertyToExitCall to help you to identify this exit call in the transaction snapshot. 

See .NET Core for Linux SDK Supported Environments for the list of backends that are automatically detected by the .NET Core for Linux SDK. If the exit call invokes a backend not listed on this page, you probably need to create a custom exit call.

Sample Exit Call Creation

 

using AppDynamics;
...
namespace coremvc.Controllers
{
	public class HomeController : Controller
	{
      public IActionResult SomePage()
      {
 
//define start of an ASP_DOTNET type business transaction called DemoBT. StartBusinessTransaction statement equals the value of the currCtxId variable
          var currCtxId = AgentSDK.StartBusinessTransaction("DemoBT", "ASP_DOTNET", "");
 
//define HTTP type exit call named CorrelationExit for the DemoBT business transaction. CreateExitCall statement equals the value of the exitCall variable
		  var exitCall = AgentSDK.CreateExitCall(currCtxId, "HTTP", "CorrelationExit");
 
//add identifying properties Host and Port, along with their respective values to the exit call 

                AgentSDK.AddIdentifyingPropertyToExitCall(exitCall, "Host", request.RequestUri.Host);
                AgentSDK.AddIdentifyingPropertyToExitCall(exitCall, "Port", request.RequestUri.Port.ToString());
          
//define the beginning of the exit call
        AgentSDK.StartExitCall(exitCall);

		//code here to make exit call
        ...

//define end of the exit call
 
         AgentSDK.StopExitCall(exitCall);

		//code here calls to other ASP_DOTNET component
         ...
//define end of the DemoBT business transaction
          AgentSDK.StopBusinessTransaction(currCtxId);
          return View();
       }
       ...

Transaction Correlation Management

Transaction correlation is the functionality that maintains the business transaction context across all tiers (servers) traversed by a distributed transaction. The tiers may be built on platforms other than .NET. For example, Java, Node.js, and PHP tiers may participate in a distributed business transaction in which a .NET tier participates as the originating, continuing or terminating tier in the transaction.

The .NET Core for Linux SDK provides facilities for managing transaction correlation among various transactions, which can be custom or automatically-detected.

While the AppDynamics default auto-detection mechanism obtains transaction correlation information from an incoming HTTP request, the .NET Core for Linux SDK allows you to obtain this information from other sources, such as a custom field in a Redis cache entry, and to supply it to your custom transactions. You can use the Agent SDK classes to support forward correlation by supplying transaction correlation information on exit calls that you make to downstream transactions.

A downstream transaction starts after its immediate upstream transaction makes its exit call. That exit call could be a direct exit call to the next tier or a call to a backend service that does some processing, such as publishing a message onto a queue. 

Sample Transaction Correlations Between Upstream and Downstream Tiers

Use Case 1: .NET Core on Linux application calling an upstream .NET Core on Linux application. Both applications are monitored by AppDynamics.

using AppDynamics;
...
namespace coremvc.Controllers
{
public class HomeController : Controller
   {
      public IActionResult SomePage()
      {
        var currCtxId AgentSDK.StartBusinessTransaction("DemoBT", "ASP_DOTNET", "");
            var client = new HttpClient();
            var request = new HttpRequestMessage()
            {
                        RequestUri = new Uri("http://localhost:8080 "),
                        Method = HttpMethod.Get,
                };

            var exitCall = AgentSDK.CreateExitCall(currCtxId, "HTTP", "CorrelationExit");
            AgentSDK.AddIdentifyingPropertyToExitCall(exitCall, "Host",   request.RequestUri.Host);
            AgentSDK.StartExitCall(exitCall);
            var correlationHeader = AgentSDK.GetCorrelationHeader(exitCall);
            request.Headers.Add("singularityheader",correlationHeader);
            await client.SendAsync(request);
            AgentSDK.StopExitCall(exitCall);
            AgentSDK.StopBusinessTransaction(currCtxId);       }
       ...

 

Use Case 2: .NET Core on Linux application calling a downstream .NET Core on Linux application. Both applications are monitored by AppDynamics.

using AppDynamics;
...
namespace coremvc.Controllers
{
public class HomeController : Controller
   {
      public IActionResult SomePage()
      {

bool hasCorrelationHeader = Request.Headers.TryGetValue("singularityheader", out var correlationHeader);

var currCtxId = AgentSDK.StartBusinessTransaction("DemoBT", "ASP_DOTNET",

hasCorrelationHeader ? (string)correlationHeader:"");

          // Code here calls to other ASP_DOTNET component

          AgentSDK.StopBusinessTransaction(currCtxId);

          return View();
       }
     ...

 

Use Case 3: Non .NET Core on Linux application monitored by AppDynamics calling a .NET Core on Linux application.

In order to correlate, the .NET Core on Linux application will have to include code such as the following:

using AppDynamics;
...
namespace coremvc.Controllers
{
public class HomeController : Controller
   {
      public IActionResult SomePage()
      {

//Obtain the HTTP header value of the page via the TryGetValue method and use that value to define correleationHeader
	bool hasCorrelationHeader = Request.Headers.TryGetValue("singularityheader", out var correlationHeader);

//Define the start of the ASP_DOTNET type business transaction DemoBT to include the correleation header if available.
	var currCtxId = AgentSDK.StartBusinessTransaction("DemoBT", "ASP_DOTNET",
	hasCorrelationHeader ? (string)correlationHeader:"");
 

          // Code here calls to other ASP_DOTNET component
			...
 
//Define the end of the DemoBT business transaction
          AgentSDK.StopBusinessTransaction(currCtxId);
          return View();
       }
       ...

  

Use Case 4: .NET Core on Linux application calling a non .NET Core on Linux application monitored by AppDynamics.

In order to correlate, the .NET Core on Linux application will have to include code such as the following:

using AppDynamics;
...
namespace coremvc.Controllers
{
public class HomeController : Controller
   {
      public IActionResult SomePage()
      {
           var currCtxId AgentSDK.StartBusinessTransaction("DemoBT", "ASP_DOTNET", "");

            var client = new HttpClient();

            var request = new HttpRequestMessage()
            {
                        RequestUri = new Uri("http://localhost:8080 "),
                        Method = HttpMethod.Get,
                };

            var exitCall = AgentSDK.CreateExitCall(currCtxId, "HTTP", "CorrelationExit");
            AgentSDK.AddIdentifyingPropertyToExitCall(exitCall, "Host",   request.RequestUri.Host);
            AgentSDK.StartExitCall(exitCall);
            var correlationHeader = AgentSDK.GetCorrelationHeader(exitCall);
            request.Headers.Add("singularityheader",correlationHeader);
            await client.SendAsync(request);
            AgentSDK.StopExitCall(exitCall);
            AgentSDK.StopBusinessTransaction(currCtxId);       }
       ...
 
 
  • No labels