public void Initialize(string instanceName) { if (!PerformanceCounterCategory.Exists(PerformanceCategoryName)) { CreatePerformanceCounterCategory(); } BdbInstanceInfo bdbInstanceInfo; if (Instances.TryGetValue(instanceName, out bdbInstanceInfo)) { Log.Info("Performance counters instance " + instanceName + " is already exists, instance will not be re-initialized."); } else { try { bdbInstanceInfo = new BdbInstanceInfo(); int numCounters = PerformanceCounterNames.Length; bdbInstanceInfo.counters = new PerformanceCounter[numCounters]; for (int i = 0; i < numCounters; i++) { bdbInstanceInfo.counters[i] = new PerformanceCounter( PerformanceCategoryName, PerformanceCounterNames[i], instanceName, false ); } bdbInstanceInfo.getHitCounter = new MinuteAggregateCounter(); bdbInstanceInfo.getAttemptCounter = new MinuteAggregateCounter(); bdbInstanceInfo.saveHitCounter = new MinuteAggregateCounter(); bdbInstanceInfo.saveAttemptCounter = new MinuteAggregateCounter(); Instances.Add(instanceName, bdbInstanceInfo); ResetCounters(bdbInstanceInfo.counters); StartTimer(); } catch (Exception ex) { if (Log.IsErrorEnabled) { Log.ErrorFormat("BerkeleyDbCounters:Initialize() Exception creating Memory Store Counters: {0}. The counters might need to be reinstalled via InstallUtil." , ex); } } Log.DebugFormat("Performance counters instance {0} initialized.", instanceName); } }