77
withCounter func(metrics.Handler) metrics.CounterIface,
78
counterTags ...metrics.Tag,
80
>
handler := operationMetricsHandler(base, tagConfig, op, namespaceName, workflowType)
81
>
withCounter(handler).Record(1, counterTags...)
82
>
emitCompletionLatencies(handler, op, closeTime, metrics.OutcomeTag(strings.ToLower(status.String())))
83
>
}
84
85
// emitCompletionLatencies emits schedule-to-close plus either start-to-close (operations that
86
// started) or schedule-to-start (sync / never-started), mirroring chasm/lib/nexusoperation's
87
// emitLatencyMetrics. It is shared by the per-outcome recorders above.
88
>
func emitCompletionLatencies(handler metrics.Handler, op Operation, closeTime time.Time, outcomeTag metrics.Tag) {
metrics.go
89
>
if op.ScheduledTime == nil {
90
return
91
}
92
>
scheduledTime := op.ScheduledTime.AsTime()
metrics.go
93
>
chasmnexus.NexusOperationScheduleToCloseLatency.With(handler).Record(closeTime.Sub(scheduledTime), outcomeTag)
94
>
if op.StartedTime != nil {
95
// Async operation that was started; schedule-to-start latency was emitted at start time.
96
chasmnexus.NexusOperationStartToCloseLatency.With(handler).Record(closeTime.Sub(op.StartedTime.AsTime()), outcomeTag)
98
// Sync operation or operation that never started.
99
chasmnexus.NexusOperationScheduleToStartLatency.With(handler).Record(closeTime.Sub(scheduledTime))