Пример #1
0
        /** Enable stats collection for the given {@link View}. */
        internal void RegisterView(IView view, IClock clock)
        {
            lock (this.lck)
            {
                this.exportedViews = null;
                this.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;
                this.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);
                }

                this.registeredViews.Add(view.Name, view);
                if (registeredMeasure == null)
                {
                    this.registeredMeasures.Add(measure.Name, measure);
                }

                this.AddMutableViewData(view.Measure.Name, MutableViewData.Create(view, clock.Now));
            }
        }
Пример #2
0
 internal IViewData GetView(IViewName viewName, IClock clock, StatsCollectionState state)
 {
     lock (this.lck)
     {
         MutableViewData view = this.GetMutableViewData(viewName);
         return(view?.ToViewData(clock.Now, state));
     }
 }
Пример #3
0
 /** 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));
     }
 }
Пример #4
0
        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));
        }
Пример #5
0
 private void AddMutableViewData(string name, MutableViewData mutableViewData)
 {
     if (this.mutableMap.ContainsKey(name))
     {
         this.mutableMap[name].Add(mutableViewData);
     }
     else
     {
         this.mutableMap.Add(name, new List <MutableViewData>()
         {
             mutableViewData
         });
     }
 }