// Update the synopsis state as a result of new input event public void Update(ResourceEvent rawEvent) { Queue <MetricEvent> writeOutputEventQueue = null; lock (this.ThisLock) { AggregateGroupKey key = new AggregateGroupKey( rawEvent.EventSource, rawEvent.InstanceId, rawEvent.TenantId, rawEvent.Dimensions, rawEvent.Name); // Lookup the correct time window queue AggregateTimeWindowQueue timeWindowQueue = this.GetOrCreateAggregateTimeWindowQueue(key); // Update the time window queue timeWindowQueue.Update(key, rawEvent); // Check if we need to produce output events writeOutputEventQueue = this.ProduceOutputEvents(); } this.EnqueueOutputEvents(writeOutputEventQueue); }
public void Update(AggregateGroupKey key, ResourceEvent evt) { if (this.ShouldDiscard(evt)) { return; } AggregateTimeWindow aggregateTimeWindow = this.GetOrCreateAggregateTimeWindow(key, evt, this.Settings.TimeWindow); aggregateTimeWindow.Update(evt); this.AdvanceTime(evt.TimeCreated); }
// Return true if we should discard the event protected bool ShouldDiscard(ResourceEvent evt) { // If the input event belongs to a time window which we already issued output for, we must discard the input event. // Otherwise we will be in a situation where the issued output events could overlap in time. if (evt.TimeCreated < this.EndTimeLastProducedEvent) { /* * ManagementEtwProvider.Provider.EventWriteMonitoringDropEvent( * evt.Name, evt.EventSource, evt.TimeCreated.ToString(CultureInfo.InvariantCulture), this.EndTimeLastProducedEvent.ToString(CultureInfo.InvariantCulture)); */ return(true); } return(false); }
AggregateTimeWindow GetOrCreateAggregateTimeWindow(AggregateGroupKey key, ResourceEvent evt, TimeSpan timeWindow) { AggregateTimeWindow foundAggregateTimeWindow = null; // Find the correct TimeWindow that the input event belongs to foreach (AggregateTimeWindow aggregateTimeWindow in this.TimeWindowList) { // When checking if an event belongs to a time window, the window is represented as [a, b) if (evt.TimeCreated >= aggregateTimeWindow.StartTime && evt.TimeCreated < aggregateTimeWindow.EndTime) { foundAggregateTimeWindow = aggregateTimeWindow; break; } } // If the TimeWindow does not exist, create a new TimeWindow if (foundAggregateTimeWindow == null) { // We want time windows to start on well defined boundaries DateTime startTime = AggregationUtility.SnapTimeWindowStartTime(evt.TimeCreated, timeWindow); TimeSpan timeWindowSpan = timeWindow; foundAggregateTimeWindow = AggregateTimeWindow.Create(key, startTime, timeWindowSpan); if (this.TimeWindowList.Count == 0) { this.AppendNewFoundTimeWindow(foundAggregateTimeWindow, AggregateTimeWindow.Create(key, startTime.Add(timeWindowSpan), timeWindowSpan)); } else if (foundAggregateTimeWindow.StartTime >= this.TimeWindowList[this.TimeWindowList.Count - 1].EndTime) { // New TimeWindow belongs at the end. this.FillMissingTimeWindowAtEnd(key, startTime, timeWindowSpan); this.AppendNewFoundTimeWindow(foundAggregateTimeWindow, AggregateTimeWindow.Create(key, startTime.Add(timeWindowSpan), timeWindowSpan)); } else { // New TimeWindow belongs at the beginning of the list. this.FillMissingTimeWindowAtBeginning(key, foundAggregateTimeWindow.EndTime, timeWindowSpan); this.TimeWindowList.Insert(0, foundAggregateTimeWindow); } } return(foundAggregateTimeWindow); }
public void Update(ResourceEvent evt) { this.Count++; this.Total += evt.Value; if (!string.IsNullOrEmpty(evt.AdditionalData)) { this.AdditionalData = evt.AdditionalData; } if (!this.Maximum.HasValue || evt.Value > this.Maximum) { this.Maximum = evt.Value; } if (!this.Minimum.HasValue || evt.Value < this.Minimum) { this.Minimum = evt.Value; } }
// Returns true if the event matches at least one policy public void Publish(ResourceEvent evt) { this.synopsis.Update(evt); }
public void Update(ResourceEvent evt) { this.State.Update(evt); }