Add logs to troubleshoot performances issues

This commit is contained in:
Charles Bochet
2024-09-18 00:10:35 +02:00
parent 7cdf2dc4ec
commit 9c885861a3
3 changed files with 54 additions and 2 deletions

View File

@ -65,8 +65,8 @@ import {
} from './interfaces/pg-graphql.interface';
import { WorkspaceQueryRunnerOptions } from './interfaces/query-runner-option.interface';
import {
computePgGraphQLError,
PgGraphQLConfig,
computePgGraphQLError,
} from './utils/compute-pg-graphql-error.util';
@Injectable()
@ -99,6 +99,9 @@ export class WorkspaceQueryRunnerService {
): Promise<IConnection<Record> | undefined> {
const { authContext, objectMetadataItem } = options;
console.log(
`running findMany for ${objectMetadataItem.nameSingular} on workspace ${authContext.workspace.id}`,
);
const hookedArgs =
await this.workspaceQueryHookService.executePreQueryHooks(
authContext,
@ -131,6 +134,10 @@ export class WorkspaceQueryRunnerService {
}
const { authContext, objectMetadataItem } = options;
console.log(
`running findOne for ${objectMetadataItem.nameSingular} on workspace ${authContext.workspace.id}`,
);
const hookedArgs =
await this.workspaceQueryHookService.executePreQueryHooks(
authContext,
@ -168,6 +175,10 @@ export class WorkspaceQueryRunnerService {
const { authContext, objectMetadataItem } = options;
console.log(
`running findDuplicates for ${objectMetadataItem.nameSingular} on workspace ${authContext.workspace.id}`,
);
const hookedArgs =
await this.workspaceQueryHookService.executePreQueryHooks(
authContext,
@ -222,6 +233,10 @@ export class WorkspaceQueryRunnerService {
): Promise<Record[] | undefined> {
const { authContext, objectMetadataItem } = options;
console.log(
`running createMany for ${objectMetadataItem.nameSingular} on workspace ${authContext.workspace.id}`,
);
const isQueryRunnerTwentyORMEnabled =
await this.featureFlagService.isFeatureEnabled(
FeatureFlagKey.IsQueryRunnerTwentyORMEnabled,
@ -313,6 +328,9 @@ export class WorkspaceQueryRunnerService {
args: CreateManyResolverArgs<Partial<Record>>,
options: WorkspaceQueryRunnerOptions,
): Promise<Record[] | undefined> {
console.log(
`running upsertMany for ${options.objectMetadataItem.nameSingular} on workspace ${options.authContext.workspace.id}`,
);
const ids = args.data
.map((item) => item.id)
.filter((id) => id !== undefined);
@ -379,6 +397,11 @@ export class WorkspaceQueryRunnerService {
options: WorkspaceQueryRunnerOptions,
): Promise<Record | undefined> {
const { authContext, objectMetadataItem } = options;
console.log(
`running updateOne for ${objectMetadataItem.nameSingular} on workspace ${authContext.workspace.id}`,
);
const repository =
await this.twentyORMGlobalManager.getRepositoryForWorkspace(
authContext.workspace.id,
@ -454,6 +477,11 @@ export class WorkspaceQueryRunnerService {
options: WorkspaceQueryRunnerOptions,
): Promise<Record[] | undefined> {
const { authContext, objectMetadataItem } = options;
console.log(
`running updateMany for ${objectMetadataItem.nameSingular} on workspace ${authContext.workspace.id}`,
);
const repository =
await this.twentyORMGlobalManager.getRepositoryForWorkspace(
authContext.workspace.id,
@ -549,6 +577,10 @@ export class WorkspaceQueryRunnerService {
): Promise<Record[] | undefined> {
const { authContext, objectMetadataItem } = options;
console.log(
`running deleteMany for ${objectMetadataItem.nameSingular} on workspace ${authContext.workspace.id}`,
);
assertMutationNotOnRemoteObject(objectMetadataItem);
const maximumRecordAffected = this.environmentService.get(
@ -638,6 +670,10 @@ export class WorkspaceQueryRunnerService {
): Promise<Record[] | undefined> {
const { authContext, objectMetadataItem } = options;
console.log(
`running destroyMany for ${objectMetadataItem.nameSingular} on workspace ${authContext.workspace.id}`,
);
assertMutationNotOnRemoteObject(objectMetadataItem);
const maximumRecordAffected = this.environmentService.get(
@ -694,6 +730,10 @@ export class WorkspaceQueryRunnerService {
): Promise<Record[] | undefined> {
const { authContext, objectMetadataItem } = options;
console.log(
`running restoreMany for ${objectMetadataItem.nameSingular} on workspace ${authContext.workspace.id}`,
);
assertMutationNotOnRemoteObject(objectMetadataItem);
const maximumRecordAffected = this.environmentService.get(
@ -765,6 +805,11 @@ export class WorkspaceQueryRunnerService {
options: WorkspaceQueryRunnerOptions,
): Promise<Record | undefined> {
const { authContext, objectMetadataItem } = options;
console.log(
`running deleteOne for ${objectMetadataItem.nameSingular} on workspace ${authContext.workspace.id}`,
);
const repository =
await this.twentyORMGlobalManager.getRepositoryForWorkspace(
authContext.workspace.id,