Esempio n. 1
0
 private void InstrumentCacheHit(PerformanceCounterCategoryMetadata targetCategory,IMethodInvocation input)
 {
     if (CacheConfiguration.Current.PerformanceCounters.InstrumentCacheTotalCounts)
     {
         PerformanceCounter.IncrementCount(FxCounters.CacheTotal.CacheHits);
     }
     if (CacheConfiguration.Current.PerformanceCounters.InstrumentCacheTargetCounts)
     {
         PerformanceCounter.IncrementCount(targetCategory.CacheHits);
     }
 }
 /// <summary>
 /// Creates performance counter category and cache performance counters
 /// </summary>
 public static void CreateCounters(PerformanceCounterCategoryMetadata category)
 {
     try
     {
         if (!PerformanceCounterCategory.Exists(category.Name))
         {
             CounterCreationDataCollection counterCollection = new CounterCreationDataCollection();
             foreach (var description in category.Counters)
             {
                 var counter = new CounterCreationData();
                 counter.CounterName = description.Name;
                 counter.CounterHelp = description.Description;
                 counter.CounterType = description.Type;
                 counterCollection.Add(counter);
             }
             PerformanceCounterCategory.Create(category.Name, category.Description, PerformanceCounterCategoryType.SingleInstance, counterCollection);
             Log.Debug("{0} counter category Created", category.Name);
         }
     }
     catch (Exception ex)
     {
         Log.Warn("Instrumentation.CreateCounters failed, performance counters may not be initialised. Error: {0}", ex.FullMessage());
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Creates performance counter category and cache performance counters
 /// </summary>
 public static void CreateCounters(PerformanceCounterCategoryMetadata category)
 {
     try
     {
         if (!PerformanceCounterCategory.Exists(category.Name))
         {
             CounterCreationDataCollection counterCollection = new CounterCreationDataCollection();
             foreach (var description in category.Counters)
             {
                 var counter = new CounterCreationData();
                 counter.CounterName = description.Name;
                 counter.CounterHelp = description.Description;
                 counter.CounterType = description.Type;
                 counterCollection.Add(counter);
             }
             PerformanceCounterCategory.Create(category.Name, category.Description, PerformanceCounterCategoryType.SingleInstance, counterCollection);
             Log.Debug("{0} counter category Created", category.Name);
         }
     }
     catch (Exception ex)
     {
         Log.Warn("Instrumentation.CreateCounters failed, performance counters may not be initialised. Error: {0}", ex.FullMessage());
     }
 }
Esempio n. 4
0
 private static PerformanceCounterCategoryMetadata InstrumentCacheRequest(IMethodInvocation input)
 {
     PerformanceCounterCategoryMetadata category = null;
     if (CacheConfiguration.Current.PerformanceCounters.InstrumentCacheTotalCounts)
     {
         PerformanceCounter.IncrementCount(FxCounters.CacheTotal.CacheRequests);
     }
     if (CacheConfiguration.Current.PerformanceCounters.InstrumentCacheTargetCounts)
     {
         var cacheKey = CacheKeyBuilder.GetCacheKeyPrefix(input);
         category = new PerformanceCounterCategoryMetadata()
         {
             Name = CacheConfiguration.Current.PerformanceCounters.CategoryNamePrefix + " - " + cacheKey,
             Description = PerformanceCounterCategoryMetadata.DefaultDescription
         };
         PerformanceCounter.IncrementCount(category.CacheRequests);
     }
     return category;
 }