metrics - fix request timestamp

This commit is contained in:
fl0ppy-d1sk 2024-02-01 10:48:06 +01:00
parent 503868b5d6
commit a7a9055b8c
No known key found for this signature in database
GPG key ID: 93EE47CC3D061500
2 changed files with 4 additions and 2 deletions

View file

@ -185,7 +185,7 @@ helpers.fill_ctx = function(no_ref)
end
data.remote_addr = var.remote_addr
data.server_name = var.server_name
data.local_time = var.local_time
data.time_local = var.time_local
if data.kind == "http" then
data.uri = var.uri
data.request_uri = var.request_uri
@ -196,6 +196,7 @@ helpers.fill_ctx = function(no_ref)
data.http_content_length = var.http_content_length
data.http_origin = var.http_origin
data.http_version = req.http_version()
data.start_time = req.start_time()
data.scheme = var.scheme
end
-- IP data : global

View file

@ -19,6 +19,7 @@ local encode = cjson.encode
local decode = cjson.decode
local match = string.match
local time = os.time
function metrics:initialize(ctx)
-- Call parent initialize
@ -50,7 +51,7 @@ function metrics:log()
end
end
local request = {
date = os.time(),
date = self.ctx.bw.start_time or time(),
ip = self.ctx.bw.remote_addr,
country = country,
method = self.ctx.bw.request_method,