Asynchronous Transaction Support

The .NET agent can capture data about asynchronous .NET application transactions. Asynchronous operations can execute sequentially and in parallel. Asynchronous events that happen in a series are the result callback of the first operation. The result callback starts the next asynchronous operation. Asynchronous events have a parent-child relationship when an asynchronous operation invokes another operation to complete. 
apmdevops106
The .NET agent can capture data about asynchronous .NET application transactions. Asynchronous operations can execute sequentially and in parallel. Asynchronous events that happen in a series are the result callback of the first operation. The result callback starts the next asynchronous operation. Asynchronous events have a parent-child relationship when an asynchronous operation invokes another operation to complete. 
Different events are important for tracing asynchronous operations:
  • Operation Start
    This event is measured from the start of invoking an asynchronous API call and marks the transaction component start time.
  • Operation Done
    This event is measured from the beginning of the operation result callback and marks the transaction component end time. This event also tracks if the next asynchronous operation start is in a series with a previous operation or in parallel.
The .NET framework uses multiple programming models to provide asynchronous transaction within applications. The .NET agent can monitor a transaction as it travels between different involved threads. Here are two recent .NET  asynchronous programming models:
  • async/await keywords
    The compiler generates the state machine behind the scene.
  • Task-based Asynchronous Pattern (TAP)
    Standard backends such as database backends and HTTP backends use this model.
async/await asynchronous Programming Model
.NET provides an async/await asynchronous programming model that is backed by a compiler-generated state machine model.
The async/await model implements some Model View Controller (MVC) controllers that contain MVC Actions. The MVC Actions are automatically detected.
Out-of-the-box, the .NET agent supports monitoring only MVC controllers that are supported for the async/await model. However, .NET asynchronous transaction monitoring can support any other classes and methods that use the async/await pattern.
You must restart the process after the application is exercised. The .NET Agent discovers the asynchronous state machine and persists the corresponding instrumentation in <A
gent_Home
>/persistedprobes/StateMachineAsync.pbd.
TAP Model
The TAP model is supported out-of-the-box for HTTP asynchronous calls from the API HttpClient.
Look for the
MVCAsyncTracing
 PBD entries in the MVC.pbd to learn how you can use the model for async/await APIs other than MVC.
The TAP model response time metric is the total time that is taken to return the response for the HTTP request. In the TAP model, transaction traces are processed and sent by a different thread, not from the calling thread.
Extending Asynchronous Instrumentation
For any other asynchronous API, you must configure a PBD to get the asynchronous calls working for classes other than MVC and HTTP backends.
Here is an example async/await PBD.
SetTracerClassMapping: AsyncBlamePointTracer com.wily.introscope.agent.trace.async.hc2.AsyncStateMachineBlamePointTracer com.wily.introscope.probebuilder.validate.ResourceNameValidator
SetTracerParameter: AsyncBlamePointTracer nameformatter com.wily.introscope.agent.trace.async.hc2.AsyncStateMachineNameFormatter
SetTracerParameter: AsyncBlamePointTracer computemetrics false
 
SetTracerClassMapping: FrontendMarkerAsync com.wily.introscope.agent.trace.async.hc2.AsyncStateMachineFrontendTracer com.wily.introscope.probebuilder.validate.ResourceNameValidator
SetTracerParameter: FrontendMarkerAsync nameformatter com.wily.introscope.agent.trace.async.hc2.AsyncStateMachineNameFormatter
SetTracerParameter: FrontendMarkerAsync isTransactionContextOwner true
# Use the isTransactionContextOwner for BlameTracer if you are not using frontend in the below instrumentation.
SetTracerParameter: FrontendMarkerAsync computemetrics false
SetTracerOrdering: FrontendMarkerAsync -100
 
 
SetFlag: MVCAsyncExtendedTracing
TurnOn: MVCAsyncExtendedTracing
##### Following tracer enables the state machine push for persistence
SetTracerClassMapping: AsyncStateMachineEnablingTracerV2 com.wily.introscope.agent.trace.async.hc2.AsyncStateMachineEnablingTracer com.wily.introscope.probebuilder.validate.ResourceNameValidator
SetTracerParameter: AsyncStateMachineEnablingTracerV2 nameformatter
SetTracerParameter: AsyncStateMachineEnablingTracerV2 formattingKeys "{namespaceandclassname},{method}"
SetTracerParameter: AsyncStateMachineEnablingTracerV2 tracerGroup MVCAsyncExtendedTracing
 
 
IdentifyClassAs:  <Your class name> MVCAsyncExtendedTracing
// You can use IdentifyMatchingClassesAs for more classes to capture...
 
 
TraceAnnotatedMethodsIfFlagged: MVCAsyncTracing [mscorlib]System.Runtime.CompilerServices.AsyncStateMachineAttribute AsyncStateMachineEnablingTracerV2 "NOT USED"
TraceOneMethodWithParametersIfFlagged: MVCAsyncExtendedTracing MoveNext AsyncBlamePointTracer "AsyncAPIS|{namespaceandclassname}|{method}"