You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/04/07 09:14:08 UTC
[GitHub] [skywalking-nginx-lua] mrproliu commented on a change in pull
request #30: Adapt the new v3 protocol
mrproliu commented on a change in pull request #30: Adapt the new v3 protocol
URL: https://github.com/apache/skywalking-nginx-lua/pull/30#discussion_r404658856
##########
File path: lib/skywalking/util.lua
##########
@@ -80,30 +80,21 @@ local random_seed = function ()
return seed
end
-math.randomseed(random_seed())
-
-function _M.newID()
- return {timestamp(), math.random(0, MAX_ID_PART2), math.random(0, MAX_ID_PART3)}
+local newID = function()
+ return timestamp() .. '.' .. math.random(0, MAX_ID_PART2) .. '.' .. math.random(0, MAX_ID_PART3)
end
--- Format a trace/segment id into an array.
--- An official ID should have three parts separated by '.' and each part of it is a number
-function _M.formatID(str)
- local regex = '.'
- if _M.is_ngx_lua then
- regex = [[\.]]
- end
- local parts = split(str, regex)
- if #parts ~= 3 then
- return nil
- end
+math.randomseed(random_seed())
- return parts
+-- for Nginx Lua
+local ok, uuid = pcall(require, "dependencies/lua-resty-jit-uuid")
+if ok then
+ uuid.seed()
+ newID = function()
+ return uuid.generate_v4()
+ end
Review comment:
When the unit test, or the nginx not running on the LuaJIT environment.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services