mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-06-08 21:47:35 +01:00
Removing temporary debug logging
This commit is contained in:
@@ -21,7 +21,6 @@ export const handleError = (
|
||||
consoleErrorPrefix?: string,
|
||||
options?: HandleErrorOptions,
|
||||
): void => {
|
||||
console.log("{{cdbp}} in handleError(): raw error: " + stringifyError(error)); //CTODO in case a stray error happens
|
||||
const errorMessage = getErrorMessage(error);
|
||||
const errorCode = error instanceof ARMError ? error.code : undefined;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { stringifyError } from "Common/stringifyError";
|
||||
import { CosmosDbArtifactType } from "Contracts/FabricMessagesContract";
|
||||
import { isFabric, isFabricMirroredKey, isFabricNative } from "Platform/Fabric/FabricUtil";
|
||||
import { AuthType } from "../../AuthType";
|
||||
@@ -27,7 +26,6 @@ export async function readDatabases(): Promise<DataModels.Database[]> {
|
||||
(userContext.fabricContext?.artifactInfo as FabricArtifactInfo[CosmosDbArtifactType.MIRRORED_KEY]).resourceTokenInfo
|
||||
.resourceTokens
|
||||
) {
|
||||
console.log("{{cdbp}} in readDatabases(): isFabricMirroredKey && has resourceTokens"); //CTODO should not get here
|
||||
const tokensData = (userContext.fabricContext.artifactInfo as FabricArtifactInfo[CosmosDbArtifactType.MIRRORED_KEY])
|
||||
.resourceTokenInfo;
|
||||
|
||||
@@ -61,7 +59,6 @@ export async function readDatabases(): Promise<DataModels.Database[]> {
|
||||
clearMessage();
|
||||
return databases;
|
||||
} else if (isFabricNative() && userContext.fabricContext?.databaseName) {
|
||||
console.log("{{cdbp}} in readDatabases(): isFabricNative"); //CTODO should not get here
|
||||
const databaseId = userContext.fabricContext.databaseName;
|
||||
databases = [
|
||||
{
|
||||
@@ -84,15 +81,9 @@ export async function readDatabases(): Promise<DataModels.Database[]> {
|
||||
userContext.apiType !== "Tables" &&
|
||||
!isFabric()
|
||||
) {
|
||||
console.log("{{cdbp}} in readDatabases(): authType == AAD, enableSDKOperations, apiType != Tables, !isFabric");
|
||||
console.log("{{cdbp}} in readDatabases(): databaseaccount: " + userContext.databaseAccount);
|
||||
console.log("{{cdbp}} in readDatabases(): calling readDatabasesWithARM");
|
||||
databases = await readDatabasesWithARM();
|
||||
console.log("{{cdbp}} in readDatabases(): done readDatabasesWithARM");
|
||||
} else {
|
||||
console.log("{{cdbp}} in readDatabases(): calling SDK");
|
||||
const sdkResponse = await client().databases.readAll().fetchAll();
|
||||
console.log("{{cdbp}} in readDatabases(): done SDK");
|
||||
databases = sdkResponse.resources as DataModels.Database[];
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -117,30 +108,22 @@ export async function readDatabasesWithARM(accountOverride?: {
|
||||
const accountName = accountOverride?.accountName ?? userContext?.databaseAccount?.name ?? "";
|
||||
const apiType = accountOverride?.apiType ?? userContext.apiType;
|
||||
|
||||
try {
|
||||
switch (apiType) {
|
||||
case "SQL":
|
||||
console.log("{{cdbp}} in readDatabasesWithARM(): calling listSqlDatabases");
|
||||
rpResponse = await listSqlDatabases(subscriptionId, resourceGroup, accountName);
|
||||
console.log("{{cdbp}} in readDatabasesWithARM(): done listSqlDatabases");
|
||||
break;
|
||||
case "Mongo":
|
||||
rpResponse = await listMongoDBDatabases(subscriptionId, resourceGroup, accountName);
|
||||
break;
|
||||
case "Cassandra":
|
||||
rpResponse = await listCassandraKeyspaces(subscriptionId, resourceGroup, accountName);
|
||||
break;
|
||||
case "Gremlin":
|
||||
rpResponse = await listGremlinDatabases(subscriptionId, resourceGroup, accountName);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unsupported default experience type: ${apiType}`);
|
||||
}
|
||||
|
||||
console.log("{{cdbp}} in readDatabasesWithARM(): response: " + JSON.stringify(rpResponse));
|
||||
return rpResponse?.value?.map((database) => database.properties?.resource as DataModels.Database) ?? [];
|
||||
} catch (error) {
|
||||
console.log("{{cdbp}} in readDatabasesWithARM(): ERROR: " + stringifyError(error));
|
||||
throw error;
|
||||
switch (apiType) {
|
||||
case "SQL":
|
||||
rpResponse = await listSqlDatabases(subscriptionId, resourceGroup, accountName);
|
||||
break;
|
||||
case "Mongo":
|
||||
rpResponse = await listMongoDBDatabases(subscriptionId, resourceGroup, accountName);
|
||||
break;
|
||||
case "Cassandra":
|
||||
rpResponse = await listCassandraKeyspaces(subscriptionId, resourceGroup, accountName);
|
||||
break;
|
||||
case "Gremlin":
|
||||
rpResponse = await listGremlinDatabases(subscriptionId, resourceGroup, accountName);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unsupported default experience type: ${apiType}`);
|
||||
}
|
||||
|
||||
return rpResponse?.value?.map((database) => database.properties?.resource as DataModels.Database) ?? [];
|
||||
}
|
||||
|
||||
@@ -402,27 +402,19 @@ export default class Explorer {
|
||||
},
|
||||
startKey,
|
||||
);
|
||||
console.log("{{cdbp}} in refreshAllDatabases(): done readDatabases");
|
||||
const currentDatabases = useDatabases.getState().databases;
|
||||
console.log("{{cdbp}} in refreshAllDatabases(): currentDatabases: " + currentDatabases);
|
||||
const deltaDatabases = this.getDeltaDatabases(databases, currentDatabases);
|
||||
console.log("{{cdbp}} in refreshAllDatabases(): deltaDatabases: " + deltaDatabases);
|
||||
let updatedDatabases = currentDatabases.filter(
|
||||
(database) => !deltaDatabases.toDelete.some((deletedDatabase) => deletedDatabase.id() === database.id()),
|
||||
);
|
||||
console.log("{{cdbp}} in refreshAllDatabases(): updatedDatabases after filter: " + updatedDatabases);
|
||||
updatedDatabases = [...updatedDatabases, ...deltaDatabases.toAdd].sort((db1, db2) =>
|
||||
db1.id().localeCompare(db2.id()),
|
||||
);
|
||||
console.log("{{cdbp}} in refreshAllDatabases(): updatedDatabases after sort: " + updatedDatabases);
|
||||
useDatabases.setState({ databases: updatedDatabases, databasesFetchedSuccessfully: true });
|
||||
scenarioMonitor.completePhase(MetricScenario.DatabaseLoad, ApplicationMetricPhase.DatabasesFetched);
|
||||
|
||||
console.log("{{cdbp}} in refreshAllDatabases(): calling refreshAndExpandNewDatabases");
|
||||
await this.refreshAndExpandNewDatabases(deltaDatabases.toAdd, updatedDatabases);
|
||||
console.log("{{cdbp}} in refreshAllDatabases(): done refreshAndExpandNewDatabases");
|
||||
} catch (error) {
|
||||
console.log("{{cdbp}} in refreshAllDatabases(): ERROR: " + stringifyError(error)); //CTODO this should be logged already but just in case
|
||||
const errorMessage = getErrorMessage(error);
|
||||
TelemetryProcessor.traceFailure(
|
||||
Action.LoadDatabases,
|
||||
@@ -612,7 +604,6 @@ export default class Explorer {
|
||||
? databases
|
||||
: databases.filter((db) => db.isDatabaseExpanded() || db.id() === Constants.SavedQueries.DatabaseName);
|
||||
|
||||
console.log("{{cdbp}} in refreshAndExpandNewDatabases(): databasesToLoad: " + databasesToLoad);
|
||||
const startKey: number = TelemetryProcessor.traceStart(Action.LoadCollections, {
|
||||
dataExplorerArea: Constants.Areas.ResourceTree,
|
||||
});
|
||||
@@ -621,7 +612,6 @@ export default class Explorer {
|
||||
try {
|
||||
await Promise.all(
|
||||
databasesToLoad.map(async (database: ViewModels.Database) => {
|
||||
console.log("{{cdbp}} in refreshAndExpandNewDatabases(): loadCollections for database: " + database.id);
|
||||
await database.loadCollections(true);
|
||||
const isNewDatabase: boolean = _.some(newDatabases, (db: ViewModels.Database) => db.id() === database.id());
|
||||
if (isNewDatabase) {
|
||||
@@ -641,7 +631,6 @@ export default class Explorer {
|
||||
// Start DatabaseTreeRendered — React render cycle will complete it in ResourceTree
|
||||
scenarioMonitor.startPhase(MetricScenario.DatabaseLoad, ApplicationMetricPhase.DatabaseTreeRendered);
|
||||
} catch (error) {
|
||||
console.log("{{cdbp}} in refreshAndExpandNewDatabases(): ERROR: " + stringifyError(error)); //CTODO this should be logged already but just in case
|
||||
TelemetryProcessor.traceFailure(
|
||||
Action.LoadCollections,
|
||||
{
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
Generated from: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/DocumentDB/preview/2025-11-01-preview/cosmos-db.json
|
||||
*/
|
||||
|
||||
import { stringifyError } from "Common/stringifyError";
|
||||
import { configContext } from "../../../../ConfigContext";
|
||||
import { armRequest } from "../../request";
|
||||
import * as Types from "./types";
|
||||
@@ -19,14 +18,7 @@ export async function listSqlDatabases(
|
||||
accountName: string,
|
||||
): Promise<Types.SqlDatabaseListResult> {
|
||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/sqlDatabases`;
|
||||
console.log("{{cdbp}} in listSqlDatabases(): path: " + path);
|
||||
try {
|
||||
console.log("{{cdbp}} in listSqlDatabases(): calling armRequest");
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
} catch (error) {
|
||||
console.log("{{cdbp}} in listSqlDatabases(): ERROR: " + stringifyError(error));
|
||||
throw error;
|
||||
}
|
||||
return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
|
||||
}
|
||||
|
||||
/* Gets the SQL database under an existing Azure Cosmos DB database account with the provided name. */
|
||||
|
||||
@@ -5,7 +5,6 @@ Instead, generate ARM clients that consume this function with stricter typing.
|
||||
|
||||
*/
|
||||
|
||||
import { stringifyError } from "Common/stringifyError";
|
||||
import promiseRetry, { AbortError } from "p-retry";
|
||||
import { HttpHeaders } from "../../Common/Constants";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
@@ -78,9 +77,6 @@ export async function armRequestWithoutPolling<T>({
|
||||
}
|
||||
|
||||
if (!userContext?.authorizationToken && !customHeaders?.["Authorization"]) {
|
||||
console.log(
|
||||
"{{cdbp}} in armRequestWithoutPolling(): condition '!userContext?.authorizationToken && !customHeaders?.['Authorization']' met, throwing 'No authority token provided' error",
|
||||
);
|
||||
throw new Error("No authority token provided");
|
||||
}
|
||||
|
||||
@@ -98,9 +94,6 @@ export async function armRequestWithoutPolling<T>({
|
||||
};
|
||||
|
||||
const effectiveTimeoutMs = timeoutMs ?? DEFAULT_ARM_TIMEOUT_MS;
|
||||
console.log(
|
||||
`{{cdbp}} in armRequestWithoutPolling(): calling fetchWithRetry (method=${method}, timeoutMs=${effectiveTimeoutMs}, hasSignal=${!!signal})`,
|
||||
);
|
||||
const response = await fetchWithRetry(url.href, fetchInit, method, effectiveTimeoutMs, signal);
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -115,11 +108,9 @@ export async function armRequestWithoutPolling<T>({
|
||||
error.code = errorResponse.code;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("{{cdbp}} in armRequestWithoutPolling(): ERROR: " + stringifyError(error));
|
||||
throw new Error(await response.text());
|
||||
}
|
||||
|
||||
console.log("{{cdbp}} in armRequestWithoutPolling(): ERROR: " + stringifyError(error));
|
||||
throw error;
|
||||
}
|
||||
|
||||
@@ -184,7 +175,6 @@ async function fetchWithRetry(
|
||||
(attemptNumber: number) => {
|
||||
const attemptTimeoutMs =
|
||||
timeoutMs * RETRY_TIMEOUT_MULTIPLIERS[Math.min(attemptNumber - 1, RETRY_TIMEOUT_MULTIPLIERS.length - 1)];
|
||||
console.log(`{{cdbp}} in fetchWithRetry(): calling fetchWithTimeout: attempt=${attemptNumber} url=${url}`);
|
||||
return fetchWithTimeout(url, fetchInit, attemptTimeoutMs);
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user