internal bool ShouldCreateReport(LatencyDetectionContext currentContext, LoggingType loggingType, out LatencyDetectionContext trigger, out LatencyReportingThreshold thresholdToCheck, out ICollection <LatencyDetectionContext> dataToLog) { bool flag = false; dataToLog = null; thresholdToCheck = null; trigger = null; if (Thread.VolatileRead(ref this.creatingReport) == 0) { LatencyDetectionLocation location = currentContext.Location; BackLog backLog = location.GetBackLog(loggingType); thresholdToCheck = location.GetThreshold(loggingType); flag = backLog.AddAndQueryThreshold(currentContext); if (flag) { flag = (Interlocked.CompareExchange(ref this.creatingReport, 1, 0) == 0); if (flag) { try { flag = backLog.IsBeyondThreshold(out trigger); if (flag) { dataToLog = this.MoveBacklogDataToReport(loggingType); } } finally { Thread.VolatileWrite(ref this.creatingReport, 0); } } } } return(flag); }
private ICollection <LatencyDetectionContext> MoveBacklogDataToReport(LoggingType type) { IDictionary <string, LatencyDetectionLocation> locations = this.thresholdCollection.Locations; int count = locations.Count; List <LatencyDetectionContext> list = null; foreach (KeyValuePair <string, LatencyDetectionLocation> keyValuePair in locations) { BackLog backLog = keyValuePair.Value.GetBackLog(type); if (list == null) { list = new List <LatencyDetectionContext>(count * backLog.Count); } backLog.MoveToList(list); } return(list); }
public bool HasHistory(string locationID) { if (string.IsNullOrEmpty(locationID)) { throw new ArgumentNullException("locationID"); } bool flag = false; LatencyDetectionLocation latencyDetectionLocation; if (this.container.Locations.TryGetValue(locationID, out latencyDetectionLocation)) { foreach (object obj in Enum.GetValues(typeof(LoggingType))) { LoggingType type = (LoggingType)obj; BackLog backLog = latencyDetectionLocation.GetBackLog(type); flag = (backLog.Count > 0); if (flag) { break; } } } return(flag); }