Skip to content

Commit 9cd7c7b

Browse files
authored
chore: additional telemetry data so we can build alerting around it (#3425)
Signed-off-by: Uroš Marolt <[email protected]>
1 parent ba0e1f3 commit 9cd7c7b

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

services/archetypes/worker/src/activities/activityInterceptor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ export class ActivityMonitoringInterceptor implements ActivityInboundCallsInterc
1616
workflow_type: this.ctx.info.workflowType,
1717
task_queue: this.ctx.info.taskQueue,
1818
activity_type: this.ctx.info.activityType,
19+
attempts: this.ctx.info.attempt,
1920
}
2021

22+
telemetry.increment('temporal.activity_execution', 1, tags)
23+
2124
const start = new Date()
2225

2326
try {

services/archetypes/worker/src/activities/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,12 @@ async function telemetryDistribution(
88
telemetry.distribution(name, value, tags)
99
}
1010

11-
export { telemetryDistribution }
11+
async function telemetryIncrement(
12+
name: string,
13+
value: number,
14+
tags?: Record<string, string | number>,
15+
) {
16+
telemetry.increment(name, value, tags)
17+
}
18+
19+
export { telemetryDistribution, telemetryIncrement }

services/archetypes/worker/src/interceptors.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@ export class WorkflowMonitoringInterceptor implements WorkflowInboundCallsInterc
2424
workflow_id: info.workflowId,
2525
workflow_type: info.workflowType,
2626
task_queue: info.taskQueue,
27+
attempts: info.attempt,
2728
}
2829

2930
const start = new Date()
3031

3132
try {
3233
const result = await next(input)
3334
return result
35+
} catch (err) {
36+
await activity.telemetryIncrement('temporal.workflow_execution_error', 1, tags)
37+
throw err
3438
} finally {
3539
const end = new Date()
3640
const duration = end.getTime() - start.getTime()

0 commit comments

Comments
 (0)