public void CounterCreatedThroughFactoryCanBeIncremented()
        {
            EnterpriseLibraryPerformanceCounter counter = factory.CreateCounter(categoryName, counterName, new string[] { "foo", "bar" });

            counter.Clear();
            counter.Increment();

            Assert.AreEqual(1L, counter.Counters[0].RawValue);
            Assert.AreEqual(1L, counter.Counters[1].RawValue);
        }
示例#2
0
        public void CounterCanBeIncremented()
        {
            EnterpriseLibraryPerformanceCounter counter = counterFactory.CreateCounter(counterCategoryName, counterName, new string[] { "Total" });

            counter.Clear();
            counter.Increment();

            long expected = 1;

            Assert.AreEqual(expected, counter.Value);
        }
示例#3
0
 public void SecurityCacheReadPerformed(object sender, SecurityCacheOperationEventArgs e)
 {
     if (PerformanceCountersEnabled)
     {
         securityCacheReadPerformedCounter.Increment();
     }
     if (WmiEnabled)
     {
         FireManagementInstrumentation(new SecurityCacheReadPerformedEvent(instanceName, e.ItemType.ToString(), (e.Token == null) ? string.Empty : e.Token.Value));
     }
 }
示例#4
0
 public void HashMismatchDetected(object sender, EventArgs e)
 {
     if (PerformanceCountersEnabled)
     {
         hashMismatchDetectedCounter.Increment();
     }
     if (WmiEnabled)
     {
         ManagementInstrumentation.Fire(new HashMismatchDetectedEvent(instanceName));
     }
 }
示例#5
0
        public void CanIncrementDifferentInstancesOfSameCounter()
        {
            EnterpriseLibraryPerformanceCounter counter = counterFactory.CreateCounter(counterCategoryName, counterName, new string[] { "ctr1", "ctr2" });

            counter.Clear();
            counter.Increment();
            long expected = 1;

            Assert.AreEqual(expected, counter.GetValueFor("ctr1"));
            Assert.AreEqual(expected, counter.GetValueFor("ctr2"));
        }
示例#6
0
 public void AuthorizationCheckPerformed(object sender, AuthorizationOperationEventArgs e)
 {
     if (PerformanceCountersEnabled)
     {
         authorizationCheckPerformedCounter.Increment();
     }
     if (WmiEnabled)
     {
         FireManagementInstrumentation(new AuthorizationCheckPerformedEvent(instanceName, e.Identity, e.RuleName));
     }
 }
示例#7
0
 public void CommandFailed(object sender, CommandFailedEventArgs e)
 {
     if (PerformanceCountersEnabled)
     {
         commandFailedCounter.Increment();
     }
     if (WmiEnabled)
     {
         FireManagementInstrumentation(new CommandFailedEvent(instanceName, e.ConnectionString, e.CommandText, e.Exception.ToString()));
     }
 }
        ///<summary>
        ///</summary>
        ///<param name="typeBeingValidated"></param>
        public void NotifyConfigurationCalled(Type typeBeingValidated)
        {
            if (typeBeingValidated == null)
            {
                throw new ArgumentNullException("typeBeingValidated");
            }

            if (PerformanceCountersEnabled)
            {
                //increment counter specific to this type/ruleSet
                string instanceName = CreateInstanceName(typeBeingValidated.Name);
                validationCall.Increment(instanceName);
                validationCallPerSecond.Increment(instanceName);
                percentageValidationSuccessesBase.Increment(instanceName);

                //increment totals
                validationCall.Increment();
                validationCallPerSecond.Increment();
                percentageValidationSuccessesBase.Increment();
            }
        }
示例#9
0
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Default handler for the <see cref="NewDataInstrumentationProvider.FireCommandFailedEvent"/> event.
        /// </summary>
        /// <remarks>
        /// Increments the "Commands Failed/sec" performance counter and writes
        /// an error entry to the event log.
        /// </remarks>
        /// <param name="commandText">The text of the command that failed its execution.</param>
        /// <param name="connectionString">The connection string of the <see cref="Database"/> that executed the failed command, with credentials removed.</param>
        /// <param name="exception">The exception thrown when the command failed.</param>
        public void FireCommandFailedEvent(string commandText, string connectionString, Exception exception)
        {
            if (exception == null)
            {
                throw new ArgumentNullException("exception");
            }

            if (PerformanceCountersEnabled)
            {
                commandFailedCounter.Increment();
                totalCommandsFailedCounter.Increment();
            }
        }
        private void IncrementAverageCounter(bool shouldIncrement, long amount,
                                             string averageCounterName, string baseCounterName, string[] instances)
        {
            if (shouldIncrement)
            {
                EnterpriseLibraryPerformanceCounter counter = counterFactory.CreateCounter(
                    category, averageCounterName, instances);
                EnterpriseLibraryPerformanceCounter baseCounter = counterFactory.CreateCounter(
                    category, baseCounterName, instances);

                counter.IncrementBy(amount);
                baseCounter.Increment();
            }
        }
 public void CacheAccessed(object sender, CacheAccessedEventArgs e)
 {
     if (PerformanceCountersEnabled)
     {
         cacheAccessAttemptsCounter.Increment();
         if (e.Hit)
         {
             cacheHitRatioCounter.Increment();
             cacheHitsCounter.Increment();
         }
         else
         {
             cacheMissesCounter.Increment();
         }
     }
 }
示例#12
0
        public void IncrementingDifferentCounterInstancesCausesBaseToIncrementSeparatelyFromChildCounters()
        {
            EnterpriseLibraryPerformanceCounter counter1 = counterFactory.CreateCounter(counterCategoryName, counterName, new string[] { "Base", "A" });
            EnterpriseLibraryPerformanceCounter counter2 = counterFactory.CreateCounter(counterCategoryName, counterName, new string[] { "Base", "B" });

            counter1.Clear();
            counter2.Clear();
            counter1.Increment();
            counter2.Increment();
            long expected = 2;

            Assert.AreEqual(expected, counter1.GetValueFor("Base"));
            Assert.AreEqual(expected, counter2.GetValueFor("Base"));
            expected = 1;
            Assert.AreEqual(expected, counter1.GetValueFor("A"));
            Assert.AreEqual(expected, counter2.GetValueFor("B"));
        }
示例#13
0
 /// <summary>
 /// Fires the CacheAccessed event - reported when an item is retrieved from the
 /// cache, or if an item was requested but not found.
 /// </summary>
 /// <param name="key">The key which was used to access the cache.</param>
 /// <param name="hit"><code>true</code> if accessing the cache was successful</param>
 public void FireCacheAccessed(string key, bool hit)
 {
     if (PerformanceCountersEnabled)
     {
         cacheAccessAttemptsCounter.Increment();
         if (hit)
         {
             cacheHitRatioCounter.Increment();
             cacheHitsCounter.Increment();
             totalCacheHitsCounter.Increment();
         }
         else
         {
             cacheMissesCounter.Increment();
             totalCacheMissesCounter.Increment();
         }
     }
 }
示例#14
0
 public void Raise()
 {
     rawFraction.Increment();
     rawBase.Increment();
 }
示例#15
0
 public void Raise()
 {
     firstCounter.Increment();
     secondCounter.Increment();
 }
示例#16
0
 public void Raise()
 {
     counter.Increment();
 }