@@ -156,12 +156,15 @@ func (s *Controller) handleActions(ctx context.Context, clusterActions []*castai
156156
157157 var err error
158158
159+ startTime := time .Now ()
159160 handleErr := s .handleAction (ctx , action )
160161 if errors .Is (handleErr , context .Canceled ) {
161162 // Action should be handled again on context canceled errors.
162163 return
163164 }
164- ackErr := s .ackAction (ctx , action , handleErr )
165+
166+ handleDuration := time .Since (startTime )
167+ ackErr := s .ackAction (ctx , action , handleErr , handleDuration )
165168 if handleErr != nil {
166169 err = handleErr
167170 }
@@ -235,7 +238,7 @@ func (s *Controller) handleAction(ctx context.Context, action *castai.ClusterAct
235238 return nil
236239}
237240
238- func (s * Controller ) ackAction (ctx context.Context , action * castai.ClusterAction , handleErr error ) error {
241+ func (s * Controller ) ackAction (ctx context.Context , action * castai.ClusterAction , handleErr error , handleDuration time. Duration ) error {
239242 actionType := action .GetType ()
240243 actionError := getHandlerError (handleErr )
241244 s .log .WithFields (logrus.Fields {
@@ -244,7 +247,7 @@ func (s *Controller) ackAction(ctx context.Context, action *castai.ClusterAction
244247 "successful" : actionError == nil ,
245248 }).Info ("ack action" )
246249
247- metrics .ActionFinished (actionType , actionError == nil )
250+ metrics .ActionFinished (actionType , actionError == nil , handleDuration )
248251
249252 boff := waitext .NewConstantBackoff (s .cfg .AckRetryWait )
250253
0 commit comments