diff --git a/topdown/http.go b/topdown/http.go index 9d01bc14b2..a84faf0851 100644 --- a/topdown/http.go +++ b/topdown/http.go @@ -168,6 +168,7 @@ func generateRaiseErrorResult(err error) *ast.Term { func getHTTPResponse(bctx BuiltinContext, req ast.Object) (*ast.Term, error) { bctx.Metrics.Timer(httpSendLatencyMetricKey).Start() + defer bctx.Metrics.Timer(httpSendLatencyMetricKey).Stop() key, err := getKeyFromRequest(req) if err != nil { @@ -199,8 +200,6 @@ func getHTTPResponse(bctx BuiltinContext, req ast.Object) (*ast.Term, error) { } } - bctx.Metrics.Timer(httpSendLatencyMetricKey).Stop() - return ast.NewTerm(resp), nil }