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

fix(log-serializer): do not add receive time to latencies.kong #12795

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions changelog/unreleased/kong/log-serializer-kong-latency.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
message: |
The value of `latencies.kong` in the log serializer payload no longer includes
the response receive time, so it now has the same value as the
`X-Kong-Proxy-Latency` response header. Response receive time is recorded in
the new `latencies.receive` metric, so if desired, the old value can be
calculated as `latencies.kong + latencies.receive`. **Note:** this also
affects payloads from all logging plugins that use the log serializer:
`file-log`, `tcp-log`, `udp-log`,`http-log`, `syslog`, and `loggly`.
type: bugfix
scope: PDK
3 changes: 1 addition & 2 deletions kong/pdk/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,7 @@ do
size = to_decimal(var.bytes_sent),
},
latencies = {
kong = (ctx.KONG_PROXY_LATENCY or ctx.KONG_RESPONSE_LATENCY or 0) +
(ctx.KONG_RECEIVE_TIME or 0),
kong = ctx.KONG_PROXY_LATENCY or ctx.KONG_RESPONSE_LATENCY or 0,
proxy = ctx.KONG_WAITING_TIME or -1,
request = tonumber(var.request_time) * 1000,
receive = ctx.KONG_RECEIVE_TIME or 0,
Expand Down
6 changes: 4 additions & 2 deletions spec/01-unit/10-log_serializer_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ describe("kong.log.serialize", function()
},
},
KONG_PROXIED = true,
KONG_RECEIVE_TIME = 100,
KONG_PROXY_LATENCY = 200,
},
var = {
kong_request_id = "1234",
Expand Down Expand Up @@ -73,10 +75,10 @@ describe("kong.log.serialize", function()

-- Latencies
assert.is_table(res.latencies)
assert.equal(0, res.latencies.kong)
assert.equal(200, res.latencies.kong)
assert.equal(-1, res.latencies.proxy)
assert.equal(2000, res.latencies.request)
assert.equal(0, res.latencies.receive)
assert.equal(100, res.latencies.receive)

-- Request
assert.is_table(res.request)
Expand Down
Loading