public void SetUp()
        {
            nameFormatter = new FixedPrefixNameFormatter("Prefix - ");
            formattedInstanceName = nameFormatter.CreateName(instanceName);
            totalConnectionOpenedCounter = new EnterpriseLibraryPerformanceCounter(
                NewDataInstrumentationProvider.CounterCategoryName,
                NewDataInstrumentationProvider.TotalConnectionOpenedCounter,
                formattedInstanceName);
            totalConnectionFailedCounter = new EnterpriseLibraryPerformanceCounter(
                NewDataInstrumentationProvider.CounterCategoryName,
                NewDataInstrumentationProvider.TotalConnectionFailedCounter,
                formattedInstanceName);
            totalCommandsExecutedCounter = new EnterpriseLibraryPerformanceCounter(
                NewDataInstrumentationProvider.CounterCategoryName,
                NewDataInstrumentationProvider.TotalCommandsExecutedCounter,
                formattedInstanceName);
            totalCommandsFailedCounter = new EnterpriseLibraryPerformanceCounter(
                NewDataInstrumentationProvider.CounterCategoryName,
                NewDataInstrumentationProvider.TotalCommandsFailedCounter,
                formattedInstanceName);

            provider = new NewDataInstrumentationProvider(instanceName, true, true, nameFormatter);

            ClearExistingCounts();
        }
 public void SetUp()
 {
     nameFormatter = new AppDomainNameFormatter(applicationInstanceName);
     instrumentationProvider = new HashAlgorithmInstrumentationProvider(instanceName, true, true, nameFormatter);
     formattedInstanceName = nameFormatter.CreateName(instanceName);
     totalHashComparisonPerformedPerformanceCounter = new EnterpriseLibraryPerformanceCounter(HashAlgorithmInstrumentationProvider.counterCategoryName, HashAlgorithmInstrumentationProvider.TotalHashComparisonPerformedPerformanceCounterName, formattedInstanceName);
     totalHashMismatchesPerformedPerformanceCounter = new EnterpriseLibraryPerformanceCounter(HashAlgorithmInstrumentationProvider.counterCategoryName, HashAlgorithmInstrumentationProvider.TotalHashMismatchesPerformedPerformanceCounterName, formattedInstanceName);
     totalHashOperationPerformedPerformanceCounter = new EnterpriseLibraryPerformanceCounter(HashAlgorithmInstrumentationProvider.counterCategoryName, HashAlgorithmInstrumentationProvider.TotalHashOperationPerformedPerformanceCounterName, formattedInstanceName);
 }
        public void SetUp()
        {
            formatter = new AppDomainNameFormatter();
            formattedInstanceName = formatter.CreateName(instanceName);
            enabledInstrumentationProvider = new SecurityCacheProviderInstrumentationProvider(instanceName, true, true, formatter);
            disabledInstrumentationProvider = new SecurityCacheProviderInstrumentationProvider(instanceName, false, false, formatter);

            totalSecurityCacheReadPerformedCounter = new EnterpriseLibraryPerformanceCounter(SecurityCacheProviderInstrumentationProvider.PerfomanceCountersCategoryName, SecurityCacheProviderInstrumentationProvider.TotalSecurityCacheReadPerformedCounterName, formattedInstanceName);

            ClearCounters();
        }
        public void SetUp()
        {
            nameFormatter = new AppDomainNameFormatter(applicationInstanceName);
            instrumentationProvider = new LoggingInstrumentationProvider(instanceName, true, true, applicationInstanceName);
            tracerInstrumentationProvider = new TracerInstrumentationProvider(true, false, string.Empty);
            formattedInstanceName = nameFormatter.CreateName(instanceName);
            totalLoggingEventsRaised = new EnterpriseLibraryPerformanceCounter(counterCategoryName, TotalLoggingEventsRaised, formattedInstanceName);
            totalTraceListenerEntriesWritten = new EnterpriseLibraryPerformanceCounter(counterCategoryName, TotalTraceListenerEntriesWritten, formattedInstanceName);

            // Use AppDomainFriendlyName for the instance name
            nameFormatter = new AppDomainNameFormatter();
            formattedInstanceName = nameFormatter.CreateName(instanceName);

            totalTraceOperationsStartedCounter = new EnterpriseLibraryPerformanceCounter(TracerInstrumentationProvider.counterCategoryName, TracerInstrumentationProvider.TotalTraceOperationsStartedCounterName, formattedInstanceName);
        }
        public void SetUp()
        {
            var handlers = new IExceptionHandler[] { new MockThrowingExceptionHandler() };

            var instrumentationProvider = new ExceptionHandlingInstrumentationProvider(policyName, true, true,
                                                                                          "ApplicationInstanceName");
            var policyEntry = new ExceptionPolicyEntry(typeof(ArgumentException), PostHandlingAction.None, handlers, instrumentationProvider);
            var policyEntries = new Dictionary<Type, ExceptionPolicyEntry>
            {
                {typeof (ArgumentException), policyEntry}
            };

            exceptionPolicy = new ExceptionPolicyImpl(policyName, policyEntries);

            nameFormatter = new FixedPrefixNameFormatter("Prefix - ");
            provider = new ExceptionHandlingInstrumentationProvider(instanceName, true, true, nameFormatter);
            formattedInstanceName = nameFormatter.CreateName(instanceName);
            totalExceptionHandlersExecuted = new EnterpriseLibraryPerformanceCounter(counterCategoryName, TotalExceptionHandlersExecuted, formattedInstanceName);
            totalExceptionsHandled = new EnterpriseLibraryPerformanceCounter(counterCategoryName, TotalExceptionsHandled, formattedInstanceName);
        }
 /// <summary>
 /// Creates the performance counters to instrument the logging events to the instance names.
 /// </summary>
 /// <param name="instanceNames">The instance names for the performance counters.</param>
 protected override void CreatePerformanceCounters(string[] instanceNames)
 {
     exceptionHandledCounter = factory.CreateCounter(counterCategoryName, "Exceptions Handled/sec", instanceNames);
     exceptionHandlerExecutedCounter = factory.CreateCounter(counterCategoryName, "Exception Handlers Executed/sec", instanceNames);
     totalExceptionsHandledCounter = factory.CreateCounter(counterCategoryName, TotalExceptionsHandled, instanceNames);
     totalExceptionHandlersExecutedCounter = factory.CreateCounter(counterCategoryName, TotalExceptionHandlersExecuted, instanceNames);
 }
        public void IncrementsMultipleInstancesIndependently()
        {
            string firstInstanceName = "first";
            string secondInstanceName = "second";

            FixedPrefixNameFormatter formatter = new FixedPrefixNameFormatter("Baz - ");

            var connectionOpenedCounter = new EnterpriseLibraryPerformanceCounter(
                NewDataInstrumentationProvider.CounterCategoryName,
                NewDataInstrumentationProvider.TotalConnectionOpenedCounter,
                formatter.CreateName(firstInstanceName),
                formatter.CreateName(secondInstanceName));

            var firstProvider = new NewDataInstrumentationProvider(firstInstanceName, true, true, formatter);
            var secondProvider = new NewDataInstrumentationProvider(secondInstanceName, true, true, formatter);

            firstProvider.FireConnectionOpenedEvent();

            Assert.AreEqual(1, connectionOpenedCounter.GetValueFor(formatter.CreateName(firstInstanceName)));
            Assert.AreEqual(0, connectionOpenedCounter.GetValueFor(formatter.CreateName(secondInstanceName)));

            secondProvider.FireConnectionOpenedEvent();

            Assert.AreEqual(1, connectionOpenedCounter.GetValueFor(formatter.CreateName(firstInstanceName)));
            Assert.AreEqual(1, connectionOpenedCounter.GetValueFor(formatter.CreateName(secondInstanceName)));
        }
 /// <summary>
 /// Creates the performance counters to instrument an <see cref="AuthorizationProvider"/>'s events.
 /// </summary>
 /// <param name="instanceNames">The instance names for the performance counters.</param>
 protected override void CreatePerformanceCounters(string[] instanceNames)
 {
     authorizationCheckPerformedCounter
         = factory.CreateCounter(PerformanceCountersCategoryName, AuthorizationCheckPerformedCounterName, instanceNames);
     authorizationCheckFailedCounter
         = factory.CreateCounter(PerformanceCountersCategoryName, AuthorizationCheckFailedCounterName, instanceNames);
 }
        /// <summary>
        /// Creates the performance counters to instrument the caching events for the specified instance names.
        /// </summary>
        /// <param name="instanceNames">The instance names for the performance counters.</param>
        protected override void CreatePerformanceCounters(string[] instanceNames)
        {
            cacheHitsCounter = factory.CreateCounter(CounterCategoryName, "Cache Hits/sec", instanceNames);
            cacheMissesCounter = factory.CreateCounter(CounterCategoryName, "Cache Misses/sec", instanceNames);
            cacheHitRatioCounter = factory.CreateCounter(CounterCategoryName, "Cache Hit Ratio", instanceNames);
            cacheAccessAttemptsCounter = factory.CreateCounter(CounterCategoryName, "Total # of Cache Access Attempts", instanceNames);

            cacheExpiriesCounter = factory.CreateCounter(CounterCategoryName, "Cache Expiries/sec", instanceNames);

            cacheScavengedItemsCounter = factory.CreateCounter(CounterCategoryName, "Cache Scavenged Items/sec", instanceNames);

            cacheTotalEntriesCounter = factory.CreateCounter(CounterCategoryName, "Total Cache Entries", instanceNames);
            cacheUpdatedEntriesCounter = factory.CreateCounter(CounterCategoryName, "Updated Entries/sec", instanceNames);
        }
		/// <summary>
		/// Creates the performance counters to instrument the symmetric crypto events for the specified instance names.
		/// </summary>
		/// <param name="instanceNames">The instance names for the performance counters.</param>
		protected override void CreatePerformanceCounters(string[] instanceNames)
		{
			symmetricEncryptionPerformedCounter
				= factory.CreateCounter(counterCategoryName, "Symmetric Encryptions/sec", instanceNames);
			symmetricDecryptionPerformedCounter
				= factory.CreateCounter(counterCategoryName, "Symmetric Decryptions/sec", instanceNames);
		}
		/// <summary>
		/// Creates the performance counters to instrument the hash provider events for the specified instance names.
		/// </summary>
		/// <param name="instanceNames">The instance names for the performance counters.</param>
		protected override void CreatePerformanceCounters(string[] instanceNames)
		{
			hashOperationPerformedCounter
				= factory.CreateCounter(counterCategoryName, "Hash Operations/sec", instanceNames);
			hashComparisonPerformedCounter
				= factory.CreateCounter(counterCategoryName, "Hash Comparisons/sec", instanceNames);
			hashMismatchDetectedCounter
				= factory.CreateCounter(counterCategoryName, "Hash Mismatches/sec", instanceNames);
		}
		/// <summary>
		/// Creates the performance counters to instrument the logging events to the instance names.
		/// </summary>
		/// <param name="instanceNames">The instance names for the performance counters.</param>
		protected override void CreatePerformanceCounters(string[] instanceNames)
		{
			logEventRaised = factory.CreateCounter(counterCategoryName, "Logging Events Raised/sec", instanceNames);
			traceListenerEntryWritten = factory.CreateCounter(counterCategoryName, "Trace Listener Entries Written/sec", instanceNames);
            totalLoggingEventsRaised = factory.CreateCounter(counterCategoryName, TotalLoggingEventsRaised, instanceNames);
            totalTraceListenerEntriesWritten = factory.CreateCounter(counterCategoryName, TotalTraceListenerEntriesWritten, instanceNames);
		}
 /// <summary>
 /// Creates the performance counters to instrument the caching events for the specified instance names.
 /// </summary>
 /// <param name="instanceNames">The instance names for the performance counters.</param>
 protected override void CreatePerformanceCounters(string[] instanceNames)
 {
     connectionOpenedCounter = counterCache.CreateCounter(CounterCategoryName, "Connections Opened/sec", instanceNames);
     commandExecutedCounter = counterCache.CreateCounter(CounterCategoryName, "Commands Executed/sec", instanceNames);
     connectionFailedCounter = counterCache.CreateCounter(CounterCategoryName, "Connections Failed/sec", instanceNames);
     commandFailedCounter = counterCache.CreateCounter(CounterCategoryName, "Commands Failed/sec", instanceNames);
     totalConnectionOpenedCounter = counterCache.CreateCounter(CounterCategoryName, TotalConnectionOpenedCounter, instanceNames);
     totalConnectionFailedCounter = counterCache.CreateCounter(CounterCategoryName, TotalConnectionFailedCounter, instanceNames);
     totalCommandsExecutedCounter = counterCache.CreateCounter(CounterCategoryName, TotalCommandsExecutedCounter, instanceNames);
     totalCommandsFailedCounter = counterCache.CreateCounter(CounterCategoryName, TotalCommandsFailedCounter, instanceNames);
 }
        /// <summary>
        /// Creates the performance counters to instrument a <see cref="SecurityCacheProvider"/>'s events.
        /// </summary>
        /// <param name="instanceNames">The instance names for the performance counters.</param>
        protected override void CreatePerformanceCounters(string[] instanceNames)
        {
            securityCacheReadPerformedCounter
                = factory.CreateCounter(PerfomanceCountersCategoryName, SecurityCacheReadPerformedCounterName, instanceNames);

            totalSecurityCacheReadPerformedCounter
                = factory.CreateCounter(PerfomanceCountersCategoryName, TotalSecurityCacheReadPerformedCounterName, instanceNames);
        }
 /// <summary>
 /// Creates the performance counters to instrument the validation events to the instance names.
 /// </summary>
 /// <param name="instanceNames">The instance names for the performance counters.</param>
 protected override void CreatePerformanceCounters(string[] instanceNames)
 {
     validationCall = new EnterpriseLibraryPerformanceCounter(counterCategoryName, "Number of Validation Calls");
     validationSucceeded = new EnterpriseLibraryPerformanceCounter(counterCategoryName, "Number of Validation Successes");
     validationFailures = new EnterpriseLibraryPerformanceCounter(counterCategoryName, "Number of Validation Failures");
     validationCallPerSecond = new EnterpriseLibraryPerformanceCounter(counterCategoryName, "Validation Calls/sec");
     validationSucceededPerSecond = new EnterpriseLibraryPerformanceCounter(counterCategoryName, "Validation Successes/sec");
     validationFailuresPerSecond = new EnterpriseLibraryPerformanceCounter(counterCategoryName, "Validation Failures/sec");
     percentageValidationSuccesses = new EnterpriseLibraryPerformanceCounter(counterCategoryName, "% Validation Successes");
     percentageValidationSuccessesBase = new EnterpriseLibraryPerformanceCounter(counterCategoryName, "% Validation Successes Base");
 }