Esempio n. 1
0
        /// <summary />
        /// <param name="seriesCountLimit"></param>
        /// <param name="valuesPerDimensionLimit"></param>
        /// <param name="seriesConfig"></param>
        public MetricConfiguration(
            int seriesCountLimit,
            int valuesPerDimensionLimit,
            IMetricSeriesConfiguration seriesConfig)
        {
            if (seriesCountLimit < 1)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(seriesCountLimit),
                          $"Metrics must allow at least one data series (but {seriesCountLimit} was specified).");
            }

            if (valuesPerDimensionLimit < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(valuesPerDimensionLimit));
            }

            Util.ValidateNotNull(seriesConfig, nameof(seriesConfig));

            SeriesCountLimit        = seriesCountLimit;
            ValuesPerDimensionLimit = valuesPerDimensionLimit;

            SeriesConfig = seriesConfig;

            _hashCode = Util.CombineHashCodes(
                SeriesCountLimit.GetHashCode(),
                ValuesPerDimensionLimit.GetHashCode(),
                SeriesConfig.GetType().FullName.GetHashCode(),
                SeriesConfig.GetHashCode());
        }
Esempio n. 2
0
        /// <summary>Creates a new instance of <c>MetricConfiguration</c>.</summary>
        /// <param name="seriesCountLimit">How many data time series a metric can contain as a maximum.
        /// Once this limit is reached, calls to <c>TrackValue(..)</c>, <c>TryGetDataSeries(..)</c> and similar
        /// that would normally result in new series will return <c>false</c>.</param>
        /// <param name="valuesPerDimensionLimit">How many different values each of the dimensions of a metric can
        /// have as a maximum.
        /// Once this limit is reached, calls to <c>TrackValue(..)</c>, <c>TryGetDataSeries(..)</c> and similar
        /// that would normally result in new series will return <c>false</c>.</param>
        /// <param name="seriesConfig">The configuration for how each series of this metric should be aggregated.</param>
        public MetricConfiguration(
            int seriesCountLimit,
            int valuesPerDimensionLimit,
            IMetricSeriesConfiguration seriesConfig)
        {
            if (seriesCountLimit < 1)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(seriesCountLimit),
                          Invariant($"Metrics must allow at least one data series (but {seriesCountLimit} was specified)."));
            }

            this.SeriesCountLimit = seriesCountLimit;

            if (valuesPerDimensionLimit < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(valuesPerDimensionLimit));
            }

            for (int d = 0; d < this.valuesPerDimensionLimits.Length; d++)
            {
                this.valuesPerDimensionLimits[d] = valuesPerDimensionLimit;
            }

            Util.ValidateNotNull(seriesConfig, nameof(seriesConfig));
            this.SeriesConfig = seriesConfig;

            this.hashCode = this.ComputeHashCode();
        }
 /// <summary>@ToDo: Complete documentation before stable release. {362}</summary>
 /// <param name="metricNamespace">@ToDo: Complete documentation before stable release. {953}</param>
 /// <param name="metricId">@ToDo: Complete documentation before stable release. {176}</param>
 /// <param name="config">@ToDo: Complete documentation before stable release. {016}</param>
 /// <returns>@ToDo: Complete documentation before stable release. {996}</returns>
 public MetricSeries CreateNewSeries(string metricNamespace, string metricId, IMetricSeriesConfiguration config)
 {
     return(this.CreateNewSeries(
                metricNamespace,
                metricId,
                dimensionNamesAndValues: null,
                config: config));
 }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="metricId"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public MetricSeries CreateNewSeries(string metricId, IMetricSeriesConfiguration config)
        {
            Util.ValidateNotNull(metricId, nameof(metricId));
            Util.ValidateNotNull(config, nameof(config));

            var dataSeries = new MetricSeries(_aggregationManager, metricId, null, config);

            return(dataSeries);
        }
        public DataSeriesAggregatorBase(IMetricSeriesConfiguration configuration, MetricSeries dataSeries, MetricAggregationCycleKind aggregationCycleKind)
        {
            Util.ValidateNotNull(configuration, nameof(configuration));

            _dataSeries           = dataSeries;
            _aggregationCycleKind = aggregationCycleKind;
            _isPersistent         = configuration.RequiresPersistentAggregation;

            Reset(default(DateTimeOffset), default(IMetricValueFilter));
        }
