private void CreateIfNotExists(IEnumerable <CounterCreationData> totalCounterCreationDatas) { // размножаем счетчики по именам операций var multipliedBtOperations = operations .SelectMany(op => totalCounterCreationDatas.Select(ccd => new CounterCreationData() { CounterHelp = ccd.CounterHelp, CounterName = PerOperationCounter.CounterNameForOperation(ccd.CounterName, op), CounterType = ccd.CounterType })).Union(totalCounterCreationDatas).ToArray(); // если ес ть хотя бы один не зарегистрированный счетчик if (!PerformanceCounterCategory.Exists(MidwayClientCategoryName) || multipliedBtOperations.Any( d => !PerformanceCounterCategory.CounterExists(d.CounterName, MidwayClientCategoryName))) { // удаляем категорию и регистрируем сноваt if (PerformanceCounterCategory.Exists(MidwayClientCategoryName)) { PerformanceCounterCategory.Delete(MidwayClientCategoryName); } var counterCreationDataCollection = new CounterCreationDataCollection(multipliedBtOperations.ToArray()); PerformanceCounterCategory.Create(MidwayClientCategoryName, "Счетчики производительности веб-сервиса обмена", PerformanceCounterCategoryType.SingleInstance, counterCreationDataCollection); } }
public object BeforeSendRequest(ref Message request, IClientChannel channel) { long startTime = 0; QueryPerformanceCounter(ref startTime); var operationName = PerOperationCounter.OperationName(request); totalOperationsExecuting.Increment(operationName); operationsStartedPerSecond.Increment(operationName); return(new TicksOperationCorrelationState() { startTime = startTime, operationName = operationName }); }
private void SetupCounters() { const string totalOpsName = "# operations executed"; const string totalOpsSuccessName = "# operations success executed"; const string totalOpsFaultName = "# operations fault executed"; const string opsPerSecondName = "# operations / sec"; const string opsStartedPerSecondName = "# operations started / sec"; const string avgDurationName = "average time per operation"; const string avgDurationBaseName = "average time per operation base"; const string totalExecutingOpsName = "# operations executing"; CreateIfNotExists(new[] { new CounterCreationData { CounterName = totalOpsName, CounterHelp = "Total number of operations executed", CounterType = PerformanceCounterType.NumberOfItems32 }, new CounterCreationData { CounterName = totalOpsSuccessName, CounterHelp = "Total number of success operations executed", CounterType = PerformanceCounterType.NumberOfItems32 } , new CounterCreationData { CounterName = totalOpsFaultName, CounterHelp = "Total number of fault operations executed", CounterType = PerformanceCounterType.NumberOfItems32 }, new CounterCreationData { CounterName = opsPerSecondName, CounterHelp = "Number of operations executed per second", CounterType = PerformanceCounterType.RateOfCountsPerSecond32 }, new CounterCreationData { CounterName = opsStartedPerSecondName, CounterHelp = "Number of operations started per second", CounterType = PerformanceCounterType.RateOfCountsPerSecond32 }, new CounterCreationData { CounterName = avgDurationName, CounterHelp = "Average duration per operation execution", CounterType = PerformanceCounterType.AverageTimer32 }, new CounterCreationData { CounterName = avgDurationBaseName, CounterHelp = "Average duration per operation execution base", CounterType = PerformanceCounterType.AverageBase }, new CounterCreationData { CounterName = totalExecutingOpsName, CounterHelp = "Number of execiting operations", CounterType = PerformanceCounterType.NumberOfItems32 } }); //TODO счетчки по операциям, покажет общую карттину в разрезе операций; список операций можно достать из exchangeServiceSoapClient.Endpoint.Contract.Operations totalOperations = new PerOperationCounter(totalOpsName, operations); totalOperationsSuccess = new PerOperationCounter(totalOpsSuccessName, operations); totalOperationsFault = new PerOperationCounter(totalOpsFaultName, operations); operationsPerSecond = new PerOperationCounter(opsPerSecondName, operations); operationsStartedPerSecond = new PerOperationCounter(opsStartedPerSecondName, operations); averageDuration = new PerOperationCounter(avgDurationName, operations); averageDurationBase = new PerOperationCounter(avgDurationBaseName, operations); totalOperationsExecuting = new PerOperationCounter(totalExecutingOpsName, operations); }