-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,8 +177,8 @@ end | |
|
||
-- Calls `access()` on every loaded plugin | ||
function _M.exec_plugins_access() | ||
-- Setting a property that will be available for every plugin | ||
ngx.ctx.started_at = get_now() | ||
local start = get_now() | ||
|
||
ngx.ctx.plugin_conf = {} | ||
|
||
-- Iterate over all the plugins | ||
|
@@ -205,13 +205,12 @@ function _M.exec_plugins_access() | |
final_url = final_url.."?"..ngx.encode_args(ngx.req.get_uri_args()) | ||
end | ||
ngx.var.backend_url = final_url | ||
ngx.ctx.proxy_started_at = get_now() | ||
ngx.ctx.kong_processing_access = get_now() - start | ||
end | ||
|
||
-- Calls `header_filter()` on every loaded plugin | ||
function _M.exec_plugins_header_filter() | ||
ngx.ctx.proxy_ended_at = get_now() | ||
|
||
local start = get_now() | ||
if not ngx.ctx.stop_phases then | ||
ngx.header["Via"] = constants.NAME.."/"..constants.VERSION | ||
|
||
|
@@ -222,10 +221,12 @@ function _M.exec_plugins_header_filter() | |
end | ||
end | ||
end | ||
ngx.ctx.kong_processing_header_filter = get_now() - start | ||
end | ||
|
||
-- Calls `body_filter()` on every loaded plugin | ||
function _M.exec_plugins_body_filter() | ||
local start = get_now() | ||
if not ngx.ctx.stop_phases then | ||
for _, plugin in ipairs(plugins) do | ||
local conf = ngx.ctx.plugin_conf[plugin.name] | ||
|
@@ -234,7 +235,7 @@ function _M.exec_plugins_body_filter() | |
end | ||
end | ||
end | ||
ngx.ctx.ended_at = get_now() | ||
ngx.ctx.kong_processing_body_filter = get_now() - start | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
subnetmarco
Author
Member
|
||
end | ||
|
||
-- Calls `log()` on every loaded plugin | ||
|
@@ -256,14 +257,14 @@ function _M.exec_plugins_log() | |
size = ngx.var.bytes_sent | ||
}, | ||
latencies = { | ||
kong = (ngx.ctx.ended_at - ngx.ctx.started_at) - (ngx.ctx.proxy_ended_at - ngx.ctx.proxy_started_at), | ||
proxy = ngx.ctx.proxy_ended_at - ngx.ctx.proxy_started_at, | ||
total = ngx.ctx.ended_at - ngx.ctx.started_at | ||
kong = (ngx.ctx.kong_processing_access + ngx.ctx.kong_processing_header_filter + ngx.ctx.kong_processing_body_filter), | ||
proxy = ngx.var.upstream_response_time * 1000, | ||
request = ngx.var.request_time * 1000 | ||
This comment has been minimized.
Sorry, something went wrong.
thibaultcha
Member
|
||
}, | ||
authenticated_entity = ngx.ctx.authenticated_entity, | ||
api = ngx.ctx.api, | ||
client_ip = ngx.var.remote_addr, | ||
started_at = ngx.ctx.started_at | ||
started_at = ngx.req.start_time() * 1000 | ||
} | ||
|
||
ngx.ctx.log_message = message | ||
|
6 comments
on commit b82c568
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API analytics plugin needs the values you removed (started_at, proxy_ended_at, proxy_started_at). Those were also values we agreed on leaving for plugins to publicly use them.
Also, it also already updated a lot of things in the timestamp computations and will have tons of conflicts...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of those values were not currently used and ngx.var.upstream_response_time
is more accurate. Once we merge the analytics plugin into master we need to remember to update anything that we need to update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We agreed on those values being usable by any plugin. Removing them potentially breaks plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's okay to release them in 0.4.0
as a breaking change, the previous values were technically incorrect so better to fix any incoherence before having a higher adoption.
I was going ahead to update the analytics plugin, but I don't see it anywhere (not even in a separate branch).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thibaultcha can you push the analytics plugin in a separate branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, didn't see the pull request #272
You know this won't give you the time at which the response has finished being received right? Only the first chunk of the response from upstream.