protected internal virtual void TimerFlush(object state)
{
if (QueuedEvents.Count == 0)
{
return;
}
SystemMetricEvent[] eventsToFlush = QueuedEvents.Values.ToArray();
QueuedEvents.Clear();
// Use the same timestamp for all events. Since these are
// aggregated events, individual timestamps for when the events were
// started are meaningless
DateTime eventTimestamp = DateTime.UtcNow;
foreach (SystemMetricEvent evt in eventsToFlush)
{
evt.Timestamp = eventTimestamp;
// perform the average calculation that we have postponed
evt.Average /= evt.Count;
}
WriteMetricEvents(eventsToFlush);
}