Esempio n. 6
0
        internal MetricSeries(
            MetricAggregationManager aggregationManager,
            string metricId,
            IEnumerable <KeyValuePair <string, string> > dimensionNamesAndValues,
            IMetricSeriesConfiguration configuration)
        {
            Util.ValidateNotNull(aggregationManager, nameof(aggregationManager));
            Util.ValidateNotNull(metricId, nameof(metricId));
            Util.ValidateNotNull(configuration, nameof(configuration));

            _aggregationManager           = aggregationManager;
            _metricId                     = metricId;
            _configuration                = configuration;
            _requiresPersistentAggregator = configuration.RequiresPersistentAggregation;

            var dimNameVals = new Dictionary <string, string>();

            if (dimensionNamesAndValues != null)
            {
                int dimIndex = 0;
                foreach (KeyValuePair <string, string> dimNameVal in dimensionNamesAndValues)
                {
                    if (dimNameVal.Key == null)
                    {
                        throw new ArgumentNullException($"The name for dimension at 0-based index '{dimIndex}' is null.");
                    }

                    if (String.IsNullOrWhiteSpace(dimNameVal.Key))
                    {
                        throw new ArgumentException($"The name for dimension at 0-based index '{dimIndex}' is empty or white-space");
                    }

                    if (dimNameVal.Value == null)
                    {
                        throw new ArgumentNullException($"The value for dimension '{dimNameVal.Key}' number is null.");
                    }

                    if (String.IsNullOrWhiteSpace(dimNameVal.Value))
                    {
                        throw new ArgumentNullException($"The value for dimension '{dimNameVal.Key}' is empty or white-space.");
                    }

                    dimNameVals[dimNameVal.Key] = dimNameVal.Value;
                    dimIndex++;
                }
            }

            _dimensionNamesAndValues = dimNameVals;

            _aggregatorPersistent = null;
            _aggregatorDefault    = null;
            _aggregatorQuickPulse = null;
            _aggregatorCustom     = null;
        }
Esempio n. 7
0
        /// <summary>Creates a new instance of <c>MetricConfiguration</c>.</summary>
        /// <param name="seriesCountLimit">How many data time series a metric can contain as a maximum.
        /// Once this limit is reached, calls to <c>TrackValue(..)</c>, <c>TryGetDataSeries(..)</c> and similar
        /// that would normally result in new series will return <c>false</c>.</param>
        /// <param name="valuesPerDimensionLimits">How many different values each of the dimensions of a metric can
        /// have as a maximum. If this enumeration contains less elements than the number of supported dimensions,
        /// then the last specified element is replicated for subsequent dimensions. If this enumeration contains
        /// too many elements, superflous elements are ignored.
        /// Once this limit is reached, calls to <c>TrackValue(..)</c>, <c>TryGetDataSeries(..)</c> and similar
        /// that would normally result in new series will return <c>false</c>.</param>
        /// <param name="seriesConfig">The configuration for how each series of this metric should be aggregated.</param>
        public MetricConfiguration(
            int seriesCountLimit,
            IEnumerable <int> valuesPerDimensionLimits,
            IMetricSeriesConfiguration seriesConfig)
        {
            if (seriesCountLimit < 1)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(seriesCountLimit),
                          Invariant($"Metrics must allow at least one data series (but {seriesCountLimit} was specified)."));
            }

            this.SeriesCountLimit = seriesCountLimit;

            if (valuesPerDimensionLimits == null)
            {
                throw new ArgumentNullException(nameof(valuesPerDimensionLimits));
            }

            int lastLim = 0, d = 0;

            foreach (int lim in valuesPerDimensionLimits)
            {
                lastLim = lim;

                if (lastLim < 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(valuesPerDimensionLimits) + "[" + d + "]");
                }

                this.valuesPerDimensionLimits[d] = lastLim;

                d++;
                if (d >= MetricIdentifier.MaxDimensionsCount)
                {
                    break;
                }
            }

            for (; d < this.valuesPerDimensionLimits.Length; d++)
            {
                this.valuesPerDimensionLimits[d] = lastLim;
            }

            Util.ValidateNotNull(seriesConfig, nameof(seriesConfig));
            this.SeriesConfig = seriesConfig;

            this.hashCode = this.ComputeHashCode();
        }
