diff --git a/sdk/cosmosdb/cosmos/review/cosmos.api.md b/sdk/cosmosdb/cosmos/review/cosmos.api.md index 589db0262c56..d36fe7f25874 100644 --- a/sdk/cosmosdb/cosmos/review/cosmos.api.md +++ b/sdk/cosmosdb/cosmos/review/cosmos.api.md @@ -578,12 +578,12 @@ export class Items { query(query: string | SqlQuerySpec, options: FeedOptions): QueryIterator; readAll(options?: FeedOptions): QueryIterator; readAll(options?: FeedOptions): QueryIterator; + readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; // Warning: (ae-forgotten-export) The symbol "ChangeFeedOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ChangeFeedIterator" needs to be exported by the entry point index.d.ts readChangeFeed(partitionKey: string | number | boolean, changeFeedOptions: ChangeFeedOptions): ChangeFeedIterator; readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; readChangeFeed(partitionKey: string | number | boolean, changeFeedOptions: ChangeFeedOptions): ChangeFeedIterator; - readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; upsert(body: any, options?: RequestOptions): Promise>; upsert(body: T, options?: RequestOptions): Promise>; } diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/defaultQueryExecutionContext.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/defaultQueryExecutionContext.ts index 92d4ced87654..e719aefe3df8 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/defaultQueryExecutionContext.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/defaultQueryExecutionContext.ts @@ -185,6 +185,7 @@ export class DefaultQueryExecutionContext implements ExecutionContext { // Add the request charge to the query metrics so that we can have per partition request charge. if (Constants.HttpHeaders.RequestCharge in responseHeaders) { + const requestCharge = Number(responseHeaders[Constants.HttpHeaders.RequestCharge]) || 0; queryMetrics = new QueryMetrics( queryMetrics.retrievedDocumentCount, queryMetrics.retrievedDocumentSize, @@ -198,7 +199,7 @@ export class DefaultQueryExecutionContext implements ExecutionContext { queryMetrics.vmExecutionTime, queryMetrics.runtimeExecutionTimes, queryMetrics.documentWriteTime, - new ClientSideMetrics(responseHeaders[Constants.HttpHeaders.RequestCharge]) + new ClientSideMetrics(requestCharge) ); } diff --git a/sdk/cosmosdb/cosmos/src/queryMetrics/clientSideMetrics.ts b/sdk/cosmosdb/cosmos/src/queryMetrics/clientSideMetrics.ts index c20a2e7bb7f1..ebe2e714f678 100644 --- a/sdk/cosmosdb/cosmos/src/queryMetrics/clientSideMetrics.ts +++ b/sdk/cosmosdb/cosmos/src/queryMetrics/clientSideMetrics.ts @@ -1,6 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { getRequestChargeIfAny } from "../queryExecutionContext/headerUtils"; export class ClientSideMetrics { constructor(public readonly requestCharge: number) {} @@ -15,7 +14,7 @@ export class ClientSideMetrics { throw new Error("clientSideMetrics has null or undefined item(s)"); } - requestCharge += getRequestChargeIfAny(clientSideMetrics.requestCharge); + requestCharge += clientSideMetrics.requestCharge; } return new ClientSideMetrics(requestCharge); diff --git a/sdk/cosmosdb/cosmos/src/request/RequestHandler.ts b/sdk/cosmosdb/cosmos/src/request/RequestHandler.ts index a369633c3121..fdb1398006fd 100644 --- a/sdk/cosmosdb/cosmos/src/request/RequestHandler.ts +++ b/sdk/cosmosdb/cosmos/src/request/RequestHandler.ts @@ -17,8 +17,7 @@ import { TimeoutError } from "./TimeoutError"; /** @hidden */ const log = logger("RequestHandler"); -/** @hidden */ -export async function executeRequest(requestContext: RequestContext) { +async function executeRequest(requestContext: RequestContext) { return executePlugins(requestContext, httpRequest, PluginOn.request); } @@ -143,6 +142,7 @@ export async function request(requestContext: RequestContext): Promise Promise>; } /** @@ -41,7 +41,8 @@ interface RetryPolicies { export async function execute({ retryContext = {}, retryPolicies, - requestContext + requestContext, + executeRequest }: ExecuteArgs): Promise> { // TODO: any response if (!retryPolicies) { @@ -121,6 +122,7 @@ export async function execute({ } await sleep(retryPolicy.retryAfterInMilliseconds); return execute({ + executeRequest, requestContext, retryContext, retryPolicies