Per the following code, Kong skips runloop.access.after(ctx)
if ctx.delayed_response
has values. Therefore, KONG_ACCESS_TIME
is not calculated.
function Kong.access()
kong_global.set_phase(kong, PHASES.access)
local ctx = ngx.ctx
runloop.access.before(ctx)
ctx.delay_response = true
for plugin, plugin_conf in plugins_iterator(ctx, loaded_plugins,
configured_plugins, true) do
if not ctx.delayed_response then
kong_global.set_named_ctx(kong, "plugin", plugin_conf)
kong_global.set_namespaced_log(kong, plugin.name)
local err = coroutine.wrap(plugin.handler.access)(plugin.handler, plugin_conf)
kong_global.reset_log(kong)
if err then
ctx.delay_response = false
kong.log.err(err)
return kong.response.exit(500, { message = "An unexpected error occurred" })
end
end
end
if ctx.delayed_response then
return flush_delayed_response(ctx)
end
ctx.delay_response = false
runloop.access.after(ctx)
end