Skip to content

Commit

Permalink
chore(plugin-server): switch console.log usage to status (#17741)
Browse files Browse the repository at this point in the history
  • Loading branch information
bretthoerner authored Oct 4, 2023
1 parent 05d5610 commit 731504f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion plugin-server/src/utils/db/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DateTime } from 'luxon'
import { defaultConfig } from '../../config/config'
import { KAFKA_PERSON } from '../../config/kafka-topics'
import { BasePerson, Person, RawPerson, TimestampFormat } from '../../types'
import { status } from '../../utils/status'
import { castTimestampOrNow } from '../../utils/utils'
import { PluginLogEntrySource, PluginLogEntryType, PluginLogLevel } from './../../types'

Expand Down Expand Up @@ -35,7 +36,7 @@ export function timeoutGuard(
): NodeJS.Timeout {
return setTimeout(() => {
const ctx = typeof context === 'function' ? context() : context
console.log(`⌛⌛⌛ ${message}`, ctx)
status.warn('⌛', message, ctx)
Sentry.captureMessage(message, ctx ? { extra: ctx } : undefined)
}, timeout)
}
Expand Down
4 changes: 2 additions & 2 deletions plugin-server/src/worker/ingestion/app-metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class AppMetrics {
}

async flush(): Promise<void> {
console.log(`Flushing app metrics`)
status.debug('🚽', `Flushing app metrics`)
const startTime = Date.now()
this.lastFlushTime = startTime
if (Object.keys(this.queuedData).length === 0) {
Expand Down Expand Up @@ -170,7 +170,7 @@ export class AppMetrics {
topic: KAFKA_APP_METRICS,
messages: kafkaMessages,
})
console.log(`Finisehd flushing app metrics, took ${Date.now() - startTime}ms`)
status.debug('🚽', `Finished flushing app metrics, took ${Date.now() - startTime}ms`)
}

_metricErrorParameters(errorWithContext: ErrorWithContext): Partial<AppMetric> {
Expand Down
10 changes: 6 additions & 4 deletions plugin-server/src/worker/ingestion/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,9 @@ export class HookCommander {
end()

const timeout = setTimeout(() => {
console.log(
`⌛⌛⌛ Posting Webhook slow. Timeout warning after 5 sec! url=${webhookUrl} team_id=${team.id} event_id=${event.eventUuid}`
status.warn(
'⌛',
`Posting Webhook slow. Timeout warning after 5 sec! url=${webhookUrl} team_id=${team.id} event_id=${event.eventUuid}`
)
}, 5000)
const relevantFetch =
Expand Down Expand Up @@ -404,8 +405,9 @@ export class HookCommander {
}

const timeout = setTimeout(() => {
console.log(
`⌛⌛⌛ Posting RestHook slow. Timeout warning after 5 sec! url=${hook.target} team_id=${event.teamId} event_id=${event.eventUuid}`
status.warn(
'⌛',
`Posting RestHook slow. Timeout warning after 5 sec! url=${hook.target} team_id=${event.teamId} event_id=${event.eventUuid}`
)
}, 5000)
const relevantFetch =
Expand Down
4 changes: 1 addition & 3 deletions plugin-server/src/worker/plugins/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ async function runSingleTeamPluginOnEvent(
onEvent: any
): Promise<void> {
const timeout = setTimeout(() => {
console.log(
`⌛⌛⌛ Still running single onEvent plugin for team ${event.team_id} for plugin ${pluginConfig.id}`
)
status.warn('⌛', `Still running single onEvent plugin for team ${event.team_id} for plugin ${pluginConfig.id}`)
}, 10 * 1000) // 10 seconds
try {
// Runs onEvent for a single plugin without any retries
Expand Down

0 comments on commit 731504f

Please sign in to comment.