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

Microsoft.ApplicationInsights.Metrics.Extensibility.MemoryMetricTelemetryPipeline

A IMetricTelemetryPipeline that holds aggregates in memory instead of sending them anywhere for processing. This is useful for local testing and debugging scenarios. An instance of this class holds up to CountLimit aggregates in memory. WHen additional aggregates are written, the oldest ones get discarded.
public const int CountLimitDefault = 1000

Default setting for how many items to hold in memory.

public int Count { get; }

Gets the current number of metric aggregates in the buffer.

public int CountLimit { get; }

Gets the max buffer size.

public MetricAggregate this[int index] { get; }

Provides access to the metric aggregates that have been written to this pipeline.

Creates a new MemoryMetricTelemetryPipeline that holds up to CountLimitDefault aggregates in memory.

public MemoryMetricTelemetryPipeline(int countLimit)

Creates a new MemoryMetricTelemetryPipeline that holds up to the specified number of aggregates in memory.

public void Clear()

Clears the buffer.

public Task FlushAsync(CancellationToken cancelToken)

No-op.

public Task TrackAsync(MetricAggregate metricAggregate, CancellationToken cancelToken)

Stores a metric aggregate in a memory buffer. The aggregate is not further processed, but it can be accessed from the buffer. If the buffer already contains CountLimit items, the oldest item (the one at index 0) gets discarded before adding the new item at the end of the buffer.