Skip to content

Commit

Permalink
[#263] get model_endpoint from headers instead of args
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelbotsman committed Dec 29, 2018
1 parent a9c802f commit 13e1992
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 6 additions & 4 deletions k8s/edge/edge.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ function _M.response_feedback(data)
ngx.say(json_encoded_response);
end

function _M.catch_model_api_response_chunk(model_id, model_version, model_endpoint, content, eof)
local http_request_headers = ngx.req.get_headers()
local requestID = http_request_headers["Request-ID"]
function _M.catch_model_api_response_chunk(model_id, model_version, content, eof)
local request_http_headers = ngx.req.get_headers()
local requestID = request_http_headers["Request-ID"]
local model_endpoint = request_http_headers["Model-Endpoint"]

if eof and string.len(content) == 0 then
return nil
Expand All @@ -114,9 +115,10 @@ function _M.catch_model_api_response_chunk(model_id, model_version, model_endpoi
return data
end

function _M.catch_model_api_call(model_id, model_version, model_endpoint)
function _M.catch_model_api_call(model_id, model_version)
local request_http_headers = ngx.req.get_headers()
local request_id = request_http_headers["Request-ID"]
local model_endpoint = request_http_headers["Model-Endpoint"]
local http_method = ngx.req.get_method()
request_http_headers["authorization"] = nil

Expand Down
5 changes: 4 additions & 1 deletion k8s/edge/statistics_sender.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ function _M.push_data(_, time, name, endpoint)
end
end

function _M.send_request_statistics(name, endpoint, latency)
function _M.send_request_statistics(name, latency)
local request_http_headers = ngx.req.get_headers()
local endpoint = request_http_headers["Model-Endpoint"]

local ok, err = ngx.timer.at(0, _M.push_data, latency, name, endpoint)
if not ok then
ngx.log(ngx.ERR, "Failed to create Statsd reporting timer: ", err)
Expand Down

0 comments on commit 13e1992

Please sign in to comment.