From 85aba0fb0fcede87e9a9b23acdf291a30aad1932 Mon Sep 17 00:00:00 2001 From: Jake Willey Date: Thu, 15 Apr 2021 13:17:10 -0700 Subject: [PATCH 1/3] CosmosDiagnostics: Adds optimizations --- .../src/Authorization/TokenCredentialCache.cs | 42 +- .../src/Diagnostics/StoreResultStatistics.cs | 94 - .../Headers/CosmosMessageHeadersInternal.cs | 6 + Microsoft.Azure.Cosmos/src/Headers/Headers.cs | 6 + .../src/Headers/StoreResponseHeaders.cs | 9 +- .../src/HttpClient/CosmosHttpClientCore.cs | 14 +- .../PointOperationStatisticsTraceDatum.cs | 5 +- .../Tracing/TraceWriter.TraceJsonWriter.cs | 186 +- Microsoft.Azure.Cosmos/src/Util/Extensions.cs | 6 +- ...iterBaselineTests.BatchOperationsAsync.xml | 54 +- ...riterBaselineTests.BulkOperationsAsync.xml | 5002 +---------------- ...aceWriterBaselineTests.ChangeFeedAsync.xml | 1713 +----- ...eWriterBaselineTests.MiscellanousAsync.xml | 92 +- ...neTests.PointOperationsExceptionsAsync.xml | 491 +- ...EndTraceWriterBaselineTests.QueryAsync.xml | 1224 +--- ...TraceWriterBaselineTests.ReadFeedAsync.xml | 1248 +--- ...selineTests.StreamPointOperationsAsync.xml | 160 +- ...aselineTests.TypedPointOperationsAsync.xml | 175 +- .../CosmosContainerTests.cs | 2 +- .../CosmosDatabaseTests.cs | 2 +- ...raceWriterBaselineTests.ScenariosAsync.xml | 634 +-- ...TraceWriterBaselineTests.Serialization.xml | 75 +- .../TraceWriterBaselineTests.TraceData.xml | 80 +- .../Batch/BatchAsyncContainerExecutorTests.cs | 3 +- .../Batch/PartitionKeyBatchResponseTests.cs | 3 +- ...titionKeyRangeBatchExecutionResultTests.cs | 3 +- .../CosmosAuthorizationTests.cs | 9 +- .../Tracing/TraceTests.cs | 66 + .../Tracing/TraceWriterBaselineTests.cs | 8 +- 29 files changed, 1078 insertions(+), 10334 deletions(-) delete mode 100644 Microsoft.Azure.Cosmos/src/Diagnostics/StoreResultStatistics.cs diff --git a/Microsoft.Azure.Cosmos/src/Authorization/TokenCredentialCache.cs b/Microsoft.Azure.Cosmos/src/Authorization/TokenCredentialCache.cs index 70f873d652..480d55984f 100644 --- a/Microsoft.Azure.Cosmos/src/Authorization/TokenCredentialCache.cs +++ b/Microsoft.Azure.Cosmos/src/Authorization/TokenCredentialCache.cs @@ -176,18 +176,8 @@ private async ValueTask RefreshCachedTokenWithRetryHelperAsync(ITrace trace) { lastException = requestFailedException; getTokenTrace.AddDatum( - "Request Failed Exception", - new PointOperationStatisticsTraceDatum( - activityId: System.Diagnostics.Trace.CorrelationManager.ActivityId.ToString(), - statusCode: (HttpStatusCode)requestFailedException.Status, - subStatusCode: SubStatusCodes.Unknown, - responseTimeUtc: DateTime.UtcNow, - requestCharge: default, - errorMessage: requestFailedException.ToString(), - method: default, - requestUri: null, - requestSessionToken: default, - responseSessionToken: default)); + $"RequestFailedException at {DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)}", + requestFailedException); DefaultTrace.TraceError($"TokenCredential.GetToken() failed with RequestFailedException. scope = {string.Join(";", this.tokenRequestContext.Scopes)}, retry = {retry}, Exception = {lastException}"); @@ -203,18 +193,8 @@ private async ValueTask RefreshCachedTokenWithRetryHelperAsync(ITrace trace) { lastException = operationCancelled; getTokenTrace.AddDatum( - "Request Timeout Exception", - new PointOperationStatisticsTraceDatum( - activityId: System.Diagnostics.Trace.CorrelationManager.ActivityId.ToString(), - statusCode: HttpStatusCode.RequestTimeout, - subStatusCode: SubStatusCodes.Unknown, - responseTimeUtc: DateTime.UtcNow, - requestCharge: default, - errorMessage: operationCancelled.ToString(), - method: default, - requestUri: null, - requestSessionToken: default, - responseSessionToken: default)); + $"OperationCanceledException at {DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)}", + operationCancelled); DefaultTrace.TraceError( $"TokenCredential.GetTokenAsync() failed. scope = {string.Join(";", this.tokenRequestContext.Scopes)}, retry = {retry}, Exception = {lastException}"); @@ -232,18 +212,8 @@ private async ValueTask RefreshCachedTokenWithRetryHelperAsync(ITrace trace) { lastException = exception; getTokenTrace.AddDatum( - "Internal Server Error Exception", - new PointOperationStatisticsTraceDatum( - activityId: System.Diagnostics.Trace.CorrelationManager.ActivityId.ToString(), - statusCode: HttpStatusCode.InternalServerError, - subStatusCode: SubStatusCodes.Unknown, - responseTimeUtc: DateTime.UtcNow, - requestCharge: default, - errorMessage: exception.ToString(), - method: default, - requestUri: null, - requestSessionToken: default, - responseSessionToken: default)); + $"Exception at {DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)}", + exception); DefaultTrace.TraceError( $"TokenCredential.GetTokenAsync() failed. scope = {string.Join(";", this.tokenRequestContext.Scopes)}, retry = {retry}, Exception = {lastException}"); diff --git a/Microsoft.Azure.Cosmos/src/Diagnostics/StoreResultStatistics.cs b/Microsoft.Azure.Cosmos/src/Diagnostics/StoreResultStatistics.cs deleted file mode 100644 index cc3bddc7e4..0000000000 --- a/Microsoft.Azure.Cosmos/src/Diagnostics/StoreResultStatistics.cs +++ /dev/null @@ -1,94 +0,0 @@ -//------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -//------------------------------------------------------------ -namespace Microsoft.Azure.Cosmos.Diagnostics -{ - using System; - using System.Globalization; - using System.Text; - using Microsoft.Azure.Documents; - - internal sealed class StoreResultStatistics - { - public DocumentClientException Exception { get; } - - public long LSN { get; } - - public string PartitionKeyRangeId { get; } - - public long GlobalCommittedLSN { get; } - - public long ItemLSN { get; } - - public ISessionToken SessionToken { get; } - - public bool UsingLocalLSN { get; } - - public bool IsValid { get; } - - public Uri StorePhysicalAddress { get; } - - public StatusCodes StatusCode { get; } - - public SubStatusCodes SubStatusCode { get; } - - public string ActivityId { get; } - - public double RequestCharge { get; } - - public StoreResultStatistics( - DocumentClientException exception, - StatusCodes statusCode, - SubStatusCodes subStatusCode, - string partitionKeyRangeId, - long lsn, - double requestCharge, - bool isValid, - Uri storePhysicalAddress, - long globalCommittedLSN, - long itemLSN, - ISessionToken sessionToken, - bool usingLocalLSN, - string activityId) - { - this.Exception = exception; - this.StatusCode = statusCode; - this.SubStatusCode = subStatusCode; - this.PartitionKeyRangeId = partitionKeyRangeId; - this.LSN = lsn; - this.RequestCharge = requestCharge; - this.IsValid = isValid; - this.StorePhysicalAddress = storePhysicalAddress; - this.GlobalCommittedLSN = globalCommittedLSN; - this.ItemLSN = itemLSN; - this.SessionToken = sessionToken; - this.UsingLocalLSN = usingLocalLSN; - this.ActivityId = activityId; - } - - public override string ToString() - { - StringBuilder stringBuilder = new StringBuilder(); - - stringBuilder.AppendFormat( - CultureInfo.InvariantCulture, - "StorePhysicalAddress: {0}, LSN: {1}, GlobalCommittedLsn: {2}, PartitionKeyRangeId: {3}, IsValid: {4}, StatusCode: {5}, SubStatusCode: {6}, " + - "RequestCharge: {7}, ItemLSN: {8}, SessionToken: {9}, UsingLocalLSN: {10}, TransportException: {11}", - this.StorePhysicalAddress, - this.LSN, - this.GlobalCommittedLSN, - this.PartitionKeyRangeId, - this.IsValid, - (int)this.StatusCode, - (int)this.SubStatusCode, - this.RequestCharge, - this.ItemLSN, - this.SessionToken?.ConvertToString(), - this.UsingLocalLSN, - this.Exception?.InnerException is TransportException ? this.Exception.InnerException.Message : "null"); - - return stringBuilder.ToString(); - } - - } -} \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/src/Headers/CosmosMessageHeadersInternal.cs b/Microsoft.Azure.Cosmos/src/Headers/CosmosMessageHeadersInternal.cs index bc792997ed..a60a02473c 100644 --- a/Microsoft.Azure.Cosmos/src/Headers/CosmosMessageHeadersInternal.cs +++ b/Microsoft.Azure.Cosmos/src/Headers/CosmosMessageHeadersInternal.cs @@ -87,6 +87,12 @@ public virtual string QueryMetrics set => this.SetProperty(HttpConstants.HttpHeaders.QueryMetrics, value); } + public virtual string BELatencyInMs + { + get => this.GetValueOrDefault(HttpConstants.HttpHeaders.BackendRequestDurationMilliseconds); + set => this.SetProperty(HttpConstants.HttpHeaders.BackendRequestDurationMilliseconds, value); + } + public virtual string Location { get => this.GetValueOrDefault(HttpConstants.HttpHeaders.Location); diff --git a/Microsoft.Azure.Cosmos/src/Headers/Headers.cs b/Microsoft.Azure.Cosmos/src/Headers/Headers.cs index 9369621c04..23e1978631 100644 --- a/Microsoft.Azure.Cosmos/src/Headers/Headers.cs +++ b/Microsoft.Azure.Cosmos/src/Headers/Headers.cs @@ -195,6 +195,12 @@ internal virtual string QueryMetricsText set => this.CosmosMessageHeaders.QueryMetrics = value; } + internal virtual string BELatencyInMs + { + get => this.CosmosMessageHeaders.QueryMetrics; + set => this.CosmosMessageHeaders.QueryMetrics = value; + } + /// /// Creates a new instance of . /// diff --git a/Microsoft.Azure.Cosmos/src/Headers/StoreResponseHeaders.cs b/Microsoft.Azure.Cosmos/src/Headers/StoreResponseHeaders.cs index b4b5305893..7c271ef375 100644 --- a/Microsoft.Azure.Cosmos/src/Headers/StoreResponseHeaders.cs +++ b/Microsoft.Azure.Cosmos/src/Headers/StoreResponseHeaders.cs @@ -5,11 +5,8 @@ namespace Microsoft.Azure.Cosmos { using System; - using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; - using System.Globalization; - using Microsoft.Azure.Documents; using Microsoft.Azure.Documents.Collections; /// @@ -49,6 +46,12 @@ public override string QueryMetrics set => this.storeResponseNameValueCollection.QueryMetrics = value; } + public override string BELatencyInMs + { + get => this.storeResponseNameValueCollection.BackendRequestDurationMilliseconds; + set => this.storeResponseNameValueCollection.BackendRequestDurationMilliseconds = value; + } + public override string Continuation { get => this.storeResponseNameValueCollection.Continuation; diff --git a/Microsoft.Azure.Cosmos/src/HttpClient/CosmosHttpClientCore.cs b/Microsoft.Azure.Cosmos/src/HttpClient/CosmosHttpClientCore.cs index ffe9fa0395..177fc9b132 100644 --- a/Microsoft.Azure.Cosmos/src/HttpClient/CosmosHttpClientCore.cs +++ b/Microsoft.Azure.Cosmos/src/HttpClient/CosmosHttpClientCore.cs @@ -258,18 +258,8 @@ private async Task SendHttpHelperAsync( { // Log the error message trace.AddDatum( - "Error", - new PointOperationStatisticsTraceDatum( - activityId: System.Diagnostics.Trace.CorrelationManager.ActivityId.ToString(), - statusCode: HttpStatusCode.ServiceUnavailable, - subStatusCode: SubStatusCodes.Unknown, - responseTimeUtc: DateTime.UtcNow, - requestCharge: 0, - errorMessage: e.ToString(), - method: requestMessage.Method, - requestUri: requestMessage.RequestUri.OriginalString, - requestSessionToken: null, - responseSessionToken: null)); + $"Error at {DateTime.UtcNow}", + e); bool isOutOfRetries = (DateTime.UtcNow - startDateTimeUtc) > timeoutPolicy.MaximumRetryTimeLimit || // Maximum of time for all retries !timeoutEnumerator.MoveNext(); // No more retries are configured diff --git a/Microsoft.Azure.Cosmos/src/Tracing/TraceData/PointOperationStatisticsTraceDatum.cs b/Microsoft.Azure.Cosmos/src/Tracing/TraceData/PointOperationStatisticsTraceDatum.cs index a44fbb9068..048b54445d 100644 --- a/Microsoft.Azure.Cosmos/src/Tracing/TraceData/PointOperationStatisticsTraceDatum.cs +++ b/Microsoft.Azure.Cosmos/src/Tracing/TraceData/PointOperationStatisticsTraceDatum.cs @@ -21,7 +21,8 @@ public PointOperationStatisticsTraceDatum( HttpMethod method, string requestUri, string requestSessionToken, - string responseSessionToken) + string responseSessionToken, + string beLatencyInMs) { this.ActivityId = activityId; this.StatusCode = statusCode; @@ -33,6 +34,7 @@ public PointOperationStatisticsTraceDatum( this.RequestSessionToken = requestSessionToken; this.ResponseSessionToken = responseSessionToken; this.ResponseTimeUtc = responseTimeUtc; + this.BELatencyInMs = beLatencyInMs; } public string ActivityId { get; } @@ -45,6 +47,7 @@ public PointOperationStatisticsTraceDatum( public string RequestUri { get; } public string RequestSessionToken { get; } public string ResponseSessionToken { get; } + public string BELatencyInMs { get; } internal override void Accept(ITraceDatumVisitor traceDatumVisitor) { diff --git a/Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.TraceJsonWriter.cs b/Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.TraceJsonWriter.cs index 57e79e54e2..7202b8fc7a 100644 --- a/Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.TraceJsonWriter.cs +++ b/Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.TraceJsonWriter.cs @@ -7,8 +7,10 @@ namespace Microsoft.Azure.Cosmos.Tracing using System; using System.Collections.Generic; using System.Globalization; + using System.Linq; using Microsoft.Azure.Cosmos.Json; using Microsoft.Azure.Cosmos.Tracing.TraceData; + using Microsoft.Azure.Documents; internal static partial class TraceWriter { @@ -36,22 +38,25 @@ public static void WriteTrace( writer.WriteFieldName("id"); writer.WriteStringValue(trace.Id.ToString()); - writer.WriteFieldName("component"); - writer.WriteStringValue(trace.Component.ToString()); - - writer.WriteFieldName("caller info"); - writer.WriteObjectStart(); + // Request handler use the base class to create the trace. + // This makes it pointless to log the caller info because + // it is always just the base class info. + if (trace.Component != TraceComponent.RequestHandler) + { + writer.WriteFieldName("caller info"); + writer.WriteObjectStart(); - writer.WriteFieldName("member"); - writer.WriteStringValue(trace.CallerInfo.MemberName); + writer.WriteFieldName("member"); + writer.WriteStringValue(trace.CallerInfo.MemberName); - writer.WriteFieldName("file"); - writer.WriteStringValue(GetFileNameFromPath(trace.CallerInfo.FilePath)); + writer.WriteFieldName("file"); + writer.WriteStringValue(GetFileNameFromPath(trace.CallerInfo.FilePath)); - writer.WriteFieldName("line"); - writer.WriteNumber64Value(trace.CallerInfo.LineNumber); + writer.WriteFieldName("line"); + writer.WriteNumber64Value(trace.CallerInfo.LineNumber); - writer.WriteObjectEnd(); + writer.WriteObjectEnd(); + } writer.WriteFieldName("start time"); writer.WriteStringValue(trace.StartTime.ToString("hh:mm:ss:fff")); @@ -59,30 +64,35 @@ public static void WriteTrace( writer.WriteFieldName("duration in milliseconds"); writer.WriteNumber64Value(trace.Duration.TotalMilliseconds); - writer.WriteFieldName("data"); - writer.WriteObjectStart(); - - foreach (KeyValuePair kvp in trace.Data) + if (trace.Data.Any()) { - string key = kvp.Key; - object value = kvp.Value; + writer.WriteFieldName("data"); + writer.WriteObjectStart(); - writer.WriteFieldName(key); - WriteTraceDatum(writer, value); - } + foreach (KeyValuePair kvp in trace.Data) + { + string key = kvp.Key; + object value = kvp.Value; - writer.WriteObjectEnd(); + writer.WriteFieldName(key); + WriteTraceDatum(writer, value); + } - writer.WriteFieldName("children"); - writer.WriteArrayStart(); + writer.WriteObjectEnd(); + } - foreach (ITrace child in trace.Children) + if (trace.Children.Any()) { - WriteTrace(writer, child); - } + writer.WriteFieldName("children"); + writer.WriteArrayStart(); - writer.WriteArrayEnd(); + foreach (ITrace child in trace.Children) + { + WriteTrace(writer, child); + } + writer.WriteArrayEnd(); + } writer.WriteObjectEnd(); } } @@ -182,6 +192,9 @@ public void Visit(PointOperationStatisticsTraceDatum pointOperationStatisticsTra this.jsonWriter.WriteFieldName("ResponseSessionToken"); this.WriteStringValueOrNull(pointOperationStatisticsTraceDatum.ResponseSessionToken); + this.jsonWriter.WriteFieldName("BELatencyInMs"); + this.WriteStringValueOrNull(pointOperationStatisticsTraceDatum.BELatencyInMs); + this.jsonWriter.WriteObjectEnd(); } @@ -211,7 +224,7 @@ public void Visit(ClientSideRequestStatisticsTraceDatum clientSideRequestStatist foreach (ClientSideRequestStatisticsTraceDatum.StoreResponseStatistics stat in clientSideRequestStatisticsTraceDatum.StoreResponseStatisticsList) { - VisitStoreResponseStatistics(stat, this.jsonWriter); + this.VisitStoreResponseStatistics(stat); } this.jsonWriter.WriteArrayEnd(); @@ -251,48 +264,30 @@ private static void VisitAddressResolutionStatistics( jsonWriter.WriteObjectEnd(); } - private static void VisitStoreResponseStatistics( - ClientSideRequestStatisticsTraceDatum.StoreResponseStatistics storeResponseStatistics, - IJsonWriter jsonWriter) + private void VisitStoreResponseStatistics( + ClientSideRequestStatisticsTraceDatum.StoreResponseStatistics storeResponseStatistics) { - jsonWriter.WriteObjectStart(); + this.jsonWriter.WriteObjectStart(); - jsonWriter.WriteFieldName("ResponseTimeUTC"); - jsonWriter.WriteStringValue(storeResponseStatistics.RequestResponseTime.ToString("o", CultureInfo.InvariantCulture)); + this.jsonWriter.WriteFieldName("ResponseTimeUTC"); + this.jsonWriter.WriteStringValue(storeResponseStatistics.RequestResponseTime.ToString("o", CultureInfo.InvariantCulture)); - jsonWriter.WriteFieldName("ResourceType"); - jsonWriter.WriteStringValue(storeResponseStatistics.RequestResourceType.ToString()); + this.jsonWriter.WriteFieldName("ResourceType"); + this.jsonWriter.WriteStringValue(storeResponseStatistics.RequestResourceType.ToString()); - jsonWriter.WriteFieldName("OperationType"); - jsonWriter.WriteStringValue(storeResponseStatistics.RequestOperationType.ToString()); + this.jsonWriter.WriteFieldName("OperationType"); + this.jsonWriter.WriteStringValue(storeResponseStatistics.RequestOperationType.ToString()); - jsonWriter.WriteFieldName("LocationEndpoint"); - if (storeResponseStatistics.LocationEndpoint == null) - { - jsonWriter.WriteNullValue(); - } - else - { - jsonWriter.WriteStringValue(storeResponseStatistics.LocationEndpoint.ToString()); - } + this.jsonWriter.WriteFieldName("LocationEndpoint"); + this.WriteStringValueOrNull(storeResponseStatistics.LocationEndpoint?.ToString()); if (storeResponseStatistics.StoreResult != null) { - jsonWriter.WriteFieldName("ActivityId"); - if (storeResponseStatistics.StoreResult.ActivityId == null) - { - jsonWriter.WriteNullValue(); - } - else - { - jsonWriter.WriteStringValue(storeResponseStatistics.StoreResult.ActivityId); - } - - jsonWriter.WriteFieldName("StoreResult"); - jsonWriter.WriteStringValue(storeResponseStatistics.StoreResult.ToString()); + this.jsonWriter.WriteFieldName("StoreResult"); + this.Visit(storeResponseStatistics.StoreResult); } - jsonWriter.WriteObjectEnd(); + this.jsonWriter.WriteObjectEnd(); } public void Visit(CpuHistoryTraceDatum cpuHistoryTraceDatum) @@ -318,6 +313,71 @@ public void Visit(ClientConfigurationTraceDatum clientConfigurationTraceDatum) } } + public void Visit(StoreResult storeResult) + { + this.jsonWriter.WriteObjectStart(); + + this.jsonWriter.WriteFieldName(nameof(storeResult.ActivityId)); + this.WriteStringValueOrNull(storeResult.ActivityId); + + this.jsonWriter.WriteFieldName(nameof(storeResult.StatusCode)); + this.jsonWriter.WriteStringValue(storeResult.StatusCode.ToString()); + + this.jsonWriter.WriteFieldName(nameof(storeResult.SubStatusCode)); + this.jsonWriter.WriteStringValue(storeResult.SubStatusCode.ToString()); + + this.jsonWriter.WriteFieldName(nameof(storeResult.LSN)); + this.jsonWriter.WriteNumber64Value(storeResult.LSN); + + this.jsonWriter.WriteFieldName(nameof(storeResult.PartitionKeyRangeId)); + this.WriteStringValueOrNull(storeResult.PartitionKeyRangeId); + + this.jsonWriter.WriteFieldName(nameof(storeResult.GlobalCommittedLSN)); + this.jsonWriter.WriteNumber64Value(storeResult.GlobalCommittedLSN); + + this.jsonWriter.WriteFieldName(nameof(storeResult.ItemLSN)); + this.jsonWriter.WriteNumber64Value(storeResult.ItemLSN); + + this.jsonWriter.WriteFieldName(nameof(storeResult.UsingLocalLSN)); + this.jsonWriter.WriteBoolValue(storeResult.UsingLocalLSN); + + this.jsonWriter.WriteFieldName(nameof(storeResult.QuorumAckedLSN)); + this.jsonWriter.WriteNumber64Value(storeResult.QuorumAckedLSN); + + this.jsonWriter.WriteFieldName(nameof(storeResult.SessionToken)); + this.WriteStringValueOrNull(storeResult.SessionToken?.ConvertToString()); + + this.jsonWriter.WriteFieldName(nameof(storeResult.CurrentWriteQuorum)); + this.jsonWriter.WriteNumber64Value(storeResult.CurrentWriteQuorum); + + this.jsonWriter.WriteFieldName(nameof(storeResult.CurrentReplicaSetSize)); + this.jsonWriter.WriteNumber64Value(storeResult.CurrentReplicaSetSize); + + this.jsonWriter.WriteFieldName(nameof(storeResult.NumberOfReadRegions)); + this.jsonWriter.WriteNumber64Value(storeResult.NumberOfReadRegions); + + this.jsonWriter.WriteFieldName(nameof(storeResult.IsClientCpuOverloaded)); + this.jsonWriter.WriteBoolValue(storeResult.IsClientCpuOverloaded); + + this.jsonWriter.WriteFieldName(nameof(storeResult.IsValid)); + this.jsonWriter.WriteBoolValue(storeResult.IsValid); + + this.jsonWriter.WriteFieldName(nameof(storeResult.StorePhysicalAddress)); + this.WriteStringValueOrNull(storeResult.StorePhysicalAddress?.ToString()); + + this.jsonWriter.WriteFieldName(nameof(storeResult.RequestCharge)); + this.jsonWriter.WriteNumber64Value(storeResult.RequestCharge); + + this.jsonWriter.WriteFieldName("BELatencyInMs"); + this.WriteStringValueOrNull(storeResult.BackendRequestDurationInMs); + + this.jsonWriter.WriteFieldName("TransportException"); + TransportException transportException = storeResult.Exception?.InnerException as TransportException; + this.WriteStringValueOrNull(transportException?.Message); + + this.jsonWriter.WriteObjectEnd(); + } + private void WriteJsonUriArray(string propertyName, IEnumerable uris) { this.jsonWriter.WriteFieldName(propertyName); @@ -341,9 +401,9 @@ private void WriteRegionsContactedArray(string propertyName, IEnumerable<(string if (uris != null) { - foreach ((string _, Uri uri) contactedRegion in uris) + foreach ((string _, Uri uri) in uris) { - this.WriteStringValueOrNull(contactedRegion.uri?.ToString()); + this.WriteStringValueOrNull(uri?.ToString()); } } diff --git a/Microsoft.Azure.Cosmos/src/Util/Extensions.cs b/Microsoft.Azure.Cosmos/src/Util/Extensions.cs index d79393b42c..41de73235b 100644 --- a/Microsoft.Azure.Cosmos/src/Util/Extensions.cs +++ b/Microsoft.Azure.Cosmos/src/Util/Extensions.cs @@ -94,7 +94,8 @@ internal static ResponseMessage ToCosmosResponseMessage( method: requestMessage?.Method, requestUri: requestMessage?.RequestUriString, requestSessionToken: requestMessage?.Headers?.Session, - responseSessionToken: headers.Session); + responseSessionToken: headers.Session, + beLatencyInMs: headers.BELatencyInMs); requestMessage.Trace.AddDatum(nameof(PointOperationStatisticsTraceDatum), pointOperationStatistics); } @@ -141,7 +142,8 @@ internal static ResponseMessage ToCosmosResponseMessage(this DocumentClientExcep method: requestMessage?.Method, requestUri: requestMessage?.RequestUriString, requestSessionToken: requestMessage?.Headers?.Session, - responseSessionToken: cosmosException.Headers.Session); + responseSessionToken: cosmosException.Headers.Session, + beLatencyInMs: cosmosException.Headers.BELatencyInMs); requestMessage?.Trace.AddDatum("Point Operation Statistics", pointOperationStatistics); } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.BatchOperationsAsync.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.BatchOperationsAsync.xml index 8193d7f6ed..28f0eb170e 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.BatchOperationsAsync.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.BatchOperationsAsync.xml @@ -57,7 +57,6 @@ @@ -305,7 +258,6 @@ @@ -788,7 +614,6 @@ @@ -1098,7 +861,6 @@ @@ -1473,7 +1157,6 @@ diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.QueryAsync.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.QueryAsync.xml index 1c704290f2..657172fe0a 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.QueryAsync.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.QueryAsync.xml @@ -139,7 +139,6 @@ diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/TraceWriterBaselineTests.Serialization.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/TraceWriterBaselineTests.Serialization.xml index 435e5ebab2..e0d36fab35 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/TraceWriterBaselineTests.Serialization.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/TraceWriterBaselineTests.Serialization.xml @@ -16,16 +16,13 @@ @@ -79,7 +76,6 @@ @@ -115,7 +110,6 @@ @@ -197,7 +187,6 @@ @@ -253,7 +239,6 @@ @@ -387,7 +365,6 @@ @@ -504,7 +476,6 @@ @@ -37,7 +38,6 @@ @@ -80,7 +80,8 @@ method: default, requestUri: default, requestSessionToken: default, - responseSessionToken: default); + responseSessionToken: default, + beLatencyInMs: default); rootTrace.AddDatum("Point Operation Statistics Default", datum); } ]]> @@ -101,7 +102,6 @@ @@ -182,7 +182,6 @@ @@ -247,7 +245,7 @@ sessionToken: new SimpleSessionToken(42), usingLocalLSN: true, activityId: Guid.Empty.ToString(), - backendRequestDurationInMs:"0"), + backendRequestDurationInMs: "4.2"), ResourceType.Document, OperationType.Query, uri1); @@ -306,7 +304,6 @@ @@ -456,7 +469,6 @@ @@ -533,7 +561,6 @@ diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Batch/BatchAsyncContainerExecutorTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Batch/BatchAsyncContainerExecutorTests.cs index 71a883e55c..6b9915a562 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Batch/BatchAsyncContainerExecutorTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Batch/BatchAsyncContainerExecutorTests.cs @@ -298,7 +298,8 @@ private static async Task GenerateResponseAsync( method: HttpMethod.Get, requestUri: "http://localhost", requestSessionToken: null, - responseSessionToken: null)); + responseSessionToken: null, + beLatencyInMs: "0.42")); } responseMessage.Headers.SubStatusCode = subStatusCode; diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Batch/PartitionKeyBatchResponseTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Batch/PartitionKeyBatchResponseTests.cs index 4ce4fa0361..c081377f2c 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Batch/PartitionKeyBatchResponseTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Batch/PartitionKeyBatchResponseTests.cs @@ -100,7 +100,8 @@ public async Task DiagnosticsAreSetThroughResponseAsync() method: HttpMethod.Get, requestUri: "http://localhost", requestSessionToken: null, - responseSessionToken: null); + responseSessionToken: null, + beLatencyInMs: "0.42"); TransactionalBatchResponse batchresponse; using (responseMessage.Trace = Trace.GetRootTrace("test trace")) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Batch/PartitionKeyRangeBatchExecutionResultTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Batch/PartitionKeyRangeBatchExecutionResultTests.cs index e868074b95..c24246da10 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Batch/PartitionKeyRangeBatchExecutionResultTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Batch/PartitionKeyRangeBatchExecutionResultTests.cs @@ -88,7 +88,8 @@ public void ToResponseMessage_MapsProperties() method: HttpMethod.Get, requestUri: "http://localhost", requestSessionToken: null, - responseSessionToken: null); + responseSessionToken: null, + beLatencyInMs: "0.42"); TransactionalBatchOperationResult result = new TransactionalBatchOperationResult(HttpStatusCode.OK) { diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CosmosAuthorizationTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CosmosAuthorizationTests.cs index 6c5d17c29a..e5d4ae6a64 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CosmosAuthorizationTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CosmosAuthorizationTests.cs @@ -377,25 +377,26 @@ public async Task TestTokenCredentialFailedToRefreshAsync() } }); + using ITrace trace = Trace.GetRootTrace("test"); using (TokenCredentialCache tokenCredentialCache = this.CreateTokenCredentialCache(testTokenCredential)) { - Assert.AreEqual(token, await tokenCredentialCache.GetTokenAsync(NoOpTrace.Singleton)); + Assert.AreEqual(token, await tokenCredentialCache.GetTokenAsync(trace)); // Token is valid for 6 seconds. Client TokenCredentialRefreshBuffer is set to 5 seconds. // After waiting for 2 seconds, the cache token is still valid, but it will be refreshed in the background. await Task.Delay(TimeSpan.FromSeconds(2)); - Assert.AreEqual(token, await tokenCredentialCache.GetTokenAsync(NoOpTrace.Singleton)); + Assert.AreEqual(token, await tokenCredentialCache.GetTokenAsync(trace)); // Token refreshes fails except for the first time, but the cached token will be served as long as it is valid. await Task.Delay(TimeSpan.FromSeconds(3)); - Assert.AreEqual(token, await tokenCredentialCache.GetTokenAsync(NoOpTrace.Singleton)); + Assert.AreEqual(token, await tokenCredentialCache.GetTokenAsync(trace)); // Cache token has expired, and it fails to refresh. await Task.Delay(TimeSpan.FromSeconds(2)); try { - await tokenCredentialCache.GetTokenAsync(NoOpTrace.Singleton); + await tokenCredentialCache.GetTokenAsync(trace); Assert.Fail("TokenCredentialCache.GetTokenAsync() is expected to fail but succeeded"); } catch (CosmosException cosmosException) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceTests.cs index a8838e5808..c72eaad251 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceTests.cs @@ -3,6 +3,15 @@ using System; using Microsoft.Azure.Cosmos.Tracing; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Microsoft.Azure.Documents; + using System.Reflection; + using System.Linq; + using System.Collections.Generic; + using Microsoft.Azure.Cosmos.Tracing.TraceData; + using static Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum; + using Microsoft.Azure.Cosmos.Json; + using Microsoft.Azure.Cosmos.Diagnostics; + using Newtonsoft.Json.Linq; [TestClass] public class TraceTests @@ -63,5 +72,62 @@ public void TestNoOpTrace() Assert.AreEqual(rootTrace.Children.Count, 0); } } + + [TestMethod] + public void ValidateStoreResultSerialization() + { + HashSet storeResultProperties = typeof(StoreResult).GetProperties(BindingFlags.Public | BindingFlags.Instance).Select(x => x.Name).ToHashSet(); + string datumKey = "ClientStats"; + Trace trace = Trace.GetRootTrace("Test"); + ClientSideRequestStatisticsTraceDatum datum = new ClientSideRequestStatisticsTraceDatum(DateTime.UtcNow); + trace.AddDatum(datumKey, datum); + + StoreResult storeResult = new StoreResult( + storeResponse: new StoreResponse(), + exception: null, + partitionKeyRangeId: 42.ToString(), + lsn: 1337, + quorumAckedLsn: 23, + requestCharge: 3.14, + currentReplicaSetSize: 4, + currentWriteQuorum: 3, + isValid: true, + storePhysicalAddress: new Uri("http://storephysicaladdress.com"), + globalCommittedLSN: 1234, + numberOfReadRegions: 13, + itemLSN: 15, + sessionToken: new SimpleSessionToken(42), + usingLocalLSN: true, + activityId: Guid.Empty.ToString(), + backendRequestDurationInMs: "4.2"); + + StoreResponseStatistics storeResponseStatistics = new StoreResponseStatistics( + DateTime.MinValue, + DateTime.MaxValue, + storeResult, + ResourceType.Document, + OperationType.Query, + new Uri("http://someUri1.com")); + + datum.StoreResponseStatisticsList.Add(storeResponseStatistics); + + CosmosTraceDiagnostics diagnostics = new CosmosTraceDiagnostics(trace); + string json = diagnostics.ToString(); + JObject jObject = JObject.Parse(json); + JObject storeResultJObject = jObject["data"][datumKey]["StoreResponseStatistics"][0]["StoreResult"].ToObject(); + List jsonPropertyNames = storeResultJObject.Properties().Select(p => p.Name).ToList(); + + storeResultProperties.Add("BELatencyInMs"); + storeResultProperties.Remove(nameof(storeResult.BackendRequestDurationInMs)); + storeResultProperties.Add("TransportException"); + storeResultProperties.Remove(nameof(storeResult.Exception)); + + foreach (string key in jsonPropertyNames) + { + Assert.IsTrue(storeResultProperties.Remove(key), $"Json contains key:{key} not a storeresult property"); + } + + Assert.AreEqual(0, storeResultProperties.Count, $"Json is missing properties: {string.Join(';', storeResultProperties)}"); + } } } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceWriterBaselineTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceWriterBaselineTests.cs index ff8539d7e1..042bf24538 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceWriterBaselineTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceWriterBaselineTests.cs @@ -292,7 +292,8 @@ public void TraceData() method: HttpMethod.Post, requestUri: "http://localhost.com", requestSessionToken: nameof(PointOperationStatisticsTraceDatum.RequestSessionToken), - responseSessionToken: nameof(PointOperationStatisticsTraceDatum.ResponseSessionToken)); + responseSessionToken: nameof(PointOperationStatisticsTraceDatum.ResponseSessionToken), + beLatencyInMs: "0.42"); rootTrace.AddDatum("Point Operation Statistics", datum); } endLineNumber = GetLineNumber(); @@ -315,7 +316,8 @@ public void TraceData() method: default, requestUri: default, requestSessionToken: default, - responseSessionToken: default); + responseSessionToken: default, + beLatencyInMs: default); rootTrace.AddDatum("Point Operation Statistics Default", datum); } endLineNumber = GetLineNumber(); @@ -398,7 +400,7 @@ public void TraceData() sessionToken: new SimpleSessionToken(42), usingLocalLSN: true, activityId: Guid.Empty.ToString(), - backendRequestDurationInMs: "0"), + backendRequestDurationInMs: "4.2"), ResourceType.Document, OperationType.Query, uri1); From 8222f8dfe5fbef4ae82586cdf88528b25ffd6334 Mon Sep 17 00:00:00 2001 From: Jake Willey Date: Fri, 16 Apr 2021 06:21:53 -0700 Subject: [PATCH 2/3] Fix header value and update baselines --- .../src/Headers/CosmosMessageHeadersInternal.cs | 2 +- Microsoft.Azure.Cosmos/src/Headers/Headers.cs | 6 +++--- .../src/Headers/StoreResponseHeaders.cs | 2 +- Microsoft.Azure.Cosmos/src/Util/Extensions.cs | 4 ++-- .../Contracts/BenchmarkResults.json | 16 ++++++++-------- .../TraceWriterBaselineTests.TraceData.xml | 12 ++++++++---- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Microsoft.Azure.Cosmos/src/Headers/CosmosMessageHeadersInternal.cs b/Microsoft.Azure.Cosmos/src/Headers/CosmosMessageHeadersInternal.cs index a60a02473c..f25144e842 100644 --- a/Microsoft.Azure.Cosmos/src/Headers/CosmosMessageHeadersInternal.cs +++ b/Microsoft.Azure.Cosmos/src/Headers/CosmosMessageHeadersInternal.cs @@ -87,7 +87,7 @@ public virtual string QueryMetrics set => this.SetProperty(HttpConstants.HttpHeaders.QueryMetrics, value); } - public virtual string BELatencyInMs + public virtual string BackendRequestDurationMilliseconds { get => this.GetValueOrDefault(HttpConstants.HttpHeaders.BackendRequestDurationMilliseconds); set => this.SetProperty(HttpConstants.HttpHeaders.BackendRequestDurationMilliseconds, value); diff --git a/Microsoft.Azure.Cosmos/src/Headers/Headers.cs b/Microsoft.Azure.Cosmos/src/Headers/Headers.cs index 23e1978631..4691e31a4c 100644 --- a/Microsoft.Azure.Cosmos/src/Headers/Headers.cs +++ b/Microsoft.Azure.Cosmos/src/Headers/Headers.cs @@ -195,10 +195,10 @@ internal virtual string QueryMetricsText set => this.CosmosMessageHeaders.QueryMetrics = value; } - internal virtual string BELatencyInMs + internal virtual string BackendRequestDurationMilliseconds { - get => this.CosmosMessageHeaders.QueryMetrics; - set => this.CosmosMessageHeaders.QueryMetrics = value; + get => this.CosmosMessageHeaders.BackendRequestDurationMilliseconds; + set => this.CosmosMessageHeaders.BackendRequestDurationMilliseconds = value; } /// diff --git a/Microsoft.Azure.Cosmos/src/Headers/StoreResponseHeaders.cs b/Microsoft.Azure.Cosmos/src/Headers/StoreResponseHeaders.cs index 7c271ef375..f098c552f9 100644 --- a/Microsoft.Azure.Cosmos/src/Headers/StoreResponseHeaders.cs +++ b/Microsoft.Azure.Cosmos/src/Headers/StoreResponseHeaders.cs @@ -46,7 +46,7 @@ public override string QueryMetrics set => this.storeResponseNameValueCollection.QueryMetrics = value; } - public override string BELatencyInMs + public override string BackendRequestDurationMilliseconds { get => this.storeResponseNameValueCollection.BackendRequestDurationMilliseconds; set => this.storeResponseNameValueCollection.BackendRequestDurationMilliseconds = value; diff --git a/Microsoft.Azure.Cosmos/src/Util/Extensions.cs b/Microsoft.Azure.Cosmos/src/Util/Extensions.cs index 41de73235b..f770dca3e8 100644 --- a/Microsoft.Azure.Cosmos/src/Util/Extensions.cs +++ b/Microsoft.Azure.Cosmos/src/Util/Extensions.cs @@ -95,7 +95,7 @@ internal static ResponseMessage ToCosmosResponseMessage( requestUri: requestMessage?.RequestUriString, requestSessionToken: requestMessage?.Headers?.Session, responseSessionToken: headers.Session, - beLatencyInMs: headers.BELatencyInMs); + beLatencyInMs: headers.BackendRequestDurationMilliseconds); requestMessage.Trace.AddDatum(nameof(PointOperationStatisticsTraceDatum), pointOperationStatistics); } @@ -143,7 +143,7 @@ internal static ResponseMessage ToCosmosResponseMessage(this DocumentClientExcep requestUri: requestMessage?.RequestUriString, requestSessionToken: requestMessage?.Headers?.Session, responseSessionToken: cosmosException.Headers.Session, - beLatencyInMs: cosmosException.Headers.BELatencyInMs); + beLatencyInMs: cosmosException.Headers.BackendRequestDurationMilliseconds); requestMessage?.Trace.AddDatum("Point Operation Statistics", pointOperationStatistics); } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Performance.Tests/Contracts/BenchmarkResults.json b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Performance.Tests/Contracts/BenchmarkResults.json index c14ecba7cb..428168a422 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Performance.Tests/Contracts/BenchmarkResults.json +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Performance.Tests/Contracts/BenchmarkResults.json @@ -3,34 +3,34 @@ "MasterKeyAuthorizationBenchmark.ReadSignatureGeneration;": 532.0, "MockedItemBenchmark.CreateItem;[Type=OfT]": 45302.0, "MockedItemBenchmark.CreateItem;[Type=OfTCustom]": 45320.0, - "MockedItemBenchmark.CreateItem;[Type=OfTWithDiagnosticsToString]": 72242.0, + "MockedItemBenchmark.CreateItem;[Type=OfTWithDiagnosticsToString]": 79730.0, "MockedItemBenchmark.CreateItem;[Type=Stream]": 29766.0, "MockedItemBenchmark.DeleteItemExists;[Type=OfT]": 37154.0, "MockedItemBenchmark.DeleteItemExists;[Type=OfTCustom]": 37154.0, - "MockedItemBenchmark.DeleteItemExists;[Type=OfTWithDiagnosticsToString]": 63450.0, + "MockedItemBenchmark.DeleteItemExists;[Type=OfTWithDiagnosticsToString]": 70924.0, "MockedItemBenchmark.DeleteItemExists;[Type=Stream]": 30382.0, "MockedItemBenchmark.DeleteItemNotExists;[Type=OfT]": 48216.0, "MockedItemBenchmark.DeleteItemNotExists;[Type=OfTCustom]": 48216.0, - "MockedItemBenchmark.DeleteItemNotExists;[Type=OfTWithDiagnosticsToString]": 74512.0, + "MockedItemBenchmark.DeleteItemNotExists;[Type=OfTWithDiagnosticsToString]": 82026.0, "MockedItemBenchmark.DeleteItemNotExists;[Type=Stream]": 43118.0, "MockedItemBenchmark.ReadFeed;[Type=OfT]": 571684.0, "MockedItemBenchmark.ReadFeed;[Type=OfTCustom]": 571048.0, - "MockedItemBenchmark.ReadFeed;[Type=OfTWithDiagnosticsToString]": 611762.0, + "MockedItemBenchmark.ReadFeed;[Type=OfTWithDiagnosticsToString]": 608994.0, "MockedItemBenchmark.ReadFeed;[Type=Stream]": 42734.0, "MockedItemBenchmark.ReadItemExists;[Type=OfT]": 42032.0, "MockedItemBenchmark.ReadItemExists;[Type=OfTCustom]": 41870.0, - "MockedItemBenchmark.ReadItemExists;[Type=OfTWithDiagnosticsToString]": 67766.0, + "MockedItemBenchmark.ReadItemExists;[Type=OfTWithDiagnosticsToString]": 74780.0, "MockedItemBenchmark.ReadItemExists;[Type=Stream]": 34688.0, "MockedItemBenchmark.ReadItemNotExists;[Type=OfT]": 53082.0, "MockedItemBenchmark.ReadItemNotExists;[Type=OfTCustom]": 53100.0, - "MockedItemBenchmark.ReadItemNotExists;[Type=OfTWithDiagnosticsToString]": 78810.0, + "MockedItemBenchmark.ReadItemNotExists;[Type=OfTWithDiagnosticsToString]": 84464.0, "MockedItemBenchmark.ReadItemNotExists;[Type=Stream]": 47994.0, "MockedItemBenchmark.UpdateItem;[Type=OfT]": 45542.0, "MockedItemBenchmark.UpdateItem;[Type=OfTCustom]": 45532.0, - "MockedItemBenchmark.UpdateItem;[Type=OfTWithDiagnosticsToString]": 72504.0, + "MockedItemBenchmark.UpdateItem;[Type=OfTWithDiagnosticsToString]": 79966.0, "MockedItemBenchmark.UpdateItem;[Type=Stream]": 30026.0, "MockedItemBenchmark.UpsertItem;[Type=OfT]": 45448.0, "MockedItemBenchmark.UpsertItem;[Type=OfTCustom]": 45458.0, - "MockedItemBenchmark.UpsertItem;[Type=OfTWithDiagnosticsToString]": 72378.0, + "MockedItemBenchmark.UpsertItem;[Type=OfTWithDiagnosticsToString]": 79856.0, "MockedItemBenchmark.UpsertItem;[Type=Stream]": 29934.0 } \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/TraceWriterBaselineTests.TraceData.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/TraceWriterBaselineTests.TraceData.xml index 945266ded1..125f8ba359 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/TraceWriterBaselineTests.TraceData.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/TraceWriterBaselineTests.TraceData.xml @@ -354,11 +354,13 @@ "PartitionKeyRangeId": "42", "GlobalCommittedLSN": 1234, "ItemLSN": 15, + "UsingLocalLSN": true, + "QuorumAckedLSN": 23, + "SessionToken": "42", "CurrentWriteQuorum": 3, "CurrentReplicaSetSize": 4, - "QuorumAckedLSN": 23, + "NumberOfReadRegions": 13, "IsClientCpuOverloaded": false, - "UsingLocalLSN": true, "IsValid": true, "StorePhysicalAddress": "http://storephysicaladdress.com/", "RequestCharge": 3.14, @@ -512,11 +514,13 @@ "PartitionKeyRangeId": null, "GlobalCommittedLSN": 0, "ItemLSN": 0, + "UsingLocalLSN": false, + "QuorumAckedLSN": 0, + "SessionToken": null, "CurrentWriteQuorum": 0, "CurrentReplicaSetSize": 0, - "QuorumAckedLSN": 0, + "NumberOfReadRegions": 0, "IsClientCpuOverloaded": false, - "UsingLocalLSN": false, "IsValid": false, "StorePhysicalAddress": null, "RequestCharge": 0, From e28a82c26e47620367b39eb3bb33c40a17dabe8b Mon Sep 17 00:00:00 2001 From: Jake Willey Date: Mon, 19 Apr 2021 07:27:56 -0700 Subject: [PATCH 3/3] Update readmany baseline --- ...TraceWriterBaselineTests.ReadManyAsync.xml | 578 ++---------------- 1 file changed, 54 insertions(+), 524 deletions(-) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.ReadManyAsync.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.ReadManyAsync.xml index dcb3194b42..661e6f08d3 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.ReadManyAsync.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.ReadManyAsync.xml @@ -114,7 +114,6 @@