From ce038cca2cee20e2691f96873633a657fbdf1844 Mon Sep 17 00:00:00 2001 From: chronolaw Date: Sun, 10 Sep 2023 18:15:09 +0800 Subject: [PATCH] init.lua --- kong/init.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/kong/init.lua b/kong/init.lua index ecc2004a94dd..5a0eedfce23a 100644 --- a/kong/init.lua +++ b/kong/init.lua @@ -110,7 +110,6 @@ local ngx_INFO = ngx.INFO local ngx_DEBUG = ngx.DEBUG local is_http_module = ngx.config.subsystem == "http" local is_stream_module = ngx.config.subsystem == "stream" -local start_time = ngx.req.start_time local worker_id = ngx.worker.id local type = type local error = error @@ -125,8 +124,11 @@ local set_current_peer = ngx_balancer.set_current_peer local set_timeouts = ngx_balancer.set_timeouts local set_more_tries = ngx_balancer.set_more_tries local enable_keepalive = ngx_balancer.enable_keepalive -local time_ns = utils.time_ns -local get_now_ms = utils.get_now_ms + + +local time_ns = utils.time_ns +local get_now_ms = utils.get_now_ms +local get_start_time_ms = utils.get_start_time_ms local get_updated_now_ms = utils.get_updated_now_ms @@ -906,7 +908,7 @@ end function Kong.preread() local ctx = get_ctx_table(fetch_table(CTX_NS, CTX_NARR, CTX_NREC)) if not ctx.KONG_PROCESSING_START then - ctx.KONG_PROCESSING_START = start_time() * 1000 + ctx.KONG_PROCESSING_START = get_start_time_ms() end if not ctx.KONG_PREREAD_START then @@ -979,7 +981,7 @@ function Kong.rewrite() end if not ctx.KONG_PROCESSING_START then - ctx.KONG_PROCESSING_START = start_time() * 1000 + ctx.KONG_PROCESSING_START = get_start_time_ms() end if not ctx.KONG_REWRITE_START then @@ -1354,7 +1356,7 @@ end function Kong.header_filter() local ctx = ngx.ctx if not ctx.KONG_PROCESSING_START then - ctx.KONG_PROCESSING_START = start_time() * 1000 + ctx.KONG_PROCESSING_START = get_start_time_ms() end if not ctx.workspace then @@ -1507,7 +1509,7 @@ function Kong.log() ctx.KONG_LOG_START_NS = time_ns() if is_stream_module then if not ctx.KONG_PROCESSING_START then - ctx.KONG_PROCESSING_START = start_time() * 1000 + ctx.KONG_PROCESSING_START = get_start_time_ms() end if ctx.KONG_PREREAD_START and not ctx.KONG_PREREAD_ENDED_AT then @@ -1616,7 +1618,7 @@ end local function serve_content(module) local ctx = ngx.ctx - ctx.KONG_PROCESSING_START = start_time() * 1000 + ctx.KONG_PROCESSING_START = get_start_time_ms() ctx.KONG_ADMIN_CONTENT_START = ctx.KONG_ADMIN_CONTENT_START or get_now_ms() ctx.KONG_PHASE = PHASES.admin_api @@ -1648,7 +1650,7 @@ function Kong.admin_header_filter() local ctx = ngx.ctx if not ctx.KONG_PROCESSING_START then - ctx.KONG_PROCESSING_START = start_time() * 1000 + ctx.KONG_PROCESSING_START = get_start_time_ms() end if not ctx.KONG_ADMIN_HEADER_FILTER_START then