public Guid Execute(out ErrorResultTO errors, int update)
        {
            var start = _stopwatch.ElapsedTicks;
            var errorsInstanceCounter     = _locater.GetCounter(GetDataObject().ResourceID, WarewolfPerfCounterType.ExecutionErrors);
            var concurrentInstanceCounter = _locater.GetCounter(GetDataObject().ResourceID, WarewolfPerfCounterType.ConcurrentRequests);
            var avgExecutionsInstance     = _locater.GetCounter(GetDataObject().ResourceID, WarewolfPerfCounterType.AverageExecutionTime);
            var reqPerSecond = _locater.GetCounter(GetDataObject().ResourceID, WarewolfPerfCounterType.RequestsPerSecond);
            var outErrors    = new ErrorResultTO();

            try
            {
                _recPerSecondCounter.Increment();
                _currentConnections.Increment();
                reqPerSecond.Increment();
                concurrentInstanceCounter.Increment();
                var ret = Container.Execute(out outErrors, update);
                errors = outErrors;
                return(ret);
            }
            finally
            {
                _currentConnections.Decrement();
                concurrentInstanceCounter.Decrement();
                var time = _stopwatch.ElapsedTicks - start;
                _avgTime.IncrementBy(time);
                avgExecutionsInstance.IncrementBy(time);
                if (outErrors != null)
                {
                    _totalErrors.IncrementBy(outErrors.FetchErrors().Count);
                    errorsInstanceCounter.IncrementBy(outErrors.FetchErrors().Count);
                }
            }
        }
 public PerfmonExecutionContainer(IEsbExecutionContainer container)
 {
     VerifyArgument.IsNotNull(nameof(Container), container);
     _container           = container;
     _locater             = CustomContainer.Get <IWarewolfPerformanceCounterLocater>();
     _recPerSecondCounter = _locater.GetCounter("Request Per Second");
     _currentConnections  = _locater.GetCounter("Concurrent requests currently executing");
     _avgTime             = _locater.GetCounter("Average workflow execution time");
     _totalErrors         = _locater.GetCounter("Total Errors");
     _stopwatch           = new Stopwatch();
     _stopwatch.Start();
 }
示例#3
0
        public void PerfmonContainer_Ctor_WrappedMethods()
        {
            var cont = new Cont();
            var mockPerformanceCounter  = new Mock <IWarewolfPerformanceCounter>();
            var mockPerformanceCounter2 = new Mock <IWarewolfPerformanceCounter>();
            var mockPerformanceCounter3 = new Mock <IWarewolfPerformanceCounter>();
            var mockPerformanceCounter4 = new Mock <IWarewolfPerformanceCounter>();

            _mockPerformanceCounterFactory.Setup(o => o.New(GlobalConstants.Warewolf, It.IsAny <string>(), GlobalConstants.GlobalCounterName)).Throws(new Exception("no other counters expected to be created"));
            _mockPerformanceCounterFactory.Setup(o => o.New(GlobalConstants.Warewolf, "Request Per Second", GlobalConstants.GlobalCounterName)).Returns(mockPerformanceCounter.Object);
            _mockPerformanceCounterFactory.Setup(o => o.New(GlobalConstants.Warewolf, "Concurrent requests currently executing", GlobalConstants.GlobalCounterName)).Returns(mockPerformanceCounter2.Object);
            _mockPerformanceCounterFactory.Setup(o => o.New(GlobalConstants.Warewolf, "Average workflow execution time", GlobalConstants.GlobalCounterName)).Returns(mockPerformanceCounter3.Object);
            _mockPerformanceCounterFactory.Setup(o => o.New(GlobalConstants.Warewolf, "average time per operation base", GlobalConstants.GlobalCounterName)).Returns(mockPerformanceCounter4.Object);

            //------------Setup for test--------------------------
            var perfmonContainer = new PerfmonExecutionContainer(cont);

            //------------Execute Test---------------------------
            perfmonContainer.Execute(out ErrorResultTO err, 3);
            //------------Assert Results-------------------------
            Assert.AreEqual(1, cont.CallCount);
            Assert.AreEqual(perfmonContainer.InstanceInputDefinition, "bob");
            Assert.AreEqual(perfmonContainer.InstanceOutputDefinition, "dave");
            var counter = _performanceCounterLocater.GetCounter(WarewolfPerfCounterType.RequestsPerSecond).FromSafe();

            _mockPerformanceCounterFactory.Verify(o => o.New(GlobalConstants.Warewolf, "Request Per Second", GlobalConstants.GlobalCounterName), Times.Once);
            _mockPerformanceCounterFactory.Verify(o => o.New(GlobalConstants.Warewolf, "Concurrent requests currently executing", GlobalConstants.GlobalCounterName), Times.Once);
            _mockPerformanceCounterFactory.Verify(o => o.New(GlobalConstants.Warewolf, "Average workflow execution time", GlobalConstants.GlobalCounterName), Times.Once);
            _mockPerformanceCounterFactory.Verify(o => o.New(GlobalConstants.Warewolf, "average time per operation base", GlobalConstants.GlobalCounterName), Times.Once);
            mockPerformanceCounter.Verify(o => o.Increment(), Times.Once);
            mockPerformanceCounter2.Verify(o => o.Increment(), Times.Once);
            mockPerformanceCounter3.Verify(o => o.IncrementBy(It.IsAny <long>()), Times.Once);
            mockPerformanceCounter4.Verify(o => o.Increment(), Times.Once);

            counter = _performanceCounterLocater.GetCounter(WarewolfPerfCounterType.AverageExecutionTime).FromSafe();
        }