private static void CreateReport(LatencyReportingThreshold threshold, LatencyDetectionContext trigger, ICollection <LatencyDetectionContext> dataToLog, LatencyDetectionException exception) { StringBuilder stringBuilder = new StringBuilder(Math.Min(LatencyDetectionContext.EstimatedStringCapacity * (dataToLog.Count + 1), 42000)); stringBuilder.Append("Latency Threshold: ").Append(threshold.Threshold.TotalMilliseconds).AppendLine(" ms"); stringBuilder.AppendLine("Trigger").AppendLine(trigger.ToString()); if (dataToLog.Count > 0) { stringBuilder.Append(dataToLog.Count).AppendLine(" Backlog Entries"); foreach (LatencyDetectionContext latencyDetectionContext in dataToLog) { stringBuilder.AppendLine(latencyDetectionContext.ToString()); } } stringBuilder.AppendLine(exception.StackTrace); string text = trigger.Version; if (string.IsNullOrEmpty(text)) { text = "00.00.0000.000"; } string callstack = (trigger.StackTraceContext ?? string.Empty) + Environment.NewLine + exception.StackTrace; ExWatson.SendLatencyWatsonReport(text, trigger.Location.Identity, exception.WatsonExceptionName, callstack, exception.WatsonMethodName, stringBuilder.ToString()); }
public void Log(LatencyReportingThreshold threshold, LatencyDetectionContext trigger, ICollection <LatencyDetectionContext> context, LatencyDetectionException exception) { if (threshold == null) { throw new ArgumentNullException("threshold"); } if (trigger == null) { throw new ArgumentNullException("trigger"); } if (context == null) { throw new ArgumentNullException("context"); } if (exception == null) { throw new ArgumentNullException("exception"); } DateTime utcNow = DateTime.UtcNow; if (ExWatson.LastWatsonReport + TimeSpan.FromMinutes(1.0) < utcNow && this.lastReport + PerformanceReportingOptions.Instance.WatsonThrottle < utcNow) { this.lastReport = DateTime.UtcNow; WindowsErrorReportingLogger.CreateReport(threshold, trigger, context, exception); } }
internal LogData(ILatencyDetectionLogger logger, LatencyReportingThreshold threshold, LatencyDetectionContext trigger, ICollection <LatencyDetectionContext> backlog, LatencyDetectionException exception) { this.logger = logger; this.threshold = threshold; this.trigger = trigger; this.backlog = backlog; this.exception = exception; }
internal void ChangeThresholdAndClear(LatencyReportingThreshold newThreshold) { lock (this.lockObject) { this.threshold = newThreshold; this.Clear(); } }
internal LatencyReportingThreshold SetThreshold(LoggingType logType, TimeSpan threshold) { LatencyReportingThreshold latencyReportingThreshold = new LatencyReportingThreshold(logType, threshold); this.thresholds[(int)logType] = latencyReportingThreshold; this.backlogs[(int)logType].ChangeThresholdAndClear(latencyReportingThreshold); return(latencyReportingThreshold); }
public void Log(LatencyReportingThreshold threshold, LatencyDetectionContext trigger, ICollection <LatencyDetectionContext> context, LatencyDetectionException exception) { if (threshold == null) { throw new ArgumentNullException("threshold"); } if (trigger == null) { throw new ArgumentNullException("trigger"); } if (context == null) { throw new ArgumentNullException("context"); } if (exception == null) { throw new ArgumentNullException("exception"); } LatencyEventLogger.eventLogger.LogEvent(CommonEventLogConstants.Tuple_LatencyDetection, string.Empty, new object[] { threshold.Threshold.TotalMilliseconds.ToString(), string.Format("Trigger:{0}", trigger.ToString("s")) }); }
internal BackLog(LatencyReportingThreshold threshold) { this.threshold = threshold; }
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); }