mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-05-21 04:37:28 +01:00
feat: Add duration tracking for query execution success and failure in nextPage function (#2487)
This commit is contained in:
@@ -19,22 +19,38 @@ export interface MinimalQueryIterator {
|
|||||||
// Pick<QueryIterator<any>, "fetchNext">;
|
// Pick<QueryIterator<any>, "fetchNext">;
|
||||||
|
|
||||||
export function nextPage(documentsIterator: MinimalQueryIterator, firstItemIndex: number): Promise<QueryResults> {
|
export function nextPage(documentsIterator: MinimalQueryIterator, firstItemIndex: number): Promise<QueryResults> {
|
||||||
TelemetryProcessor.traceStart(Action.ExecuteQuery);
|
const startKey = TelemetryProcessor.traceStart(Action.ExecuteQuery);
|
||||||
return documentsIterator.fetchNext().then((response) => {
|
return documentsIterator
|
||||||
TelemetryProcessor.traceSuccess(Action.ExecuteQuery, { dataExplorerArea: Constants.Areas.Tab });
|
.fetchNext()
|
||||||
const documents = response.resources;
|
.then((response) => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
const durationMs = Date.now() - startKey;
|
||||||
const headers = (response as any).headers || {}; // TODO this is a private key. Remove any
|
TelemetryProcessor.traceSuccess(
|
||||||
const itemCount = (documents && documents.length) || 0;
|
Action.ExecuteQuery,
|
||||||
return {
|
{ dataExplorerArea: Constants.Areas.Tab, durationMs },
|
||||||
documents,
|
startKey,
|
||||||
hasMoreResults: response.hasMoreResults,
|
);
|
||||||
itemCount,
|
const documents = response.resources;
|
||||||
firstItemIndex: Number(firstItemIndex) + 1,
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
lastItemIndex: Number(firstItemIndex) + Number(itemCount),
|
const headers = (response as any).headers || {}; // TODO this is a private key. Remove any
|
||||||
headers,
|
const itemCount = (documents && documents.length) || 0;
|
||||||
activityId: response.activityId,
|
return {
|
||||||
requestCharge: response.requestCharge,
|
documents,
|
||||||
};
|
hasMoreResults: response.hasMoreResults,
|
||||||
});
|
itemCount,
|
||||||
|
firstItemIndex: Number(firstItemIndex) + 1,
|
||||||
|
lastItemIndex: Number(firstItemIndex) + Number(itemCount),
|
||||||
|
headers,
|
||||||
|
activityId: response.activityId,
|
||||||
|
requestCharge: response.requestCharge,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
const durationMs = Date.now() - startKey;
|
||||||
|
TelemetryProcessor.traceFailure(
|
||||||
|
Action.ExecuteQuery,
|
||||||
|
{ dataExplorerArea: Constants.Areas.Tab, durationMs, error: error.message },
|
||||||
|
startKey,
|
||||||
|
);
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user