protected override MetricAggregate CreateAggregate(DateTimeOffset periodEnd) { double last, min, max; lock (_updateLock) { if (!_data.HasValues) { return(null); } min = _data.Min; max = _data.Max; last = _data.Last; } last = Util.EnsureConcreteValue(last); min = Util.EnsureConcreteValue(min); max = Util.EnsureConcreteValue(max); MetricAggregate aggregate = new MetricAggregate( DataSeries?.MetricId ?? Util.NullString, MetricConfigurations.Common.AggregateKinds().Gauge().Moniker); aggregate.Data[MetricConfigurations.Common.AggregateKinds().Gauge().DataKeys.Last] = last; aggregate.Data[MetricConfigurations.Common.AggregateKinds().Gauge().DataKeys.Min] = min; aggregate.Data[MetricConfigurations.Common.AggregateKinds().Gauge().DataKeys.Max] = max; AddInfo_Timing_Dimensions_Context(aggregate, periodEnd); return(aggregate); }
protected override MetricAggregate CreateAggregate(DateTimeOffset periodEnd) { double sum, min, max; lock (_updateLock) { sum = _sum; min = _min; max = _max; } if (_min > _max) { return(null); } sum = Util.EnsureConcreteValue(sum); min = Util.EnsureConcreteValue(min); max = Util.EnsureConcreteValue(max); MetricAggregate aggregate = new MetricAggregate( DataSeries?.MetricId ?? Util.NullString, MetricConfigurations.Common.AggregateKinds().Accumulator().Moniker); aggregate.Data[MetricConfigurations.Common.AggregateKinds().Accumulator().DataKeys.Sum] = sum; aggregate.Data[MetricConfigurations.Common.AggregateKinds().Accumulator().DataKeys.Min] = min; aggregate.Data[MetricConfigurations.Common.AggregateKinds().Accumulator().DataKeys.Max] = max; AddInfo_Timing_Dimensions_Context(aggregate, periodEnd); return(aggregate); }
public GaugeAggregator(MetricSeriesConfigurationForGauge configuration, MetricSeries dataSeries, MetricAggregationCycleKind aggregationCycleKind) : base(MetricValuesBufferFactory, configuration, dataSeries, aggregationCycleKind) { Util.ValidateNotNull(configuration, nameof(configuration)); _restrictToUInt32Values = configuration.RestrictToUInt32Values; ResetAggregate(); }
protected override double ConvertMetricValue(double metricValue) { if (_restrictToUInt32Values) { return(Util.RoundAndValidateValue(metricValue)); } else { return(metricValue); } }
/// <summary> /// Set the configuration returned from <c>MetricConfigurations.Common.Accumulator()</c>. /// </summary> /// <param name="metricConfigPresets">Will be ignored.</param> /// <param name="defaultConfigurationForGauge">Future default config.</param> public static void SetDefaultForGauge( this MetricConfigurations metricConfigPresets, MetricConfigurationForGauge defaultConfigurationForGauge) { Util.ValidateNotNull( defaultConfigurationForGauge, nameof(defaultConfigurationForGauge)); Util.ValidateNotNull( defaultConfigurationForGauge.SeriesConfig, nameof(defaultConfigurationForGauge) + "." + nameof(defaultConfigurationForGauge.SeriesConfig)); s_defaultConfigForGauge = defaultConfigurationForGauge; }
/// <summary> /// Set the configuration returned from <c>MetricConfigurations.Common.Accumulator()</c>. /// </summary> /// <param name="metricConfigPresets">Will be ignored.</param> /// <param name="defaultConfigurationForAccumulator">Future default config.</param> public static void SetDefaultForAccumulator( this MetricConfigurations metricConfigPresets, MetricConfigurationForAccumulator defaultConfigurationForAccumulator) { Util.ValidateNotNull( defaultConfigurationForAccumulator, nameof(defaultConfigurationForAccumulator)); Util.ValidateNotNull( defaultConfigurationForAccumulator.SeriesConfig, nameof(defaultConfigurationForAccumulator) + "." + nameof(defaultConfigurationForAccumulator.SeriesConfig)); s_defaultConfigForAccumulator = defaultConfigurationForAccumulator; }
/// <summary> /// /// </summary> /// <param name="metricConfigPresets"></param> /// <param name="defaultConfigurationForGauge"></param> public static void SetDefaultForGauge( this MetricConfigurations metricConfigPresets, SimpleMetricConfiguration defaultConfigurationForGauge) { Util.ValidateNotNull(defaultConfigurationForGauge, nameof(defaultConfigurationForGauge)); Util.ValidateNotNull( defaultConfigurationForGauge.SeriesConfig, nameof(defaultConfigurationForGauge) + "." + nameof(defaultConfigurationForGauge.SeriesConfig)); if (false == (defaultConfigurationForGauge.SeriesConfig is MetricSeriesConfigurationForGauge)) { throw new ArgumentException($"{nameof(defaultConfigurationForGauge) + "." + nameof(defaultConfigurationForGauge.SeriesConfig)}" + $" must be a \"{nameof(MetricSeriesConfigurationForGauge)}\", but it is" + $" \"{defaultConfigurationForGauge.SeriesConfig.GetType().Name}\"."); } // todo validate type of series config to be measurement. s_defaultConfigForGauge = defaultConfigurationForGauge; }
protected override double ConvertMetricValue(object metricValue) { double value = Util.ConvertToDoubleValue(metricValue); return(ConvertMetricValue(value)); }