public void OnLogLine(Dictionary <DiagnosticMeasurement, float?> countersAndValues, DateTime?timestamp = null) { Dictionary <string, Dictionary <int, double> > dictionary; if (this.GetCurrentCounters(out dictionary)) { lock (this.dictLock) { foreach (KeyValuePair <string, Dictionary <int, double> > keyValuePair in dictionary) { HashSet <int> hashSet = new HashSet <int>(); try { foreach (KeyValuePair <int, double> keyValuePair2 in keyValuePair.Value) { string empty = string.Empty; if (this.perfLogExt.PidToProcessName.TryGetValue((float)keyValuePair2.Key, out empty)) { DiagnosticMeasurement measure = DiagnosticMeasurement.GetMeasure(Environment.MachineName, ".NET CLR Memory", keyValuePair.Key, empty); int num = PerfLogExtension.CounterRemapType(measure); if (num >= 0) { this.perfLogExt.RemapInstance[num].AddCounter(measure, new float?((float)keyValuePair2.Value)); } else { countersAndValues[measure] = new float?((float)keyValuePair2.Value); } } else { hashSet.Add(keyValuePair2.Key); } } this.perfLogExt.RemapInstance[1].Process(countersAndValues); double num2 = (from a in keyValuePair.Value select a.Value).Sum(); DiagnosticMeasurement measure2 = DiagnosticMeasurement.GetMeasure(Environment.MachineName, ".NET CLR Memory", keyValuePair.Key, "_Global_"); countersAndValues.Add(measure2, new float?((float)num2)); this.RemovePidsOnExit(hashSet); } catch (Exception ex) { Log.LogErrorMessage("ClrGCCalculatedCounter.OnLogLine failed due to exception {0}.", new object[] { ex }); } } } } }
public ClrGCCalculatedCounters(PerfLogExtension perfLogExt, string guidFolderPath, bool shouldCreateTimer) { this.perfLogExt = perfLogExt; this.lastStatisticsRefresh = DateTime.MinValue; this.statisticsRefreshFrequency = Configuration.GetConfigTimeSpan("EtwTraceCollectionRepeatInterval", TimeSpan.FromSeconds(30.0), TimeSpan.FromDays(7.0), TimeSpan.FromMinutes(1.0)); using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(ClrGCCalculatedCounters.DiagnosticsRegistryKey)) { if (registryKey != null) { string text = (string)registryKey.GetValue("MsiInstallPath"); string text2 = (string)registryKey.GetValue("LogFolderPath"); if (!string.IsNullOrEmpty(text)) { this.traceLogPath = string.Format("{0}\\tracelog.exe", text); } if (!string.IsNullOrEmpty(text2)) { string text3; if (guidFolderPath == null) { text3 = string.Format("{0}\\EtwTraces", text2); } else { text3 = guidFolderPath; } HashSet <Guid> etwGuids = new HashSet <Guid> { GCPrivateEventsParser.ProviderGuid }; if (!Directory.Exists(text3)) { throw new ApplicationException(string.Format("Cannot find path {0}", text3)); } this.guidFilePath = this.CreateGuidFile(text3, "guid.guid", etwGuids); this.etlFilePaths = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase) { { "CalculatedCounterTrace", Path.Combine(text3, "CalculatedCounterTrace.etl") } }; } } } this.parserCollection.Add(GCPrivateEventsParser.ProviderGuid, new GCPrivateEventsParser()); if (shouldCreateTimer) { this.statsTimer = new Timer(new TimerCallback(this.TryRefreshCounters), null, 10L, (long)this.statisticsRefreshFrequency.TotalMilliseconds); } }