Beispiel #1
0
        /// <summary>
        /// Creates the original initialize perf counters.
        /// </summary>
        protected void CreateOrInitializePerfCounters()
        {
            // Let's create Performance counter category
            if (!PerformanceCounterCategory.Exists(Consts.PerformanceCounterCategory))
            {
                CounterDataCollection.AddRange(new CounterCreationData[] {
                    new CounterCreationData(Consts.TimeTakenCounter, string.Empty, PerformanceCounterType.NumberOfItems32),
                    new CounterCreationData(Consts.TotalErrorCounter, string.Empty, PerformanceCounterType.NumberOfItems32),
                    new CounterCreationData(Consts.TotalUnhandledErrorCounter, string.Empty, PerformanceCounterType.NumberOfItems32),
                    new CounterCreationData(Consts.TotalFailedAutomationCounter, string.Empty, PerformanceCounterType.NumberOfItems32),
                    new CounterCreationData(Consts.TotalAutomationRequestCounter, string.Empty, PerformanceCounterType.NumberOfItems32),
                    new CounterCreationData(Consts.TotalSucceededAutomationCounter, string.Empty, PerformanceCounterType.NumberOfItems32)
                });

                PerformanceCounterCategory.Create(Consts.PerformanceCounterCategory, Consts.PerformanceCounterCategory,
                                                  PerformanceCounterCategoryType.MultiInstance, CounterDataCollection);
            }

            // Let's ensure category exists and create custom performance counters
            if (PerformanceCounterCategory.Exists(Consts.PerformanceCounterCategory))
            {
                CountersAvailable.Add(PerfCounter.TimeTaken, new PerformanceCounter(Consts.PerformanceCounterCategory, Consts.TimeTakenCounter, Consts.PerformanceCounterCategory, false));
                CountersAvailable.Add(PerfCounter.ErrorCount, new PerformanceCounter(Consts.PerformanceCounterCategory, Consts.TotalErrorCounter, Consts.PerformanceCounterCategory, false));
                CountersAvailable.Add(PerfCounter.UnhandledExceptions, new PerformanceCounter(Consts.PerformanceCounterCategory, Consts.TotalUnhandledErrorCounter, Consts.PerformanceCounterCategory, false));
                CountersAvailable.Add(PerfCounter.FailedAutomations, new PerformanceCounter(Consts.PerformanceCounterCategory, Consts.TotalFailedAutomationCounter, Consts.PerformanceCounterCategory, false));
                CountersAvailable.Add(PerfCounter.TotalAutomationRequests, new PerformanceCounter(Consts.PerformanceCounterCategory, Consts.TotalAutomationRequestCounter, Consts.PerformanceCounterCategory, false));
                CountersAvailable.Add(PerfCounter.SucceededAutomations, new PerformanceCounter(Consts.PerformanceCounterCategory, Consts.TotalSucceededAutomationCounter, Consts.PerformanceCounterCategory, false));
            }
        }
Beispiel #2
0
 /// <summary>
 /// Adds the counters to instance.
 /// </summary>
 private void AddCountersToInstance()
 {
     if (PerformanceCounterCategory.Exists(CategoryName))
     {
         CountersAvailable.Add(Enums.PerfCounter.JniException, new PerformanceCounter(CategoryName, TotalJniExceptions, CategoryName, false));
         CountersAvailable.Add(Enums.PerfCounter.TotalRequests, new PerformanceCounter(CategoryName, TotalRequests, CategoryName, false));
         CountersAvailable.Add(Enums.PerfCounter.SuccessfulExecution, new PerformanceCounter(CategoryName, TotalSuccessExecution, CategoryName, false));
         CountersAvailable.Add(Enums.PerfCounter.CachedJniMethodCall, new PerformanceCounter(CategoryName, CachedJniMethodCall, CategoryName, false));
         CountersAvailable.Add(Enums.PerfCounter.ProxyGeneration, new PerformanceCounter(CategoryName, ProxyGeneration, CategoryName, false));
         CountersAvailable.Add(Enums.PerfCounter.DbJniMethodCall, new PerformanceCounter(CategoryName, DbJniMethodCall, CategoryName, false));
     }
 }