internal void AgentInvokeEndHandler(object dispatcher, MExSession context) { MExCountersInstance instance = MExCounters.GetInstance(context.CurrentAgent.Name); long timestamp = Stopwatch.GetTimestamp(); instance.AverageAgentDelay.IncrementBy(timestamp - context.BeginInvokeTicks); instance.AverageAgentDelayBase.Increment(); instance.TotalAgentInvocations.Increment(); }
internal MExCountersInstance(string instanceName, MExCountersInstance autoUpdateTotalInstance) : base(instanceName, MExCounters.CategoryName) { bool flag = false; List <ExPerformanceCounter> list = new List <ExPerformanceCounter>(); try { this.AverageAgentDelay = new ExPerformanceCounter(base.CategoryName, "Average Agent Processing Time (sec)", instanceName, null, new ExPerformanceCounter[0]); list.Add(this.AverageAgentDelay); this.AverageAgentDelayBase = new ExPerformanceCounter(base.CategoryName, "Average Agent Processing Time Base (sec)", instanceName, null, new ExPerformanceCounter[0]); list.Add(this.AverageAgentDelayBase); this.AverageAgentProcessorUsageSynchronousInvocations = new ExPerformanceCounter(base.CategoryName, "Average CPU usage of synchronous invocations of agent (milliseconds)", instanceName, null, new ExPerformanceCounter[0]); list.Add(this.AverageAgentProcessorUsageSynchronousInvocations); this.SynchronousAgentInvocationSamples = new ExPerformanceCounter(base.CategoryName, "Samples used to calculate Average CPU usage of synchronous invocations", instanceName, null, new ExPerformanceCounter[0]); list.Add(this.SynchronousAgentInvocationSamples); this.AverageAgentProcessorUsageAsynchronousInvocations = new ExPerformanceCounter(base.CategoryName, "Average CPU usage of asynchronous invocations of agent (milliseconds)", instanceName, null, new ExPerformanceCounter[0]); list.Add(this.AverageAgentProcessorUsageAsynchronousInvocations); this.AsynchronousAgentInvocationSamples = new ExPerformanceCounter(base.CategoryName, "Samples used to calculate Average CPU usage of asynchronous invocations", instanceName, null, new ExPerformanceCounter[0]); list.Add(this.AsynchronousAgentInvocationSamples); this.TotalAgentInvocations = new ExPerformanceCounter(base.CategoryName, "Total Agent Invocations", instanceName, null, new ExPerformanceCounter[0]); list.Add(this.TotalAgentInvocations); this.TotalAgentErrorHandlingOverrides = new ExPerformanceCounter(base.CategoryName, "Total Agent Error Handling Overrides", instanceName, null, new ExPerformanceCounter[0]); list.Add(this.TotalAgentErrorHandlingOverrides); long num = this.AverageAgentDelay.RawValue; num += 1L; flag = true; } finally { if (!flag) { foreach (ExPerformanceCounter exPerformanceCounter in list) { exPerformanceCounter.Close(); } } } this.counters = list.ToArray(); }
internal void AgentInvokeReturnsHandler(object dispatcher, MExSession context) { MExCountersInstance instance = MExCounters.GetInstance(context.CurrentAgent.Name); if (context.IsAsyncAgent) { SlidingAverageCounter slidingAverageCounter = this.asynchronousAgentProcessorUsageSlidingCounters[context.CurrentAgent.SequenceNumber]; slidingAverageCounter.AddValue(context.TotalProcessorTime); long rawValue2; long rawValue = slidingAverageCounter.CalculateAverageAcrossAllSamples(out rawValue2); instance.AverageAgentProcessorUsageAsynchronousInvocations.RawValue = rawValue; instance.AsynchronousAgentInvocationSamples.RawValue = rawValue2; } else { SlidingAverageCounter slidingAverageCounter2 = this.synchronousAgentProcessorUsageSlidingCounters[context.CurrentAgent.SequenceNumber]; slidingAverageCounter2.AddValue(context.TotalProcessorTime); long rawValue4; long rawValue3 = slidingAverageCounter2.CalculateAverageAcrossAllSamples(out rawValue4); instance.AverageAgentProcessorUsageSynchronousInvocations.RawValue = rawValue3; instance.SynchronousAgentInvocationSamples.RawValue = rawValue4; } context.CleanupCpuTracker(); }