<PackageReference Include="Microsoft.ApplicationInsights" Version="2.23.0" />

Microsoft.ApplicationInsights.Metrics.Extensibility.MetricSeriesAggregatorBase<TBufferedValue>

abstract class MetricSeriesAggregatorBase<TBufferedValue> : IMetricSeriesAggregator
The abstract base contain functionaity shared by most aggregators.
public MetricSeries DataSeries { get; }

Gets the data series aggregated by this aggregator.

protected MetricSeriesAggregatorBase(Func<MetricValuesBufferBase<TBufferedValue>> metricValuesBufferFactory, IMetricSeriesConfiguration configuration, MetricSeries dataSeries, MetricAggregationCycleKind aggregationCycleKind)

Initializes an aggregator instance.

Populate common fields of just-constructed metric aggregate.

Finishes the aggregation cycle.

protected abstract TBufferedValue ConvertMetricValue(double metricValue)

Concrete aggregator imlemenations override this to convert the metric value passed to the public TrackValue(..) method to the typed used by the internal buffer.

protected abstract TBufferedValue ConvertMetricValue(object metricValue)

Concrete aggregator imlemenations override this to convert the metric value passed to the public TrackValue(..) method to the typed used by the internal buffer.

protected abstract MetricAggregate CreateAggregate(DateTimeOffset periodEnd)

Concrete aggregator imlemenations override this to actually create an aggregate form the tracked matric values.

Get an aggregate of the values tracked so far without completing the ongoing aggregation cycle. May not be thread-safe.

public void Reset(DateTimeOffset periodStart)

Clear the state of this aggregator to allow it to be reused for a new aggregation cycle.

public void Reset(DateTimeOffset periodStart, IMetricValueFilter valueFilter)

Clear the state of this aggregator to allow it to be reused for a new aggregation cycle.

protected abstract void ResetAggregate()

Concrete aggregator imlemenations override this to actually reset the aggregator.

public void TrackValue(double metricValue)

Track a metric va,ue for inclusion into the current cycle.

public void TrackValue(object metricValue)

Track a metric va,ue for inclusion into the current cycle.

public bool TryRecycle()

Clear the state of this aggregator to allow it to be reused for a new aggregation cycle.

protected abstract object UpdateAggregate_Stage1(MetricValuesBufferBase<TBufferedValue> buffer, int minFlushIndex, int maxFlushIndex)

Aggregators implement updating aggregate state from buffer by implemenmting this method (UpdateAggregate_Stage1) and its sibling method UpdateAggregate_Stage2. Stage 1 is the part of the update that needs to happen while holding a lock on the metric values buffer (e.g. extracting a summary from the buffer). Stage 2 is the part of the update that does not need such a lock.

protected abstract void UpdateAggregate_Stage2(object stage1Result)

Aggregators implement updating aggregate state from buffer by implemenmting this method (UpdateAggregate_Stage2) and its sibling method UpdateAggregate_Stage1. Stage 1 is the part of the update that needs to happen while holding a lock on the metric values buffer (e.g. extracting a summary from the buffer). Stage 2 is the part of the update that does not need such a lock.