Skip to content

Commit

Permalink
Merge pull request #125 from bravesirrobin81/master
Browse files Browse the repository at this point in the history
Use uuid from header if present
  • Loading branch information
jaykeshur authored May 10, 2019
2 parents e13302d + 281cbcf commit bd629dc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
11 changes: 11 additions & 0 deletions ci-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,17 @@ echo "Testing no logging of url params option works..."
docker logs "${MOCKSERVER}" | grep 'Nginxid:'
docker logs ${INSTANCE} | grep '"nginx_uuid": "'

start_test "Test UUID header logging option passes through supplied value..." "${STD_CMD} \
-e \"PROXY_SERVICE_HOST=http://${MOCKSERVER}\" \
-e \"PROXY_SERVICE_PORT=${MOCKSERVER_PORT}\" \
-e \"DNSMASK=TRUE\" \
-e \"ENABLE_UUID_PARAM=HEADER\" \
--link \"${MOCKSERVER}:${MOCKSERVER}\" "
curl -sk -H "nginxId: 00000000-1111-2222-3333-444455556666" https://${DOCKER_HOST_NAME}:${PORT}
echo "Testing no logging of url params option works..."
docker logs "${MOCKSERVER}" | grep 'Nginxid:00000000-1111-2222-3333-444455556666'
docker logs ${INSTANCE} | grep '"nginx_uuid": "00000000-1111-2222-3333-444455556666"'

start_test "Test VERBOSE_ERROR_PAGES=TRUE displays debug info" "${STD_CMD} \
-e \"PROXY_SERVICE_HOST=http://${MOCKSERVER}\" \
-e \"PROXY_SERVICE_PORT=${MOCKSERVER_PORT}\" \
Expand Down
15 changes: 10 additions & 5 deletions lua/set_uuid.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
if os.getenv("LOG_UUID") == "FALSE" then
return ""
else
local socket = require("socket")
local uuid = require("uuid")
uuid.randomseed(socket.gettime()*10000)
local uuid_str = uuid()
local uuid_str = ""
if ngx.req.get_headers()["nginxId"] == nil then
local socket = require("socket")
local uuid = require("uuid")
uuid.randomseed(socket.gettime()*10000)
uuid_str = uuid()
else
uuid_str = ngx.req.get_headers()["nginxId"]
end
ngx.var.uuid = uuid_str
ngx.var.uuid_log_opt = " nginxId=" .. uuid_str
return uuid_str
end
end

0 comments on commit bd629dc

Please sign in to comment.