Skip to content

Commit

Permalink
fix tests?
Browse files Browse the repository at this point in the history
  • Loading branch information
xvello committed Nov 22, 2023
1 parent 8684850 commit dd65a32
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion plugin-server/src/config/config.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions plugin-server/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions plugin-server/src/utils/db/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -170,13 +170,15 @@ export class DB {
kafkaProducer: KafkaProducerWrapper,
clickhouse: ClickHouse,
statsd: StatsD | undefined,
pluginsDefaultLogLevel: PluginLogLevel,
personAndGroupsCacheTtl = 1
) {
this.postgres = postgres
this.redisPool = redisPool
this.kafkaProducer = kafkaProducer
this.clickhouse = clickhouse
this.statsd = statsd
this.pluginsDefaultLogLevel = pluginsDefaultLogLevel
this.PERSONS_AND_GROUPS_CACHE_TTL = personAndGroupsCacheTtl
}

Expand Down Expand Up @@ -1076,7 +1078,7 @@ export class DB {

public async queuePluginLogEntry(entry: LogEntryPayload): Promise<void> {
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
Expand Down
10 changes: 9 additions & 1 deletion plugin-server/src/utils/db/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit dd65a32

Please sign in to comment.