コード例 #1
0
        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());
        }