/** Enable stats collection for the given {@link View}. */ internal void RegisterView(IView view, IClock clock) { lock (_lck) { exportedViews = null; registeredViews.TryGetValue(view.Name, out IView existing); if (existing != null) { if (existing.Equals(view)) { // Ignore views that are already registered. return; } else { throw new ArgumentException("A different view with the same name is already registered: " + existing); } } IMeasure measure = view.Measure; registeredMeasures.TryGetValue(measure.Name, out IMeasure registeredMeasure); if (registeredMeasure != null && !registeredMeasure.Equals(measure)) { throw new ArgumentException("A different measure with the same name is already registered: " + registeredMeasure); } registeredViews.Add(view.Name, view); if (registeredMeasure == null) { registeredMeasures.Add(measure.Name, measure); } AddMutableViewData(view.Measure.Name, MutableViewData.Create(view, clock.Now)); } }
/** Returns a {@link ViewData} corresponding to the given {@link View.Name}. */ internal IViewData GetView(IViewName viewName, IClock clock, StatsCollectionState state) { lock (_lck) { MutableViewData view = GetMutableViewData(viewName); return(view == null ? null : view.ToViewData(clock.Now, state)); } }
public static IAggregationData Sum(this IDictionary <TagValues, IAggregationData> aggMap, IView view) { var sum = MutableViewData.CreateMutableAggregation(view.Aggregation); foreach (IAggregationData agData in aggMap.Values) { Sum(sum, agData); } return(MutableViewData.CreateAggregationData(sum, view.Measure)); }
private void AddMutableViewData(string name, MutableViewData mutableViewData) { if (mutableMap.ContainsKey(name)) { mutableMap[name].Add(mutableViewData); } else { mutableMap.Add(name, new List <MutableViewData>() { mutableViewData }); } }