-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from bravesirrobin81/master
Use uuid from header if present
- Loading branch information
Showing
2 changed files
with
21 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |