Skip to content

Commit

Permalink
chore(plugin-server): fix cardinality of plugin_action_ms (#19099)
Browse files Browse the repository at this point in the history
  • Loading branch information
bretthoerner authored and Twixes committed Dec 6, 2023
1 parent 4b71856 commit 2e373b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion plugin-server/src/utils/db/postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class PostgresRouter {
transaction: (client: TransactionClient) => Promise<ReturnType>
): Promise<ReturnType> {
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 {
Expand Down
14 changes: 7 additions & 7 deletions plugin-server/src/worker/plugins/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand All @@ -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(
Expand Down Expand Up @@ -239,7 +239,7 @@ export async function runProcessEvent(hub: Hub, event: PluginEvent): Promise<Plu
}
pluginsSucceeded.push(pluginIdentifier)
pluginActionMsSummary
.labels(pluginConfig.id.toString(), 'processEvent', 'success')
.labels(pluginConfig.plugin?.id.toString() ?? '?', 'processEvent', 'success')
.observe(new Date().getTime() - timer.getTime())
await hub.appMetrics.queueMetric({
teamId,
Expand All @@ -250,7 +250,7 @@ export async function runProcessEvent(hub: Hub, event: PluginEvent): Promise<Plu
} catch (error) {
await processError(hub, pluginConfig, error, returnedEvent)
pluginActionMsSummary
.labels(pluginConfig.id.toString(), 'processEvent', 'error')
.labels(pluginConfig.plugin?.id.toString() ?? '?', 'processEvent', 'error')
.observe(new Date().getTime() - timer.getTime())
hub.statsd?.increment(`plugin.process_event.ERROR`, {
plugin: pluginConfig.plugin?.name ?? '?',
Expand Down

0 comments on commit 2e373b5

Please sign in to comment.