From cc2c28ad0d8b10e72c20c5d925e21fe50b65b048 Mon Sep 17 00:00:00 2001 From: Tiina Turban Date: Thu, 5 Oct 2023 20:21:03 +0200 Subject: [PATCH] chore: log slow warnings relative to external request timeout (#17821) --- plugin-server/src/worker/ingestion/hooks.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugin-server/src/worker/ingestion/hooks.ts b/plugin-server/src/worker/ingestion/hooks.ts index 218a6c71d41f1..3057f3c761bab 100644 --- a/plugin-server/src/worker/ingestion/hooks.ts +++ b/plugin-server/src/worker/ingestion/hooks.ts @@ -364,12 +364,15 @@ export class HookCommander { const message = this.formatMessage(webhookUrl, action, event, team) end() + const slowWarningTimeout = this.EXTERNAL_REQUEST_TIMEOUT * 0.7 const timeout = setTimeout(() => { status.warn( '⌛', - `Posting Webhook slow. Timeout warning after 5 sec! url=${webhookUrl} team_id=${team.id} event_id=${event.eventUuid}` + `Posting Webhook slow. Timeout warning after ${ + slowWarningTimeout / 1000 + } sec! url=${webhookUrl} team_id=${team.id} event_id=${event.eventUuid}` ) - }, 5000) + }, slowWarningTimeout) const relevantFetch = isCloud() && (!this.fetchHostnameGuardTeams || this.fetchHostnameGuardTeams.has(team.id)) ? safeTrackedFetch @@ -443,12 +446,15 @@ export class HookCommander { data: { ...data, person: sendablePerson }, } + const slowWarningTimeout = this.EXTERNAL_REQUEST_TIMEOUT * 0.7 const timeout = setTimeout(() => { status.warn( '⌛', - `Posting RestHook slow. Timeout warning after 5 sec! url=${hook.target} team_id=${event.teamId} event_id=${event.eventUuid}` + `Posting RestHook slow. Timeout warning after ${slowWarningTimeout / 1000} sec! url=${ + hook.target + } team_id=${event.teamId} event_id=${event.eventUuid}` ) - }, 5000) + }, slowWarningTimeout) const relevantFetch = isCloud() && (!this.fetchHostnameGuardTeams || this.fetchHostnameGuardTeams.has(hook.team_id)) ? safeTrackedFetch