Skip to content
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
7 changes: 7 additions & 0 deletions src/ngx_http_lua_kong_var_index.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ static ngx_str_t default_vars[] = {
ngx_string("upstream_http_upgrade"),
ngx_string("upstream_status"),

/* detailed upstream timing vars */
ngx_string("upstream_start_timestamp_us"),
ngx_string("upstream_connect_timestamp_us"),
ngx_string("upstream_request_timestamp_us"),
ngx_string("upstream_header_timestamp_us"),
ngx_string("upstream_response_timestamp_us"),

/* lua-kong-module vars */
ngx_string("kong_request_id"),

Expand Down
35 changes: 34 additions & 1 deletion t/006-default_indexed-var.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use Test::Nginx::Socket::Lua;

repeat_each(2);

plan tests => repeat_each() * (blocks() * 8) + 10;
plan tests => repeat_each() * (blocks() * 8) + 14;

#no_diff();
#no_long_string();
Expand Down Expand Up @@ -444,3 +444,36 @@ get variable value 'false' by index
[error]
[crit]
[alert]

=== TEST 14: upstream timing variables
--- http_config
lua_package_path "../lua-resty-core/lib/?.lua;lualib/?.lua;;";
lua_kong_load_var_index default;
init_by_lua_block {
require("resty.kong.var").patch_metatable()
}

--- config
location = /test {
content_by_lua_block {
ngx.say(ngx.var.upstream_start_timestamp_us, " ",
ngx.var.upstream_connect_timestamp_us, " ",
ngx.var.upstream_request_timestamp_us, " ",
ngx.var.upstream_header_timestamp_us, " ",
ngx.var.upstream_response_timestamp_us)
}
}
--- request
GET /test
--- response_body
nil nil nil nil nil
--- error_log
variable value is not found by index
variable value is not found by index
variable value is not found by index
variable value is not found by index
variable value is not found by index
--- no_error_log
[error]
[crit]
[alert]
Loading