diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/QueryClient/CosmosQueryClient.cs b/Microsoft.Azure.Cosmos/src/Query/Core/QueryClient/CosmosQueryClient.cs index 8cf640181d..027635dcf1 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/QueryClient/CosmosQueryClient.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/QueryClient/CosmosQueryClient.cs @@ -49,7 +49,7 @@ internal abstract Task ExecuteItemQueryAsync( Documents.ResourceType resourceType, Documents.OperationType operationType, QueryRequestOptions requestOptions, - CosmosDiagnosticsContext diagnosticsContext, + Action queryPageDiagnostics, SqlQuerySpec sqlQuerySpec, string continuationToken, Documents.PartitionKeyRangeIdentity partitionKeyRange, diff --git a/Microsoft.Azure.Cosmos/src/Query/v3Query/CosmosQueryClientCore.cs b/Microsoft.Azure.Cosmos/src/Query/v3Query/CosmosQueryClientCore.cs index 320938ccac..1ed7f280e1 100644 --- a/Microsoft.Azure.Cosmos/src/Query/v3Query/CosmosQueryClientCore.cs +++ b/Microsoft.Azure.Cosmos/src/Query/v3Query/CosmosQueryClientCore.cs @@ -117,7 +117,7 @@ internal override async Task ExecuteItemQueryAsync( ResourceType resourceType, OperationType operationType, QueryRequestOptions requestOptions, - CosmosDiagnosticsContext diagnosticsContext, + Action queryPageDiagnostics, SqlQuerySpec sqlQuerySpec, string continuationToken, PartitionKeyRangeIdentity partitionKeyRange, @@ -155,7 +155,7 @@ internal override async Task ExecuteItemQueryAsync( resourceType, message, partitionKeyRange, - diagnosticsContext); + queryPageDiagnostics); } internal override async Task ExecuteQueryPlanRequestAsync( @@ -265,7 +265,7 @@ private QueryResponseCore GetCosmosElementResponse( ResourceType resourceType, ResponseMessage cosmosResponseMessage, PartitionKeyRangeIdentity partitionKeyRangeIdentity, - CosmosDiagnosticsContext diagnosticsContext) + Action queryPageDiagnostics) { using (cosmosResponseMessage) { @@ -274,8 +274,8 @@ private QueryResponseCore GetCosmosElementResponse( queryMetricText: cosmosResponseMessage.Headers.QueryMetricsText, indexUtilizationText: cosmosResponseMessage.Headers[HttpConstants.HttpHeaders.IndexUtilization], diagnosticsContext: cosmosResponseMessage.DiagnosticsContext); + queryPageDiagnostics(queryPage); - diagnosticsContext.AddDiagnosticsInternal(queryPage); if (!cosmosResponseMessage.IsSuccessStatusCode) { return QueryResponseCore.CreateFailure( diff --git a/Microsoft.Azure.Cosmos/src/Query/v3Query/CosmosQueryContextCore.cs b/Microsoft.Azure.Cosmos/src/Query/v3Query/CosmosQueryContextCore.cs index d145ba313b..ed9e0e2232 100644 --- a/Microsoft.Azure.Cosmos/src/Query/v3Query/CosmosQueryContextCore.cs +++ b/Microsoft.Azure.Cosmos/src/Query/v3Query/CosmosQueryContextCore.cs @@ -82,7 +82,7 @@ internal override Task ExecuteQueryAsync( partitionKeyRange: partitionKeyRange, isContinuationExpected: isContinuationExpected, pageSize: pageSize, - diagnosticsContext: this.diagnosticsContext, + queryPageDiagnostics: this.AddQueryPageDiagnostic, cancellationToken: cancellationToken); } @@ -105,5 +105,10 @@ internal override Task ExecuteQueryPlanRequestAsy this.diagnosticsContext, cancellationToken); } + + private void AddQueryPageDiagnostic(QueryPageDiagnostics queryPageDiagnostics) + { + this.diagnosticsContext.AddDiagnosticsInternal(queryPageDiagnostics); + } } } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Query/MockCosmosQueryClient.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Query/MockCosmosQueryClient.cs index 4c604a1cee..b12ba1f28a 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Query/MockCosmosQueryClient.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Query/MockCosmosQueryClient.cs @@ -66,7 +66,7 @@ internal override Task ExecuteItemQueryAsync( ResourceType resourceType, OperationType operationType, QueryRequestOptions requestOptions, - CosmosDiagnosticsContext diagnosticsContext, + Action queryPageDiagnostics, SqlQuerySpec sqlQuerySpec, string continuationToken, PartitionKeyRangeIdentity partitionKeyRange, @@ -82,7 +82,7 @@ internal override Task ExecuteItemQueryAsync( resourceType: resourceType, operationType: operationType, requestOptions: requestOptions, - diagnosticsContext: diagnosticsContext, + queryPageDiagnostics: queryPageDiagnostics, sqlQuerySpec: sqlQuerySpec, continuationToken: continuationToken, partitionKeyRange: partitionKeyRange, diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Query/MockItemProducerFactory.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Query/MockItemProducerFactory.cs index 33bc9fed18..e6cc39c3b6 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Query/MockItemProducerFactory.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Query/MockItemProducerFactory.cs @@ -234,7 +234,7 @@ public static List MockSinglePartitionKeyRangeContext( ResourceType.Document, OperationType.Query, It.IsAny(), - It.IsAny(), + It.IsAny>(), It.Is(specInput => IsSqlQuerySpecEqual(sqlQuerySpec, specInput)), previousContinuationToken, It.Is(rangeId => string.Equals(rangeId.PartitionKeyRangeId, partitionKeyRange.Id) && string.Equals(rangeId.CollectionRid, collectionRid)), diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Query/MockQueryFactory.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Query/MockQueryFactory.cs index fbc40813e5..e7990b183a 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Query/MockQueryFactory.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Query/MockQueryFactory.cs @@ -151,7 +151,7 @@ private static IList GenerateAndMockResponseHelper( ResourceType.Document, OperationType.Query, It.IsAny(), - It.IsAny(), + It.IsAny>(), It.Is(specInput => MockItemProducerFactory.IsSqlQuerySpecEqual(sqlQuerySpec, specInput)), previousContinuationToken, It.Is(rangeId => string.Equals(rangeId.PartitionKeyRangeId, partitionKeyRange.Id) && string.Equals(rangeId.CollectionRid, containerRid)), @@ -179,7 +179,7 @@ private static IList GenerateAndMockResponseHelper( ResourceType.Document, OperationType.Query, It.IsAny(), - It.IsAny(), + It.IsAny>(), It.Is(specInput => MockItemProducerFactory.IsSqlQuerySpecEqual(sqlQuerySpec, specInput)), previousContinuationToken, It.Is(rangeId => string.Equals(rangeId.PartitionKeyRangeId, partitionKeyRange.Id) && string.Equals(rangeId.CollectionRid, containerRid)),