Skip to content

Commit 9f7eff7

Browse files
committed
[custom_metrics] handle error when backend url is invalid
1 parent 293613f commit 9f7eff7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

gateway/src/apicast/policy/custom_metrics/custom_metrics.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ end
9090

9191
-- report: Report the given usage information to the backend
9292
function _M.report(context, usage)
93-
local backend = backend_client:new(context.service, http_ng_resty)
93+
local backend, err = backend_client:new(context.service, http_ng_resty)
94+
if not backend then
95+
ngx.log(ngx.ERR, "failed to create backend_client, err: ", err)
96+
return
97+
end
9498
local reports = {}
9599
for key, value in pairs(usage.deltas) do
96100
local result = deepcopy(context.credentials)

0 commit comments

Comments
 (0)