diff --git a/k8s/edge/nginx.conf.ltmpl b/k8s/edge/nginx.conf.ltmpl index 09e69f565..c4c6a07f8 100644 --- a/k8s/edge/nginx.conf.ltmpl +++ b/k8s/edge/nginx.conf.ltmpl @@ -124,9 +124,7 @@ http { -- arg[2] is true if this is the last chunk local edge = require("edge") - local endpoint_header = ngx.header["Model-Endpoint"] - local chunkInfo = edge.catch_model_api_response_chunk("{{ model_endpoint.model_service.id }}", "{{ model_endpoint.model_service.version }}", - endpoint_header, ngx.arg[1], ngx.arg[2]) + local chunkInfo = edge.catch_model_api_response_chunk("{{ model_endpoint.model_service.id }}", "{{ model_endpoint.model_service.version }}", ngx.arg[1], ngx.arg[2]) if chunkInfo then local fluentd_logger = require "fluentd_logger" @@ -155,6 +153,14 @@ http { ngx.log(ngx.INFO, "Request ID has been generated: "..requestID) end + -- Model-Endpoint generation if it is missing + local model_endpoint = ngx.req.get_headers()["Model-Endpoint"] + if not model_endpoint then + model_endpoint = "default" + ngx.req.set_header("Model-Endpoint", model_endpoint) + ngx.log(ngx.INFO, "Model Endpoint has been set to "..model_endpoint) + end + ngx.header["Request-ID"] = requestID } @@ -172,12 +178,11 @@ http { -- HTTP requests timing metrics for statsd local statistics_sender = require "statistics_sender" local latency = math.floor((ngx.now() - ngx.req.start_time()) * 1000) - statistics_sender.send_request_statistics("{{ model_endpoint.model_service.metrics_name }}", endpoint_header, latency) + statistics_sender.send_request_statistics("{{ model_endpoint.model_service.metrics_name }}", latency) -- Request info gathering local edge = require("edge") - local requestInfo = edge.catch_model_api_call("{{ model_endpoint.model_service.id }}", "{{ model_endpoint.model_service.version }}", - endpoint_header) + local requestInfo = edge.catch_model_api_call("{{ model_endpoint.model_service.id }}", "{{ model_endpoint.model_service.version }}") local fluentd_logger = require "fluentd_logger" fluentd_logger.post(ngx.req.start_time(), "request_response", requestInfo)