-
Notifications
You must be signed in to change notification settings - Fork 7
AI Method 2
Ahmad Sattar edited this page Oct 24, 2019
·
8 revisions
The second method of logging extends on the first by timing each execution and tracking them as dependencies,
such that a timeline of plugin execution if formed in AI.
We keep correlation of each trace item, but add a visual representation to our traces.
The timeline and logs would look like this:
- Copy the DGTracingService and IDGTracingService into your plugins project
- Insert your instrumentation key at the top of DGTracingService
- Inside
Plugin.cs
Add the following attribute above theLocalPluginContext
constructor
internal IDGTracingService DGTracingService {
get;
private set;
}
- Inside
Plugin.cs
Below line containingthis.TracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
add
this.TracingService = new DGTracingService(this.TracingService, this.PluginExecutionContext.CorrelationId);
this.DGTracingService = (IDGTracingService)this.TracingService;
- Add the following before the Try block in the
Execute
function insidePlugin.cs
var startTime = DateTime.UtcNow;
var timer = System.Diagnostics.Stopwatch.StartNew();
- Inside the Catch section of the Try/Catch/Finally secion add this to the top
timer.Stop();
localcontext.DGTracingService.TraceException(e);
- Inside the finally section of the Try/Catch/Finally secion add this to the top
timer.Stop();
localcontext.DGTracingService.TraceDependency(
localcontext.PluginExecutionContext.MessageName,
localcontext.PluginExecutionContext.PrimaryEntityName,
this.ChildClassName,
startTime, timer.Elapsed);
- If you wish to show trace class names without namespace, add the following attribute above the
Plugin
constructor
protected string ChildClassNameSimple{
get;
private set;
}
And add this inside the Plugin
constructor
this.ChildClassNameSimple = childClass.Name;