diff --git a/rest/httpc/requests.go b/rest/httpc/requests.go index bc1251596671..ede500697d0f 100644 --- a/rest/httpc/requests.go +++ b/rest/httpc/requests.go @@ -39,7 +39,11 @@ func Do(ctx context.Context, method, url string, data any) (*http.Response, erro // DoRequest sends an HTTP request and returns an HTTP response. func DoRequest(r *http.Request) (*http.Response, error) { - return request(r, defaultClient{}) + interceptor := internal.MetricsInterceptor("", nil) + r, handler := interceptor(r) + resp, err := request(r, defaultClient{}) + handler(resp, err) + return resp, err } type ( diff --git a/rest/httpc/service.go b/rest/httpc/service.go index a65880e324ab..9831846624bf 100644 --- a/rest/httpc/service.go +++ b/rest/httpc/service.go @@ -5,6 +5,7 @@ import ( "net/http" "github.com/zeromicro/go-zero/core/breaker" + "github.com/zeromicro/go-zero/rest/httpc/internal" ) type ( @@ -54,7 +55,11 @@ func (s namedService) Do(ctx context.Context, method, url string, data any) (*ht // DoRequest sends an HTTP request to the service. func (s namedService) DoRequest(r *http.Request) (*http.Response, error) { - return request(r, s) + interceptor := internal.MetricsInterceptor(s.name, nil) + r, handler := interceptor(r) + resp, err := request(r, s) + handler(resp, err) + return resp, err } func (s namedService) do(r *http.Request) (resp *http.Response, err error) {