public override void Visit(CosmosDiagnosticsContext cosmosDiagnosticsContext) { Assert.IsFalse(this.isContextVisited, "Point operations should only have a single context"); this.isContextVisited = true; this.StartTimeUtc = cosmosDiagnosticsContext.StartUtc; this.TotalElapsedTime = cosmosDiagnosticsContext.GetClientElapsedTime(); DiagnosticValidator.ValidateCosmosDiagnosticsContext(cosmosDiagnosticsContext); foreach (CosmosDiagnosticsInternal diagnosticsInternal in cosmosDiagnosticsContext) { diagnosticsInternal.Accept(this); } }
public override void Visit(CosmosDiagnosticsContext cosmosDiagnosticsContext) { this.isContextVisited = true; this.StartTimeUtc = cosmosDiagnosticsContext.StartUtc; this.TotalElapsedTime = cosmosDiagnosticsContext.GetClientElapsedTime(); // Buffered pages are normal and have 0 request. This causes most validation to fail. if (cosmosDiagnosticsContext.TotalRequestCount > 0) { DiagnosticValidator.ValidateCosmosDiagnosticsContext(cosmosDiagnosticsContext); } foreach (CosmosDiagnosticsInternal diagnosticsInternal in cosmosDiagnosticsContext) { diagnosticsInternal.Accept(this); } }
internal static void ValidateCosmosDiagnosticsContext( CosmosDiagnosticsContext cosmosDiagnosticsContext) { Assert.IsTrue((cosmosDiagnosticsContext.StartUtc - DateTime.UtcNow) < TimeSpan.FromHours(12), $"Start Time is not valid {cosmosDiagnosticsContext.StartUtc}"); Assert.AreNotEqual(cosmosDiagnosticsContext.UserAgent.ToString(), new UserAgentContainer().UserAgent.ToString(), "User agent not set"); Assert.IsTrue(cosmosDiagnosticsContext.TotalRequestCount > 0, "No request found"); Assert.IsFalse(cosmosDiagnosticsContext.IsComplete(), "OverallClientRequestTime should be stopped"); Assert.IsTrue(cosmosDiagnosticsContext.GetClientElapsedTime() > TimeSpan.Zero, "OverallClientRequestTime should have time."); string info = cosmosDiagnosticsContext.ToString(); Assert.IsNotNull(info); JObject jObject = JObject.Parse(info.ToString()); JToken summary = jObject["Summary"]; Assert.IsNotNull(summary["UserAgent"].ToString()); Assert.AreNotEqual(summary["UserAgent"].ToString(), new UserAgentContainer().UserAgent); Assert.IsNotNull(summary["StartUtc"].ToString()); Assert.IsNotNull(summary["TotalElapsedTime"].ToString()); }