@@ -71,14 +71,6 @@ func (app *App) failSwitchover(switchover *Switchover, err error) error {
7171 switchover .Result .Error = err .Error ()
7272 switchover .Result .FinishedAt = time .Now ()
7373
74- // Report failure timing
75- dur := time .Since (switchover .StartedAt )
76- eventName := "switchover_failed"
77- if switchover .Cause == CauseAuto {
78- eventName = "failover_failed"
79- }
80- app .timings .reportTiming (eventName , dur )
81-
8274 return app .dcs .Set (pathCurrentSwitch , switchover )
8375}
8476
@@ -106,17 +98,23 @@ func (app *App) finishSwitchover(switchover *Switchover, switchErr error) error
10698 switchover .Result .Ok = result
10799 switchover .Result .FinishedAt = time .Now ()
108100
101+ var eventName string
102+
109103 if switchErr != nil {
104+ eventName = "switchover_failed"
105+ if switchover .Cause == CauseAuto {
106+ eventName = "failover_failed"
107+ }
110108 switchover .Result .Error = switchErr .Error ()
111109 } else {
112110 // Report success timing
113- dur := time .Since (switchover .StartedAt )
114- eventName := "switchover_complete"
111+ eventName = "switchover_complete"
115112 if switchover .Cause == CauseAuto {
116113 eventName = "failover_complete"
117114 }
118- app .timings .reportTiming (eventName , dur )
119115 }
116+ dur := time .Since (switchover .StartedAt )
117+ app .timings .reportTiming (eventName , dur )
120118
121119 err := app .dcs .Delete (pathCurrentSwitch )
122120 if err != nil {
0 commit comments