Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change: add more prometheus metrics(etcd modify index) #1888

Merged
merged 18 commits into from
Jul 30, 2020
Merged
4 changes: 3 additions & 1 deletion apisix/core/config_etcd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ local function sync_data(self)

log.info("waitdir key: ", self.key, " prev_index: ", self.prev_index + 1)
log.info("res: ", json.delay_encode(dir_res, true))
if not dir_res then
if err and err == "timeout" then
nic-chen marked this conversation as resolved.
Show resolved Hide resolved
if key_res and key_res.headers then
local key_index = key_res.headers["X-Etcd-Index"]
local key_idx = key_index and tonumber(key_index) or 0
Expand All @@ -238,7 +238,9 @@ local function sync_data(self)
self:upgrade_version(key_index)
end
end
end

if not dir_res then
return false, err
end

Expand Down
7 changes: 2 additions & 5 deletions t/core/etcd-sync.t
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ prev_index updated
item_schema = core.schema.consumer
})

ngx.sleep(0.5)
ngx.sleep(0.2)
local idx = consumers.prev_index

core.log.error("idx:", idx)
Expand All @@ -81,7 +81,7 @@ prev_index updated
local val = "test_value"
core.etcd.set(key, val)

ngx.sleep(2)
ngx.sleep(1)

local new_idx = consumers.prev_index
core.log.error("new_idx:", new_idx)
Expand All @@ -98,6 +98,3 @@ GET /t
--- response_body
prev_index not update
--- timeout: 3