654
655
// emitLatencyMetrics emits schedule-to-close, schedule-to-start, and start-to-close latencies.
656
>
func (o *Operation) emitLatencyMetrics(handler metrics.Handler, closeTime time.Time, outcomeTag metrics.Tag) {
operation.go
657
>
scheduledTime := o.GetScheduledTime().AsTime()
658
>
NexusOperationScheduleToCloseLatency.With(handler).Record(closeTime.Sub(scheduledTime), outcomeTag)
659
>
660
>
startedTime := o.GetStartedTime()
661
>
if startedTime != nil {
662
// Async operation that was started.
663
// Schedule-to-start latency is emitted in TransitionStarted.
664
NexusOperationStartToCloseLatency.With(handler).Record(closeTime.Sub(startedTime.AsTime()), outcomeTag)
666
// Sync operation or operation that never started.
667
// For sync ops, schedule-to-start equals schedule-to-close.