Skip to content

Commit

Permalink
backend_client: update 3scale backend status metric
Browse files Browse the repository at this point in the history
  • Loading branch information
davidor committed Aug 30, 2018
1 parent 0f727d8 commit e929942
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions gateway/src/apicast/backend_client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ local http_ng = require('resty.http_ng')
local user_agent = require('apicast.user_agent')
local resty_url = require('resty.url')
local resty_env = require('resty.env')
local threescale_backend_status_counters = require('apicast.metrics.3scale_backend_status')

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

local function inc_backend_status_metric(status)
threescale_backend_status_counters.inc(status)
end

local function build_args(args)
local query = {}

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

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

inc_backend_status_metric(res.status)

return res
end

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

inc_backend_status_metric(res.status)

return res
end

Expand Down

0 comments on commit e929942

Please sign in to comment.