File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
services/archetypes/worker/src Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export class ActivityMonitoringInterceptor implements ActivityInboundCallsInterc
1818 activity_type : this . ctx . info . activityType ,
1919 }
2020
21- const timer = telemetry . timer ( 'temporal.activity_execution_duration' , tags )
21+ const start = new Date ( )
2222
2323 try {
2424 const res = await next ( input )
@@ -36,7 +36,13 @@ export class ActivityMonitoringInterceptor implements ActivityInboundCallsInterc
3636 log . error ( err , 'Error while processing an activity!' )
3737 throw err
3838 } finally {
39- timer . stop ( )
39+ const end = new Date ( )
40+ const duration = end . getTime ( ) - start . getTime ( )
41+
42+ // Only send telemetry if duration is more than 2 hours
43+ if ( duration > 2 * 60 * 60 * 1000 ) {
44+ telemetry . distribution ( 'temporal.activity_execution_duration' , duration , tags )
45+ }
4046 }
4147 }
4248}
Original file line number Diff line number Diff line change @@ -34,7 +34,11 @@ export class WorkflowMonitoringInterceptor implements WorkflowInboundCallsInterc
3434 } finally {
3535 const end = new Date ( )
3636 const duration = end . getTime ( ) - start . getTime ( )
37- await activity . telemetryDistribution ( 'temporal.workflow_execution_duration' , duration , tags )
37+
38+ // Only send telemetry if duration is more than 2 hours
39+ if ( duration > 3 * 60 * 60 * 1000 ) {
40+ await activity . telemetryDistribution ( 'temporal.workflow_execution_duration' , duration , tags )
41+ }
3842 }
3943 }
4044}
You can’t perform that action at this time.
0 commit comments