From dd65a321b3f26337062843013e60291c95337b62 Mon Sep 17 00:00:00 2001 From: Xavier Vello Date: Wed, 22 Nov 2023 14:29:51 +0100 Subject: [PATCH] fix tests? --- plugin-server/src/config/config.ts | 3 ++- plugin-server/src/types.ts | 1 + plugin-server/src/utils/db/db.ts | 8 +++++--- plugin-server/src/utils/db/hub.ts | 10 +++++++++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/plugin-server/src/config/config.ts b/plugin-server/src/config/config.ts index 5d08afb6428fe9..031e108eb691c4 100644 --- a/plugin-server/src/config/config.ts +++ b/plugin-server/src/config/config.ts @@ -1,4 +1,4 @@ -import { LogLevel, PluginsServerConfig, stringToPluginServerMode, ValueMatcher } from '../types' +import { LogLevel, PluginLogLevel, PluginsServerConfig, stringToPluginServerMode, ValueMatcher } from '../types' import { isDevEnv, isTestEnv, stringToBoolean } from '../utils/env-utils' import { KAFKAJS_LOG_LEVEL_MAPPING } from './constants' import { @@ -72,6 +72,7 @@ export function getDefaultConfig(): PluginsServerConfig { TASKS_PER_WORKER: 10, INGESTION_CONCURRENCY: 10, INGESTION_BATCH_SIZE: 500, + PLUGINS_DEFAULT_LOG_LEVEL: isTestEnv() ? PluginLogLevel.Full : PluginLogLevel.Log, LOG_LEVEL: isTestEnv() ? LogLevel.Warn : LogLevel.Info, SENTRY_DSN: null, SENTRY_PLUGIN_SERVER_TRACING_SAMPLE_RATE: 0, diff --git a/plugin-server/src/types.ts b/plugin-server/src/types.ts index af3d34f69cc18b..c4a973118a8876 100644 --- a/plugin-server/src/types.ts +++ b/plugin-server/src/types.ts @@ -146,6 +146,7 @@ export interface PluginsServerConfig { APP_METRICS_FLUSH_MAX_QUEUE_SIZE: number BASE_DIR: string // base path for resolving local plugins PLUGINS_RELOAD_PUBSUB_CHANNEL: string // Redis channel for reload events' + PLUGINS_DEFAULT_LOG_LEVEL: PluginLogLevel LOG_LEVEL: LogLevel SENTRY_DSN: string | null SENTRY_PLUGIN_SERVER_TRACING_SAMPLE_RATE: number // Rate of tracing in plugin server (between 0 and 1) diff --git a/plugin-server/src/utils/db/db.ts b/plugin-server/src/utils/db/db.ts index f6999b3caae853..2cb417c7f5a6f5 100644 --- a/plugin-server/src/utils/db/db.ts +++ b/plugin-server/src/utils/db/db.ts @@ -158,8 +158,8 @@ export class DB { /** How many unique group types to allow per team */ MAX_GROUP_TYPES_PER_TEAM = 5 - /** Whether to write to clickhouse_person_unique_id topic */ - writeToPersonUniqueId?: boolean + /** Default log level for plugins that don't specify it */ + pluginsDefaultLogLevel: PluginLogLevel /** How many seconds to keep person info in Redis cache */ PERSONS_AND_GROUPS_CACHE_TTL: number @@ -170,6 +170,7 @@ export class DB { kafkaProducer: KafkaProducerWrapper, clickhouse: ClickHouse, statsd: StatsD | undefined, + pluginsDefaultLogLevel: PluginLogLevel, personAndGroupsCacheTtl = 1 ) { this.postgres = postgres @@ -177,6 +178,7 @@ export class DB { this.kafkaProducer = kafkaProducer this.clickhouse = clickhouse this.statsd = statsd + this.pluginsDefaultLogLevel = pluginsDefaultLogLevel this.PERSONS_AND_GROUPS_CACHE_TTL = personAndGroupsCacheTtl } @@ -1076,7 +1078,7 @@ export class DB { public async queuePluginLogEntry(entry: LogEntryPayload): Promise { const { pluginConfig, source, message, type, timestamp, instanceId } = entry - const configuredLogLevel = pluginConfig.plugin?.log_level || PluginLogLevel.Log + const configuredLogLevel = pluginConfig.plugin?.log_level || this.pluginsDefaultLogLevel if (!shouldStoreLog(configuredLogLevel, type)) { return diff --git a/plugin-server/src/utils/db/hub.ts b/plugin-server/src/utils/db/hub.ts index 2d5c780b7336ea..5a462590d77444 100644 --- a/plugin-server/src/utils/db/hub.ts +++ b/plugin-server/src/utils/db/hub.ts @@ -137,7 +137,15 @@ export async function createHub( const promiseManager = new PromiseManager(serverConfig, statsd) - const db = new DB(postgres, redisPool, kafkaProducer, clickhouse, statsd, serverConfig.PERSON_INFO_CACHE_TTL) + const db = new DB( + postgres, + redisPool, + kafkaProducer, + clickhouse, + statsd, + serverConfig.PLUGINS_DEFAULT_LOG_LEVEL, + serverConfig.PERSON_INFO_CACHE_TTL + ) const teamManager = new TeamManager(postgres, serverConfig, statsd) const organizationManager = new OrganizationManager(postgres, teamManager) const pluginsApiKeyManager = new PluginsApiKeyManager(db)