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.GetRunningElapsedTime(); 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.GetRunningElapsedTime(); // Buffered pages are normal and have 0 request. This causes most validation to fail. if (cosmosDiagnosticsContext.GetTotalResponseCount() > 0) { DiagnosticValidator.ValidateCosmosDiagnosticsContext(cosmosDiagnosticsContext); } foreach (CosmosDiagnosticsInternal diagnosticsInternal in cosmosDiagnosticsContext) { diagnosticsInternal.Accept(this); } }
public override void Visit(CosmosDiagnosticsContext cosmosDiagnosticsContext) { this.StartTimeUtc = cosmosDiagnosticsContext.StartUtc; this.TotalElapsedTime = cosmosDiagnosticsContext.GetRunningElapsedTime(); // Only the first context needs to be validated. Inner contexts that were appended only // require the content to validated. if (!this.isContextVisited) { DiagnosticValidator.ValidateCosmosDiagnosticsContext(cosmosDiagnosticsContext); } this.isContextVisited = true; 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.IsTrue(cosmosDiagnosticsContext.UserAgent.ToString().Contains("cosmos-netstandard-sdk")); Assert.IsTrue(cosmosDiagnosticsContext.GetTotalRequestCount() > 0, "No request found"); Assert.IsTrue(cosmosDiagnosticsContext.IsComplete(), "OverallClientRequestTime should be stopped"); Assert.IsTrue(cosmosDiagnosticsContext.GetRunningElapsedTime() > TimeSpan.Zero, "OverallClientRequestTime should have time."); string info = cosmosDiagnosticsContext.ToString(); Assert.IsNotNull(info); JObject jObject = JObject.Parse(info.ToString()); Assert.IsNotNull(jObject["DiagnosticVersion"].ToString()); JToken summary = jObject["Summary"]; Assert.IsNotNull(summary["UserAgent"].ToString()); Assert.IsTrue(summary["UserAgent"].ToString().Contains("cosmos-netstandard-sdk")); Assert.IsNotNull(summary["StartUtc"].ToString()); Assert.IsNotNull(summary["TotalElapsedTimeInMs"].ToString()); }