mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-04-14 21:58:14 +01:00
Add tracing for Execute (submit) query and Upload documents
This commit is contained in:
parent
a3bfc89318
commit
7f2fe7e33e
@ -1,6 +1,8 @@
|
||||
import { FeedOptions, ItemDefinition, QueryIterator, Resource } from "@azure/cosmos";
|
||||
import { Action, ActionModifiers } from "Shared/Telemetry/TelemetryConstants";
|
||||
import { isVectorSearchEnabled } from "Utils/CapabilityUtils";
|
||||
import { LocalStorageUtility, StorageKey } from "../../Shared/StorageUtility";
|
||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { Queries } from "../Constants";
|
||||
import { client } from "../CosmosClient";
|
||||
|
||||
@ -11,6 +13,7 @@ export const queryDocuments = (
|
||||
options: FeedOptions,
|
||||
): QueryIterator<ItemDefinition & Resource> => {
|
||||
options = getCommonQueryOptions(options);
|
||||
TelemetryProcessor.trace(Action.ExecuteQuery, ActionModifiers.Submit);
|
||||
return client().database(databaseId).container(containerId).items.query(query, options);
|
||||
};
|
||||
|
||||
|
@ -1040,9 +1040,22 @@ export default class Collection implements ViewModels.Collection {
|
||||
}
|
||||
|
||||
public async uploadFiles(files: FileList): Promise<{ data: UploadDetailsRecord[] }> {
|
||||
const data = await Promise.all(Array.from(files).map((file) => this.uploadFile(file)));
|
||||
|
||||
return { data };
|
||||
try {
|
||||
TelemetryProcessor.trace(Action.UploadDocuments, ActionModifiers.Start, {
|
||||
nbFiles: files.length,
|
||||
});
|
||||
const data = await Promise.all(Array.from(files).map((file) => this.uploadFile(file)));
|
||||
TelemetryProcessor.trace(Action.UploadDocuments, ActionModifiers.Success, {
|
||||
nbFiles: files.length,
|
||||
});
|
||||
return { data };
|
||||
} catch (error) {
|
||||
TelemetryProcessor.trace(Action.UploadDocuments, ActionModifiers.Failed, {
|
||||
error: getErrorMessage(error),
|
||||
errorStack: getErrorStack(error),
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
private uploadFile(file: File): Promise<UploadDetailsRecord> {
|
||||
|
@ -142,6 +142,7 @@ export enum Action {
|
||||
ReadPersistedTabState,
|
||||
SavePersistedTabState,
|
||||
DeletePersistedTabState,
|
||||
UploadDocuments,
|
||||
}
|
||||
|
||||
export const ActionModifiers = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user