예제 #1
0
        internal void AddAggregation(double value, string property1 = null, string property2 = null, string property3 = null)
        {
            if (!string.IsNullOrWhiteSpace(property1))
            {
                if (this.property1Values == null)
                {
                    this.property1Values = new ConcurrentDictionary <string, string>();
                }

                property1 = GetPropertyValue(this.property1Values, property1);
            }

            if (!string.IsNullOrWhiteSpace(property2))
            {
                if (this.property2Values == null)
                {
                    this.property2Values = new ConcurrentDictionary <string, string>();
                }

                property2 = GetPropertyValue(this.property2Values, property2);
            }

            if (!string.IsNullOrWhiteSpace(property3))
            {
                if (this.property3Values == null)
                {
                    this.property3Values = new ConcurrentDictionary <string, string>();
                }

                property3 = GetPropertyValue(this.property3Values, property3);
            }

            int aggregationKey = GetAggregationKey(property1, property2, property3);

            MetricsBag counterData = this.aggregations.GetOrAdd(aggregationKey, (key) =>
            {
                return(new MetricsBag(property1, property2, property3));
            });

            Debug.Assert(this.aggregations.Count <= (Constants.MaxPropertyCardinality + 2) * (Constants.MaxPropertyCardinality + 2) * (Constants.MaxPropertyCardinality + 2));

            counterData.Add(value);
        }