public override void Visit(QueryPageDiagnostics queryPageDiagnostics) { this.jsonWriter.WriteStartObject(); this.jsonWriter.WritePropertyName("PKRangeId"); this.jsonWriter.WriteValue(queryPageDiagnostics.PartitionKeyRangeId); this.jsonWriter.WritePropertyName("QueryMetric"); this.jsonWriter.WriteValue(queryPageDiagnostics.QueryMetricText); this.jsonWriter.WritePropertyName("IndexUtilization"); this.jsonWriter.WriteValue(queryPageDiagnostics.IndexUtilizationText); this.jsonWriter.WritePropertyName("SchedulingTimeSpan"); queryPageDiagnostics.SchedulingTimeSpan.WriteJsonObject(this.jsonWriter); this.jsonWriter.WritePropertyName("Context"); this.jsonWriter.WriteStartArray(); foreach (CosmosDiagnosticsInternal cosmosDiagnosticsInternal in queryPageDiagnostics.DiagnosticsContext) { cosmosDiagnosticsInternal.Accept(this); } this.jsonWriter.WriteEndArray(); this.jsonWriter.WriteEndObject(); }
public override void Visit(QueryPageDiagnostics queryPageDiagnostics) { this.jsonWriter.WriteStartObject(); this.jsonWriter.WritePropertyName("PKRangeId"); this.jsonWriter.WriteValue(queryPageDiagnostics.PartitionKeyRangeId); this.jsonWriter.WritePropertyName("StartUtc"); this.jsonWriter.WriteValue(queryPageDiagnostics.DiagnosticsContext.StartUtc.ToString("o", CultureInfo.InvariantCulture)); this.jsonWriter.WritePropertyName("QueryMetric"); this.jsonWriter.WriteValue(queryPageDiagnostics.QueryMetricText); this.jsonWriter.WritePropertyName("IndexUtilization"); this.jsonWriter.WriteValue(queryPageDiagnostics.IndexUtilizationText); this.jsonWriter.WritePropertyName("ClientCorrelationId"); this.jsonWriter.WriteValue(queryPageDiagnostics.ClientCorrelationId); this.jsonWriter.WritePropertyName("Context"); this.jsonWriter.WriteStartArray(); foreach (CosmosDiagnosticsInternal cosmosDiagnosticsInternal in queryPageDiagnostics.DiagnosticsContext) { cosmosDiagnosticsInternal.Accept(this); } this.jsonWriter.WriteEndArray(); this.jsonWriter.WriteEndObject(); }
public void TestWithMalformedString() { string malformedString = "totalExecutionTimeInMs=asdf"; QueryPageDiagnostics queryPageDiagnostics = new QueryPageDiagnostics( partitionKeyRangeId: nameof(QueryPageDiagnostics.PartitionKeyRangeId), queryMetricText: malformedString, indexUtilizationText: nameof(QueryPageDiagnostics.IndexUtilizationText), diagnosticsContext: default(CosmosDiagnosticsContext)); (BackendMetricsExtractor.ParseFailureReason parseFailureReason, BackendMetrics extractedBackendMetrics) = queryPageDiagnostics.Accept(BackendMetricsExtractor.Singleton); Assert.AreEqual(BackendMetricsExtractor.ParseFailureReason.MalformedString, parseFailureReason); }