Esempio n. 8
0
        public MetricSeriesAggregatorBase(
            Func <MetricValuesBufferBase <TBufferedValue> > metricValuesBufferFactory,
            IMetricSeriesConfiguration configuration,
            MetricSeries dataSeries,
            MetricAggregationCycleKind aggregationCycleKind)
        {
            Util.ValidateNotNull(metricValuesBufferFactory, nameof(metricValuesBufferFactory));
            Util.ValidateNotNull(configuration, nameof(configuration));

            _dataSeries           = dataSeries;
            _aggregationCycleKind = aggregationCycleKind;
            _isPersistent         = configuration.RequiresPersistentAggregation;

            _metricValuesBufferFactory = metricValuesBufferFactory;
            _metricValuesBuffer        = InvokeMetricValuesBufferFactory();

            Reset(default(DateTimeOffset), default(IMetricValueFilter));
        }
Esempio n. 9
0
        public SimpleUInt32DataSeriesAggregator(IMetricSeriesConfiguration configuration, MetricSeries dataSeries, MetricAggregationCycleKind aggregationCycleKind)
            : base(configuration, dataSeries, aggregationCycleKind)
        {
            Util.ValidateNotNull(configuration, nameof(configuration));

            SimpleMetricSeriesConfiguration simpleSeriesConfig = configuration as SimpleMetricSeriesConfiguration;

            if (simpleSeriesConfig == null)
            {
                throw new ArgumentException(
                          $"{nameof(SimpleUInt32DataSeriesAggregator)} expects a configuration of type {nameof(SimpleMetricSeriesConfiguration)},"
                          + $" however the specified configuration is {configuration?.GetType()?.FullName ?? Util.NullString}.",
                          nameof(configuration));
            }

            if (false == simpleSeriesConfig.RestrictToUInt32Values)
            {
                throw new ArgumentException(
                          $"{nameof(SimpleUInt32DataSeriesAggregator)} expects a configuration of type {nameof(SimpleMetricSeriesConfiguration)}"
                          + $" where 'RestrictToUInt32Values' is TRUE, however it is False.",
                          nameof(configuration));
            }
        }
        /// <summary>@ToDo: Complete documentation before stable release. {064}</summary>
        /// <param name="metricNamespace">@ToDo: Complete documentation before stable release. {831}</param>
        /// <param name="metricId">@ToDo: Complete documentation before stable release. {381}</param>
        /// <param name="dimensionNamesAndValues">@ToDo: Complete documentation before stable release. {374}</param>
        /// <param name="config">@ToDo: Complete documentation before stable release. {303}</param>
        /// <returns>@ToDo: Complete documentation before stable release. {866}</returns>
        public MetricSeries CreateNewSeries(
            string metricNamespace,
            string metricId,
            IEnumerable <KeyValuePair <string, string> > dimensionNamesAndValues,
            IMetricSeriesConfiguration config)
        {
            // Create MetricIdentifier (it will also validate metricNamespace and metricId):
            List <string> dimNames = null;

            if (dimensionNamesAndValues != null)
            {
                dimNames = new List <string>();
                foreach (KeyValuePair <string, string> dimNameVal in dimensionNamesAndValues)
                {
                    dimNames.Add(dimNameVal.Key);
                }
            }

            var metricIdentifier = new MetricIdentifier(metricNamespace, metricId, dimNames);

            // Create series:
            return(this.CreateNewSeries(metricIdentifier, dimensionNamesAndValues, config));
        }
