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); }
public TimeSpan GetThreshold(string identity, LoggingType type) { if (string.IsNullOrEmpty(identity)) { throw new ArgumentException("Should not be null or empty.", "identity"); } LatencyDetectionLocation latencyDetectionLocation = null; if (this.locationsByName.TryGetValue(identity, out latencyDetectionLocation)) { return(latencyDetectionLocation.GetThreshold(type).Threshold); } throw new ArgumentException("Not the id of an existing location.", "identity"); }
internal static void ValidateBinningParameters(LatencyDetectionLocation location, string version, object hash) { if (location == null) { throw new ArgumentNullException("location"); } if (string.IsNullOrEmpty(version)) { throw new ArgumentException("May not be null or empty.", "version"); } if (hash == null) { throw new ArgumentNullException("hash"); } }
internal LatencyDetectionContext(LatencyDetectionLocation location, ContextOptions contextOptions, string version, object hash, params IPerformanceDataProvider[] providers) { this.latencyDetectionLocation = location; this.assemblyVersion = version; this.StackTraceContext = hash; this.contextOptions = contextOptions; if ((contextOptions & ContextOptions.DoNotMeasureTime) == ContextOptions.DoNotMeasureTime) { this.timer = null; } else { this.timer = MyStopwatch.StartNew(); } this.SetDataProviders(providers); }
void IThresholdInitializer.SetThresholdFromConfiguration(LatencyDetectionLocation location, LoggingType type) { TimeSpan threshold = location.DefaultThreshold; if (LoggingType.WindowsErrorReporting == type) { using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\ExchangeServer\\v15\\LatencyDetectionOptions")) { if (registryKey != null) { uint registryUInt = PerformanceReportingOptions.GetRegistryUInt32(registryKey, location.Identity + "ThresholdMilliseconds", PerformanceReportingOptions.GetTotalMilliseconds(location.DefaultThreshold), PerformanceReportingOptions.GetTotalMilliseconds(location.MinimumThreshold)); threshold = TimeSpan.FromMilliseconds(registryUInt); } } } location.SetThreshold(type, threshold); }
internal void ValidateLocation(LatencyDetectionLocation location) { if (location == null) { throw new ArgumentNullException("location"); } string identity = location.Identity; TimeSpan minimumThreshold = location.MinimumThreshold; if (location.MinimumThreshold < LatencyReportingThreshold.MinimumThresholdValue) { string message = string.Format(CultureInfo.InvariantCulture, "Minimum threshold for location with identity \"{0}\", {1}, is below the allowed minimum of {2}.", new object[] { identity, minimumThreshold, LatencyReportingThreshold.MinimumThresholdValue }); throw new ArgumentException(message, "location"); } LatencyDetectionLocation latencyDetectionLocation; if (this.locationsByName.TryGetValue(identity, out latencyDetectionLocation)) { if (location != latencyDetectionLocation) { string message2 = string.Format(CultureInfo.InvariantCulture, "More than one {0} found with Identity = \"{1}\"", new object[] { typeof(LatencyDetectionLocation).FullName, identity }); throw new ArgumentException(message2, "location"); } } else { this.locationsByName[identity] = location; } }
private LatencyDetectionContextFactory(LatencyDetectionLocation factoryLocation) { this.location = factoryLocation; }
public static LatencyDetectionContextFactory CreateFactory(string identity, TimeSpan minimumThreshold, TimeSpan defaultThreshold) { LatencyDetectionLocation factoryLocation = new LatencyDetectionLocation(LatencyDetectionContextFactory.thresholdInitializer, identity, minimumThreshold, defaultThreshold); return(new LatencyDetectionContextFactory(factoryLocation)); }
internal BackLog GetBackLog(int type) { LatencyDetectionLocation.CheckLoggingTypeIndex(type); return(this.backlogs[type]); }
internal LatencyReportingThreshold GetThreshold(int type) { LatencyDetectionLocation.CheckLoggingTypeIndex(type); return(this.thresholds[type]); }
internal LatencyDetectionContext(LatencyDetectionLocation location, string version, object hash, params IPerformanceDataProvider[] providers) : this(location, ContextOptions.Default, version, hash, providers) { }