From 2e373b519462944efeffb36847b7db4713542b05 Mon Sep 17 00:00:00 2001 From: Brett Hoerner Date: Tue, 5 Dec 2023 09:25:12 -0700 Subject: [PATCH] chore(plugin-server): fix cardinality of plugin_action_ms (#19099) --- plugin-server/src/utils/db/postgres.ts | 2 +- plugin-server/src/worker/plugins/run.ts | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugin-server/src/utils/db/postgres.ts b/plugin-server/src/utils/db/postgres.ts index caf7d13dd201a1..7e859a3bc225e0 100644 --- a/plugin-server/src/utils/db/postgres.ts +++ b/plugin-server/src/utils/db/postgres.ts @@ -105,7 +105,7 @@ export class PostgresRouter { transaction: (client: TransactionClient) => Promise ): Promise { const wrappedTag = `${PostgresUse[usage]}:Tx<${tag}>` - return instrumentQuery(this.statsd, 'query.postgres_transation', wrappedTag, async () => { + return instrumentQuery(this.statsd, 'query.postgres_transaction', wrappedTag, async () => { const timeout = timeoutGuard(`Postgres slow transaction warning after 30 sec!`) const client = await this.pools.get(usage)!.connect() try { diff --git a/plugin-server/src/worker/plugins/run.ts b/plugin-server/src/worker/plugins/run.ts index b9f4e45a26af0d..d07e33dc67bd94 100644 --- a/plugin-server/src/worker/plugins/run.ts +++ b/plugin-server/src/worker/plugins/run.ts @@ -36,7 +36,7 @@ async function runSingleTeamPluginOnEvent( try { await onEvent!(event) pluginActionMsSummary - .labels(pluginConfig.id.toString(), 'onEvent', 'success') + .labels(pluginConfig.plugin?.id.toString() ?? '?', 'onEvent', 'success') .observe(new Date().getTime() - timer.getTime()) await hub.appMetrics.queueMetric({ teamId: event.team_id, @@ -47,7 +47,7 @@ async function runSingleTeamPluginOnEvent( } catch (error) { hub.statsd?.increment(`${metricName}.ERROR`, metricTags) pluginActionMsSummary - .labels(pluginConfig.id.toString(), 'onEvent', 'error') + .labels(pluginConfig.plugin?.id.toString() ?? '?', 'onEvent', 'error') .observe(new Date().getTime() - timer.getTime()) await processError(hub, pluginConfig, error, event) await hub.appMetrics.queueError( @@ -130,7 +130,7 @@ async function runSingleTeamPluginComposeWebhook( }) if (request.ok) { pluginActionMsSummary - .labels(pluginConfig.id.toString(), 'composeWebhook', 'success') + .labels(pluginConfig.plugin?.id.toString() ?? '?', 'composeWebhook', 'success') .observe(new Date().getTime() - timer.getTime()) await hub.appMetrics.queueMetric({ teamId: event.team_id, @@ -141,7 +141,7 @@ async function runSingleTeamPluginComposeWebhook( } else { hub.statsd?.increment(`${metricName}.ERROR`, metricTags) pluginActionMsSummary - .labels(pluginConfig.id.toString(), 'composeWebhook', 'error') + .labels(pluginConfig.plugin?.id.toString() ?? '?', 'composeWebhook', 'error') .observe(new Date().getTime() - timer.getTime()) const error = `Fetch to ${webhook.url} failed with ${request.statusText}` await processError(hub, pluginConfig, error, event) @@ -161,7 +161,7 @@ async function runSingleTeamPluginComposeWebhook( } catch (error) { hub.statsd?.increment(`${metricName}.ERROR`, metricTags) pluginActionMsSummary - .labels(pluginConfig.id.toString(), 'composeWebhook', 'error') + .labels(pluginConfig.plugin?.id.toString() ?? '?', 'composeWebhook', 'error') .observe(new Date().getTime() - timer.getTime()) await processError(hub, pluginConfig, error, event) await hub.appMetrics.queueError( @@ -239,7 +239,7 @@ export async function runProcessEvent(hub: Hub, event: PluginEvent): Promise