Example #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));
            }
        }
Example #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));
     }
 }
Example #3
0
 /// <summary>
 /// Releases unmanaged and - optionally - managed resources.
 /// </summary>
 /// <param name="isDisposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
 protected virtual void Dispose(bool isDisposing)
 {
     if (!IsDisposed)
     {
         if (isDisposing)
         {
             if (CountersAvailable != null && CountersAvailable.Count > 0)
             {
                 CountersAvailable.ToList().ForEach(x => {
                     x.Value.Close();
                     x.Value.Dispose();
                 });
             }
         }
         IsDisposed = true;
     }
 }
Example #4
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="isDisposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool isDisposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (isDisposing)
            {
                var counters = CountersAvailable.ToList();

                counters.ForEach(_ => {
                    _.Value?.Close();
                    _.Value?.Dispose();
                });
            }
            _isDisposed = true;
        }
Example #5
0
 /// <summary>
 /// Gets the <see cref="PerformanceCounter" /> with the specified counter name.
 /// </summary>
 /// <value>
 /// The <see cref="PerformanceCounter" />.
 /// </value>
 /// <param name="counterName">Name of the counter.</param>
 /// <returns></returns>
 public PerformanceCounter this[PerfCounter counterName] {
     get {
         var retval = CountersAvailable.ContainsKey(counterName) ? CountersAvailable[counterName] : null;
         return(retval);
     }
 }
Example #6
0
 /// <summary>
 /// Gets the <see cref="PerformanceCounter"/> with the specified counter name.
 /// </summary>
 /// <value>
 /// The <see cref="PerformanceCounter"/>.
 /// </value>
 /// <param name="counterName">Name of the counter.</param>
 /// <returns></returns>
 public PerformanceCounter this[Enums.PerfCounter counterName] {
     get {
         return(CountersAvailable.ContainsKey(counterName) ? CountersAvailable[counterName] : null);
     }
 }