From 7cffaabe6a6d108035e2139be35d34c04f0db36a Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Wed, 13 Mar 2024 15:13:20 -0700 Subject: [PATCH] feat(log-serializer): add `latencies.receive` property to log-serializer --- changelog/unreleased/kong/log-serializer-receive-latency.yml | 3 +++ kong/pdk/log.lua | 1 + spec/01-unit/10-log_serializer_spec.lua | 1 + 3 files changed, 5 insertions(+) create mode 100644 changelog/unreleased/kong/log-serializer-receive-latency.yml diff --git a/changelog/unreleased/kong/log-serializer-receive-latency.yml b/changelog/unreleased/kong/log-serializer-receive-latency.yml new file mode 100644 index 00000000000..3eb522d7b6c --- /dev/null +++ b/changelog/unreleased/kong/log-serializer-receive-latency.yml @@ -0,0 +1,3 @@ +message: 'Add `latencies.receive` property to log serializer' +type: feature +scope: Core diff --git a/kong/pdk/log.lua b/kong/pdk/log.lua index 7fbaf168f7c..a4c0d077d21 100644 --- a/kong/pdk/log.lua +++ b/kong/pdk/log.lua @@ -845,6 +845,7 @@ do (ctx.KONG_RECEIVE_TIME or 0), proxy = ctx.KONG_WAITING_TIME or -1, request = tonumber(var.request_time) * 1000, + receive = ctx.KONG_RECEIVE_TIME or 0, }, tries = (ctx.balancer_data or {}).tries, authenticated_entity = build_authenticated_entity(ctx), diff --git a/spec/01-unit/10-log_serializer_spec.lua b/spec/01-unit/10-log_serializer_spec.lua index daa4489d9fb..7c2d45dbfeb 100644 --- a/spec/01-unit/10-log_serializer_spec.lua +++ b/spec/01-unit/10-log_serializer_spec.lua @@ -76,6 +76,7 @@ describe("kong.log.serialize", function() assert.equal(0, res.latencies.kong) assert.equal(-1, res.latencies.proxy) assert.equal(2000, res.latencies.request) + assert.equal(0, res.latencies.receive) -- Request assert.is_table(res.request)