Skip to content

Commit

Permalink
fix(admin) add the worker info to the response of /timers
Browse files Browse the repository at this point in the history
  • Loading branch information
ADD-SP authored and fffonion committed Jun 24, 2022
1 parent 1a62d7f commit 9c279e4
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 43 deletions.
75 changes: 41 additions & 34 deletions autodoc/admin-api/data/admin-api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -491,45 +491,52 @@ return {
```
```json
{
"flamegraph": {
"running": "@./kong/init.lua:706:init_worker();@./kong/runloop/handler.lua:1086:before() 0\n",
"elapsed_time": "@./kong/init.lua:706:init_worker();@./kong/runloop/handler.lua:1086:before() 17\n",
"pending": "@./kong/init.lua:706:init_worker();@./kong/runloop/handler.lua:1086:before() 0\n"
},
"sys": {
"running": 0,
"runs": 7,
"pending": 0,
"waiting": 7,
"total": 7
{ "worker": {
"id": 0,
"count": 4,
},
"timers": {
"healthcheck-localhost:8080": {
"name": "healthcheck-localhost:8080",
"meta": {
"name": "@/build/luarocks/share/lua/5.1/resty/counter.lua:71:new()",
"callstack": "@./kong/plugins/prometheus/prometheus.lua:673:init_worker();@/build/luarocks/share/lua/5.1/resty/counter.lua:71:new()"
},
"stats": {
"finish": 2,
"runs": 2,
"elapsed_time": {
"min": 0,
"max": 0,
"avg": 0,
"variance": 0
},
"last_err_msg": ""
}
}
"stats": {
"flamegraph": {
"running": "@./kong/init.lua:706:init_worker();@./kong/runloop/handler.lua:1086:before() 0\n",
"elapsed_time": "@./kong/init.lua:706:init_worker();@./kong/runloop/handler.lua:1086:before() 17\n",
"pending": "@./kong/init.lua:706:init_worker();@./kong/runloop/handler.lua:1086:before() 0\n"
},
"sys": {
"running": 0,
"runs": 7,
"pending": 0,
"waiting": 7,
"total": 7
},
"timers": {
"healthcheck-localhost:8080": {
"name": "healthcheck-localhost:8080",
"meta": {
"name": "@/build/luarocks/share/lua/5.1/resty/counter.lua:71:new()",
"callstack": "@./kong/plugins/prometheus/prometheus.lua:673:init_worker();@/build/luarocks/share/lua/5.1/resty/counter.lua:71:new()"
},
"stats": {
"finish": 2,
"runs": 2,
"elapsed_time": {
"min": 0,
"max": 0,
"avg": 0,
"variance": 0
},
"last_err_msg": ""
}
}
}
}
}
```
* `flamegraph`: String-encoded timer-related flamegraph data.
* `worker`:
* `id`: The ordinal number of the current Nginx worker processes (starting from number 0).
* `count`: The total number of the Nginx worker processes.
* `stats.flamegraph`: String-encoded timer-related flamegraph data.
You can use [brendangregg/FlameGraph](https://github.com/brendangregg/FlameGraph) to generate flamegraph svgs.
* `sys`: List the number of different type of timers.
* `stats.sys`: List the number of different type of timers.
* `running`: number of running timers.
* `pending`: number of pending timers.
* `waiting`: number of unexpired timers.
Expand Down
21 changes: 12 additions & 9 deletions spec/02-integration/04-admin_api/20-timers_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,20 @@ local client
local body = assert.res_status(200 , res)
local json = cjson.decode(body)

assert(type(json.flamegraph.running) == "string")
assert(type(json.flamegraph.pending) == "string")
assert(type(json.flamegraph.elapsed_time) == "string")
assert(type(json.worker.id) == "number")
assert(type(json.worker.count) == "number")

assert(type(json.sys.total) == "number")
assert(type(json.sys.runs) == "number")
assert(type(json.sys.running) == "number")
assert(type(json.sys.pending) == "number")
assert(type(json.sys.waiting) == "number")
assert(type(json.stats.flamegraph.running) == "string")
assert(type(json.stats.flamegraph.pending) == "string")
assert(type(json.stats.flamegraph.elapsed_time) == "string")

assert(type(json.timers) == "table")
assert(type(json.stats.sys.total) == "number")
assert(type(json.stats.sys.runs) == "number")
assert(type(json.stats.sys.running) == "number")
assert(type(json.stats.sys.pending) == "number")
assert(type(json.stats.sys.waiting) == "number")

assert(type(json.stats.timers) == "table")

end)

Expand Down

0 comments on commit 9c279e4

Please sign in to comment.