diff --git a/pkg/cloud/services/compute/instance.go b/pkg/cloud/services/compute/instance.go index 0f8197f533..2abafcb1ca 100644 --- a/pkg/cloud/services/compute/instance.go +++ b/pkg/cloud/services/compute/instance.go @@ -769,11 +769,11 @@ func (s *Service) getPort(portID string) (port *ports.Port, err error) { } mc := metrics.NewMetricPrometheusContext("port", "get") port, err = ports.Get(s.networkClient, portID).Extract() - if mc.ObserveRequest(err) != nil { + if err != nil { if capoerrors.IsNotFound(err) { return nil, nil } - return nil, fmt.Errorf("get port %q detail failed: %v", portID, err) + return nil, fmt.Errorf("get port %q detail failed: %v", portID, mc.ObserveRequest(err)) } return port, nil } @@ -819,11 +819,11 @@ func (s *Service) GetInstance(resourceID string) (instance *infrav1.Instance, er } mc := metrics.NewMetricPrometheusContext("server", "get") server, err := servers.Get(s.computeClient, resourceID).Extract() - if mc.ObserveRequest(err) != nil { + if err != nil { if capoerrors.IsNotFound(err) { return nil, nil } - return nil, fmt.Errorf("get server %q detail failed: %v", resourceID, err) + return nil, fmt.Errorf("get server %q detail failed: %v", resourceID, mc.ObserveRequest(err)) } i, err := serverToInstance(server) if err != nil {