Skip to content

Commit bd629dc

Browse files
authored
Merge pull request #125 from bravesirrobin81/master
Use uuid from header if present
2 parents e13302d + 281cbcf commit bd629dc

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

ci-build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,17 @@ echo "Testing no logging of url params option works..."
515515
docker logs "${MOCKSERVER}" | grep 'Nginxid:'
516516
docker logs ${INSTANCE} | grep '"nginx_uuid": "'
517517

518+
start_test "Test UUID header logging option passes through supplied value..." "${STD_CMD} \
519+
-e \"PROXY_SERVICE_HOST=http://${MOCKSERVER}\" \
520+
-e \"PROXY_SERVICE_PORT=${MOCKSERVER_PORT}\" \
521+
-e \"DNSMASK=TRUE\" \
522+
-e \"ENABLE_UUID_PARAM=HEADER\" \
523+
--link \"${MOCKSERVER}:${MOCKSERVER}\" "
524+
curl -sk -H "nginxId: 00000000-1111-2222-3333-444455556666" https://${DOCKER_HOST_NAME}:${PORT}
525+
echo "Testing no logging of url params option works..."
526+
docker logs "${MOCKSERVER}" | grep 'Nginxid:00000000-1111-2222-3333-444455556666'
527+
docker logs ${INSTANCE} | grep '"nginx_uuid": "00000000-1111-2222-3333-444455556666"'
528+
518529
start_test "Test VERBOSE_ERROR_PAGES=TRUE displays debug info" "${STD_CMD} \
519530
-e \"PROXY_SERVICE_HOST=http://${MOCKSERVER}\" \
520531
-e \"PROXY_SERVICE_PORT=${MOCKSERVER_PORT}\" \

lua/set_uuid.lua

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
if os.getenv("LOG_UUID") == "FALSE" then
22
return ""
33
else
4-
local socket = require("socket")
5-
local uuid = require("uuid")
6-
uuid.randomseed(socket.gettime()*10000)
7-
local uuid_str = uuid()
4+
local uuid_str = ""
5+
if ngx.req.get_headers()["nginxId"] == nil then
6+
local socket = require("socket")
7+
local uuid = require("uuid")
8+
uuid.randomseed(socket.gettime()*10000)
9+
uuid_str = uuid()
10+
else
11+
uuid_str = ngx.req.get_headers()["nginxId"]
12+
end
813
ngx.var.uuid = uuid_str
914
ngx.var.uuid_log_opt = " nginxId=" .. uuid_str
1015
return uuid_str
11-
end
16+
end

0 commit comments

Comments
 (0)