Exemplo n.º 1
0
        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.IsComplete())
            {
                this.jsonWriter.WritePropertyName("TotalElapsedTimeInMs");
            }
            else
            {
                this.jsonWriter.WritePropertyName("RunningElapsedTimeInMs");
            }

            this.jsonWriter.WriteValue(cosmosDiagnosticsContext.GetClientElapsedTime().TotalMilliseconds);

            this.jsonWriter.WritePropertyName("UserAgent");
            this.jsonWriter.WriteValue(cosmosDiagnosticsContext.UserAgent);

            this.jsonWriter.WritePropertyName("TotalRequestCount");
            this.jsonWriter.WriteValue(cosmosDiagnosticsContext.TotalRequestCount);

            this.jsonWriter.WritePropertyName("FailedRequestCount");
            this.jsonWriter.WriteValue(cosmosDiagnosticsContext.FailedRequestCount);

            this.jsonWriter.WriteEndObject();

            this.jsonWriter.WritePropertyName("Context");
            this.jsonWriter.WriteStartArray();

            foreach (CosmosDiagnosticsInternal cosmosDiagnosticsInternal in cosmosDiagnosticsContext)
            {
                cosmosDiagnosticsInternal.Accept(this);
            }

            this.jsonWriter.WriteEndArray();

            this.jsonWriter.WriteEndObject();
        }