cleaning - remove logs (#19445)
This commit is contained in:
@@ -4,7 +4,6 @@ import { ScalarsExplorerService } from 'src/engine/api/graphql/services/scalars-
|
||||
import { WorkspaceGraphqlSchemaSDLService } from 'src/engine/api/graphql/workspace-graphql-schema-sdl/workspace-graphql-schema-sdl.service';
|
||||
import { WorkspaceResolverFactory } from 'src/engine/api/graphql/workspace-resolver-builder/workspace-resolver.factory';
|
||||
import { WorkspaceSchemaFactory } from 'src/engine/api/graphql/workspace-schema.factory';
|
||||
import { MetricsService } from 'src/engine/core-modules/metrics/metrics.service';
|
||||
|
||||
describe('WorkspaceSchemaFactory', () => {
|
||||
let service: WorkspaceSchemaFactory;
|
||||
@@ -25,10 +24,6 @@ describe('WorkspaceSchemaFactory', () => {
|
||||
provide: WorkspaceGraphqlSchemaSDLService,
|
||||
useValue: {},
|
||||
},
|
||||
{
|
||||
provide: MetricsService,
|
||||
useValue: {},
|
||||
},
|
||||
],
|
||||
}).compile();
|
||||
|
||||
|
||||
@@ -4,15 +4,10 @@ import { ScalarsExplorerService } from 'src/engine/api/graphql/services/scalars-
|
||||
import { WorkspaceGraphqlSchemaSDLModule } from 'src/engine/api/graphql/workspace-graphql-schema-sdl/workspace-graphql-schema-sdl.module';
|
||||
import { WorkspaceResolverBuilderModule } from 'src/engine/api/graphql/workspace-resolver-builder/workspace-resolver-builder.module';
|
||||
|
||||
import { MetricsModule } from 'src/engine/core-modules/metrics/metrics.module';
|
||||
import { WorkspaceSchemaFactory } from './workspace-schema.factory';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
WorkspaceResolverBuilderModule,
|
||||
WorkspaceGraphqlSchemaSDLModule,
|
||||
MetricsModule,
|
||||
],
|
||||
imports: [WorkspaceResolverBuilderModule, WorkspaceGraphqlSchemaSDLModule],
|
||||
providers: [WorkspaceSchemaFactory, ScalarsExplorerService],
|
||||
exports: [WorkspaceSchemaFactory],
|
||||
})
|
||||
|
||||
-6
@@ -66,7 +66,6 @@ import { type WorkspaceSchemaBuilderContext } from 'src/engine/api/graphql/works
|
||||
import { UserInputError } from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
|
||||
import { I18nService } from 'src/engine/core-modules/i18n/i18n.service';
|
||||
import { MetricsService } from 'src/engine/core-modules/metrics/metrics.service';
|
||||
import { MetricsKeys } from 'src/engine/core-modules/metrics/types/metrics-keys.type';
|
||||
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||
import { WorkspaceManyOrAllFlatEntityMapsCacheService } from 'src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.service';
|
||||
import { buildObjectIdByNameMaps } from 'src/engine/metadata-modules/flat-object-metadata/utils/build-object-id-by-name-maps.util';
|
||||
@@ -307,11 +306,6 @@ export class DirectExecutionService {
|
||||
variableValues: (req.body?.variables as Record<string, unknown>) ?? {},
|
||||
});
|
||||
|
||||
await this.metricsService.incrementCounter({
|
||||
key: MetricsKeys.GraphqlIntrospectionDirectExecution,
|
||||
shouldStoreInCache: false,
|
||||
});
|
||||
|
||||
return {
|
||||
data: result.data as Record<string, unknown> | undefined,
|
||||
errors: result.errors?.map((error) => error.toJSON()),
|
||||
|
||||
+1
-37
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ContextIdFactory, ModuleRef } from '@nestjs/core';
|
||||
import { ModuleRef } from '@nestjs/core';
|
||||
import { type GqlOptionsFactory } from '@nestjs/graphql';
|
||||
|
||||
import {
|
||||
@@ -8,16 +8,11 @@ import {
|
||||
} from '@graphql-yoga/nestjs';
|
||||
import * as Sentry from '@sentry/node';
|
||||
import GraphQLJSON from 'graphql-type-json';
|
||||
import {
|
||||
type GraphQLSchemaWithContext,
|
||||
type YogaInitialContext,
|
||||
} from 'graphql-yoga';
|
||||
|
||||
import { NodeEnvironment } from 'src/engine/core-modules/twenty-config/interfaces/node-environment.interface';
|
||||
|
||||
import { DirectExecutionService } from 'src/engine/api/graphql/direct-execution/direct-execution.service';
|
||||
import { useDirectExecution } from 'src/engine/api/graphql/direct-execution/hooks/use-direct-execution.hook';
|
||||
import { WorkspaceSchemaFactory } from 'src/engine/api/graphql/workspace-schema.factory';
|
||||
import { type FlatAuthContextUser } from 'src/engine/core-modules/auth/types/flat-auth-context-user.type';
|
||||
import { CoreEngineModule } from 'src/engine/core-modules/core-engine.module';
|
||||
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
|
||||
@@ -28,7 +23,6 @@ import { useGraphQLErrorHandlerHook } from 'src/engine/core-modules/graphql/hook
|
||||
import { useValidateGraphqlQueryComplexity } from 'src/engine/core-modules/graphql/hooks/use-validate-graphql-query-complexity.hook';
|
||||
import { I18nService } from 'src/engine/core-modules/i18n/i18n.service';
|
||||
import { MetricsService } from 'src/engine/core-modules/metrics/metrics.service';
|
||||
import { MetricsKeys } from 'src/engine/core-modules/metrics/types/metrics-keys.type';
|
||||
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||
import { type FlatWorkspace } from 'src/engine/core-modules/workspace/types/flat-workspace.type';
|
||||
import { DataloaderService } from 'src/engine/dataloaders/dataloader.service';
|
||||
@@ -105,34 +99,4 @@ export class GraphQLConfigService
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
async createSchema(
|
||||
context: YogaDriverServerContext<'express'> & YogaInitialContext,
|
||||
workspace: FlatWorkspace,
|
||||
applicationId?: string,
|
||||
): Promise<GraphQLSchemaWithContext<YogaDriverServerContext<'express'>>> {
|
||||
// Create a new contextId for each request
|
||||
const contextId = ContextIdFactory.create();
|
||||
|
||||
if (this.moduleRef.registerRequestByContextId) {
|
||||
// Register the request in the contextId
|
||||
this.moduleRef.registerRequestByContextId(context.req, contextId);
|
||||
}
|
||||
|
||||
// Resolve the WorkspaceSchemaFactory for the contextId
|
||||
const workspaceFactory = await this.moduleRef.resolve(
|
||||
WorkspaceSchemaFactory,
|
||||
contextId,
|
||||
{
|
||||
strict: false,
|
||||
},
|
||||
);
|
||||
|
||||
await this.metricsService.incrementCounter({
|
||||
key: MetricsKeys.GraphqlSchemaBuild,
|
||||
shouldStoreInCache: false,
|
||||
});
|
||||
|
||||
return await workspaceFactory.createGraphQLSchema(workspace, applicationId);
|
||||
}
|
||||
}
|
||||
|
||||
-30
@@ -76,36 +76,6 @@ export class CoreEntityCacheService implements OnModuleInit {
|
||||
this.coreEntityCacheProviders.set(coreEntityCacheKeyName, instance);
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(() => {
|
||||
const stats = this.getStats();
|
||||
|
||||
this.logger.log(
|
||||
`Cache stats: localCacheSize=${stats.localCacheSize} memoizerCacheSize=${stats.memoizerCacheSize} memoizerPendingSize=${stats.memoizerPendingSize} entriesByKey=${JSON.stringify(stats.entriesByKey)} versionsByKey=${JSON.stringify(stats.versionsByKey)}`,
|
||||
);
|
||||
}, 60_000).unref();
|
||||
}
|
||||
|
||||
public getStats() {
|
||||
const memoizerSize = this.memoizer.getSize();
|
||||
const entriesByKey: Record<string, number> = {};
|
||||
const versionsByKey: Record<string, number> = {};
|
||||
|
||||
for (const [key, entry] of this.localCache.entries()) {
|
||||
const prefix = key.substring(0, key.lastIndexOf(':'));
|
||||
|
||||
entriesByKey[prefix] = (entriesByKey[prefix] ?? 0) + 1;
|
||||
versionsByKey[prefix] =
|
||||
(versionsByKey[prefix] ?? 0) + entry.versions.size;
|
||||
}
|
||||
|
||||
return {
|
||||
localCacheSize: this.localCache.size,
|
||||
memoizerCacheSize: memoizerSize.cache,
|
||||
memoizerPendingSize: memoizerSize.pending,
|
||||
entriesByKey,
|
||||
versionsByKey,
|
||||
};
|
||||
}
|
||||
|
||||
public async get<K extends CoreEntityCacheKeyName>(
|
||||
|
||||
@@ -34,6 +34,4 @@ export enum MetricsKeys {
|
||||
JobCompleted = 'job/completed',
|
||||
JobFailed = 'job/failed',
|
||||
JobWaiting = 'job/waiting',
|
||||
GraphqlSchemaBuild = 'graphql/schema-build',
|
||||
GraphqlIntrospectionDirectExecution = 'graphql-introspection/direct-execution',
|
||||
}
|
||||
|
||||
@@ -95,10 +95,6 @@ export class PromiseMemoizer<T> {
|
||||
}
|
||||
}
|
||||
|
||||
getSize(): { cache: number; pending: number } {
|
||||
return { cache: this.cache.size, pending: this.pending.size };
|
||||
}
|
||||
|
||||
async clearAll(onDelete?: (value: T) => Promise<void> | void): Promise<void> {
|
||||
for (const [, entry] of this.cache.entries()) {
|
||||
await onDelete?.(entry.value);
|
||||
|
||||
@@ -94,36 +94,6 @@ export class WorkspaceCacheService implements OnModuleInit {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(() => {
|
||||
const stats = this.getStats();
|
||||
|
||||
this.logger.log(
|
||||
`Cache stats: localCacheSize=${stats.localCacheSize} memoizerCacheSize=${stats.memoizerCacheSize} memoizerPendingSize=${stats.memoizerPendingSize} entriesByKey=${JSON.stringify(stats.entriesByKey)} versionsByKey=${JSON.stringify(stats.versionsByKey)}`,
|
||||
);
|
||||
}, 60_000).unref();
|
||||
}
|
||||
|
||||
public getStats() {
|
||||
const memoizerSize = this.memoizer.getSize();
|
||||
const entriesByKey: Record<string, number> = {};
|
||||
const versionsByKey: Record<string, number> = {};
|
||||
|
||||
for (const [key, entry] of this.localCache.entries()) {
|
||||
const prefix = key.substring(0, key.lastIndexOf(':'));
|
||||
|
||||
entriesByKey[prefix] = (entriesByKey[prefix] ?? 0) + 1;
|
||||
versionsByKey[prefix] =
|
||||
(versionsByKey[prefix] ?? 0) + entry.versions.size;
|
||||
}
|
||||
|
||||
return {
|
||||
localCacheSize: this.localCache.size,
|
||||
memoizerCacheSize: memoizerSize.cache,
|
||||
memoizerPendingSize: memoizerSize.pending,
|
||||
entriesByKey,
|
||||
versionsByKey,
|
||||
};
|
||||
}
|
||||
|
||||
public async getOrRecompute<const K extends WorkspaceCacheKeyName[]>(
|
||||
|
||||
Reference in New Issue
Block a user