Skip to content

Commit e929942

Browse files
committed
backend_client: update 3scale backend status metric
1 parent 0f727d8 commit e929942

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

gateway/src/apicast/backend_client.lua

+9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ local http_ng = require('resty.http_ng')
2020
local user_agent = require('apicast.user_agent')
2121
local resty_url = require('resty.url')
2222
local resty_env = require('resty.env')
23+
local threescale_backend_status_counters = require('apicast.metrics.3scale_backend_status')
2324

2425
local http_proxy = require('resty.http.proxy')
2526
local http_ng_ngx = require('resty.http_ng.backend.ngx')
@@ -97,6 +98,10 @@ function _M:new(service, http_client)
9798
}, mt)
9899
end
99100

101+
local function inc_backend_status_metric(status)
102+
threescale_backend_status_counters.inc(status)
103+
end
104+
100105
local function build_args(args)
101106
local query = {}
102107

@@ -133,6 +138,8 @@ local function call_backend_transaction(self, path, options, ...)
133138

134139
ngx.log(ngx.INFO, 'backend client uri: ', url, ' ok: ', res.ok, ' status: ', res.status, ' body: ', res.body, ' error: ', res.error)
135140

141+
inc_backend_status_metric(res.status)
142+
136143
return res
137144
end
138145

@@ -229,6 +236,8 @@ function _M:report(reports_batch)
229236
local report_body = format_transactions(reports_batch)
230237
local res = http_client.post(report_uri, report_body)
231238

239+
inc_backend_status_metric(res.status)
240+
232241
return res
233242
end
234243

0 commit comments

Comments
 (0)