public void Stats(CounterSet snapshot) { if (IsEnabled()) { var oldActivity = Guid.Empty; var buildActivity = Environment.GetEnvironmentVariable("_MS_ENGSYS_ACTIVITY_ID"); Guid activity; if (buildActivity != null && Guid.TryParse(buildActivity, out activity)) { SetCurrentThreadActivityId(activity, out oldActivity); } WriteEvent((int)StatsEventId.Stats, snapshot.ToDictionaryIntegral()); if (oldActivity != Guid.Empty) { SetCurrentThreadActivityId(oldActivity); } } }
/// <summary> /// Gets the counters collected by this tracer instance. /// </summary> public CounterSet GetCounters() { var aggregatedCounters = new CounterSet(); aggregatedCounters.Merge(ContentSessionTracer.GetCounters()); var countersStored = aggregatedCounters.ToDictionaryIntegral(); foreach (var counter in MemoizationStoreTracer.GetCounters().ToDictionaryIntegral()) { if (!countersStored.ContainsKey(counter.Key)) { aggregatedCounters.Add(counter.Key, counter.Value); } } foreach (Counter counter in _counters) { aggregatedCounters.Add(counter.Name, counter.Value); } return(aggregatedCounters); }