Beispiel #1
0
        internal LatencyDetectionException CreateLatencyDetectionException()
        {
            LatencyDetectionException ex = null;
            int num = (int)(this.Elapsed.TotalMilliseconds / 2.0);

            if (this.HasTrustworthyCpuTime && this.timer.ElapsedCpu.TotalMilliseconds >= (double)num)
            {
                ex = new CpuLatencyDetectionException(this);
            }
            else if (this.providers.Length > 0)
            {
                for (int i = 0; i < this.providers.Length; i++)
                {
                    int milliseconds = this.taskData[i].Difference.Milliseconds;
                    if (milliseconds >= num)
                    {
                        ex = new DataProviderLatencyDetectionException(this, this.providers[i]);
                        break;
                    }
                }
            }
            if (ex == null)
            {
                ex = new LatencyDetectionException(this);
            }
            return(ex);
        }
Beispiel #2
0
 internal void Log(LatencyDetectionContext context)
 {
     foreach (KeyValuePair <LoggingType, ILatencyDetectionLogger> keyValuePair in this.loggers)
     {
         ILatencyDetectionLogger               value = keyValuePair.Value;
         LoggingType                           key   = keyValuePair.Key;
         LatencyDetectionContext               latencyDetectionContext;
         LatencyReportingThreshold             threshold;
         ICollection <LatencyDetectionContext> backlog;
         bool flag = this.checker.ShouldCreateReport(context, key, out latencyDetectionContext, out threshold, out backlog);
         if (flag)
         {
             LatencyDetectionException   exception = latencyDetectionContext.CreateLatencyDetectionException();
             PerformanceReporter.LogData state     = new PerformanceReporter.LogData(value, threshold, latencyDetectionContext, backlog, exception);
             ThreadPool.QueueUserWorkItem(PerformanceReporter.LogReportDelegate, state);
         }
     }
 }
Beispiel #3
0
 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;
 }
 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"))
     });
 }
        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);
            }
        }