Esempio n. 11
0
        internal MetricSeries(
            MetricAggregationManager aggregationManager,
            MetricIdentifier metricIdentifier,
            IEnumerable <KeyValuePair <string, string> > dimensionNamesAndValues,
            IMetricSeriesConfiguration configuration)
        {
            // Validate and store aggregationManager:
            Util.ValidateNotNull(aggregationManager, nameof(aggregationManager));
            this.aggregationManager = aggregationManager;

            // Validate and store metricIdentifier:
            Util.ValidateNotNull(metricIdentifier, nameof(metricIdentifier));
            this.MetricIdentifier = metricIdentifier;

            // Copy dimensionNamesAndValues, validate values (keys are implicitly validated as they need to match the keys in the identifier):
            var dimNameVals = new Dictionary <string, string>();

            if (dimensionNamesAndValues != null)
            {
                int dimIndex = 0;
                foreach (KeyValuePair <string, string> dimNameVal in dimensionNamesAndValues)
                {
                    if (dimNameVal.Value == null)
                    {
                        throw new ArgumentNullException(Invariant($"The value for dimension '{dimNameVal.Key}' number is null."));
                    }

                    if (String.IsNullOrWhiteSpace(dimNameVal.Value))
                    {
                        throw new ArgumentNullException(Invariant($"The value for dimension '{dimNameVal.Key}' is empty or white-space."));
                    }

                    dimNameVals[dimNameVal.Key] = dimNameVal.Value;
                    dimIndex++;
                }
            }

            // Validate that metricIdentifier and dimensionNamesAndValues contain consistent dimension names:
            if (metricIdentifier.DimensionsCount != dimNameVals.Count)
            {
                throw new ArgumentException(Invariant($"The specified {nameof(metricIdentifier)} contains {metricIdentifier.DimensionsCount} dimensions,")
                                            + Invariant($" however the specified {nameof(dimensionNamesAndValues)} contains {dimNameVals.Count} name-value pairs with unique names."));
            }

            foreach (string dimName in metricIdentifier.GetDimensionNames())
            {
                if (false == dimNameVals.ContainsKey(dimName))
                {
                    throw new ArgumentException(Invariant($"The specified {nameof(metricIdentifier)} contains a dimension named \"{dimName}\",")
                                                + Invariant($" however the specified {nameof(dimensionNamesAndValues)} does not contain an entry for that name."));
                }
            }

            // Store copied dimensionNamesAndValues:
            this.dimensionNamesAndValues = dimNameVals;

            // Validate and store configuration:
            Util.ValidateNotNull(configuration, nameof(configuration));
            this.configuration = configuration;
            this.requiresPersistentAggregator = configuration.RequiresPersistentAggregation;

            // Init other instance vars:
            this.aggregatorPersistent = null;
            this.aggregatorDefault    = null;
            this.aggregatorQuickPulse = null;
            this.aggregatorCustom     = null;
        }
 /// <summary />
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(IMetricSeriesConfiguration other)
 {
     return(Equals((object)other));
 }
        /// <summary>@ToDo: Complete documentation before stable release. {569}</summary>
        /// <param name="metricIdentifier">@ToDo: Complete documentation before stable release. {108}</param>
        /// <param name="dimensionNamesAndValues">@ToDo: Complete documentation before stable release. {785}</param>
        /// <param name="config">@ToDo: Complete documentation before stable release. {275}</param>
        /// <returns>@ToDo: Complete documentation before stable release. {908}</returns>
        public MetricSeries CreateNewSeries(MetricIdentifier metricIdentifier, IEnumerable <KeyValuePair <string, string> > dimensionNamesAndValues, IMetricSeriesConfiguration config)
        {
            Util.ValidateNotNull(metricIdentifier, nameof(metricIdentifier));
            Util.ValidateNotNull(config, nameof(config));

            var dataSeries = new MetricSeries(this.aggregationManager, metricIdentifier, dimensionNamesAndValues, config);

            return(dataSeries);
        }
Esempio n. 14
0
 public SimpleNumberSeriesAggregatorBase(IMetricSeriesConfiguration configuration, MetricSeries dataSeries, MetricAggregationCycleKind aggregationCycleKind)
     : base(configuration, dataSeries, aggregationCycleKind)
 {
 }