public override void Visit(CosmosDiagnosticsContext cosmosDiagnosticsContext) { this.jsonWriter.WriteStartObject(); this.jsonWriter.WritePropertyName("DiagnosticVersion"); this.jsonWriter.WriteValue(DiagnosticsVersion); this.jsonWriter.WritePropertyName("Summary"); this.jsonWriter.WriteStartObject(); this.jsonWriter.WritePropertyName("StartUtc"); this.jsonWriter.WriteValue(cosmosDiagnosticsContext.StartUtc.ToString("o", CultureInfo.InvariantCulture)); if (cosmosDiagnosticsContext.TryGetTotalElapsedTime(out TimeSpan totalElapsedTime)) { this.jsonWriter.WritePropertyName("TotalElapsedTimeInMs"); this.jsonWriter.WriteValue(totalElapsedTime.TotalMilliseconds); } else { this.jsonWriter.WritePropertyName("RunningElapsedTimeInMs"); this.jsonWriter.WriteValue(cosmosDiagnosticsContext.GetRunningElapsedTime().TotalMilliseconds); } this.jsonWriter.WritePropertyName("UserAgent"); this.jsonWriter.WriteValue(cosmosDiagnosticsContext.UserAgent); this.jsonWriter.WritePropertyName("TotalRequestCount"); this.jsonWriter.WriteValue(cosmosDiagnosticsContext.GetTotalResponseCount()); this.jsonWriter.WritePropertyName("FailedRequestCount"); this.jsonWriter.WriteValue(cosmosDiagnosticsContext.GetFailedResponseCount()); this.jsonWriter.WritePropertyName("Operation"); this.jsonWriter.WriteValue(cosmosDiagnosticsContext.OperationName); this.jsonWriter.WriteEndObject(); this.jsonWriter.WritePropertyName("Context"); this.jsonWriter.WriteStartArray(); foreach (CosmosDiagnosticsInternal cosmosDiagnosticsInternal in cosmosDiagnosticsContext) { cosmosDiagnosticsInternal.Accept(this); } this.jsonWriter.WriteEndArray(); this.jsonWriter.WriteEndObject(); }
public static void VerifyQueryDiagnostics( CosmosDiagnostics diagnostics, bool isFirstPage, bool disableDiagnostics) { string info = diagnostics.ToString(); if (disableDiagnostics) { Assert.AreEqual(string.Empty, info); return; } CosmosDiagnosticsContext diagnosticsContext = (diagnostics as CosmosDiagnosticsCore).Context; // If all the pages are buffered then several of the normal summary validation will fail. if (diagnosticsContext.GetTotalResponseCount() > 0) { DiagnosticValidator.ValidateCosmosDiagnosticsContext(diagnosticsContext); } DiagnosticValidator.ValidateQueryDiagnostics(diagnosticsContext, isFirstPage); }