提交 1167d918 编写于 作者: A ascrutae

fix(Trace-Segment): fix the trace segment id is dulplicate

fix #67
上级 01d669ab
......@@ -20,6 +20,7 @@ module.exports = ID;
const AgentConfig = require("../config");
const process = require("process");
const randomize = require("randomatic");
/**
* @param {idParts} idParts
......@@ -33,10 +34,9 @@ function ID(idParts) {
this._part3 = idParts.part3;
} else {
this._part1 = AgentConfig.getInstanceId();
this._part2 = process.pid *
process.ppid ? process.ppid : (((1 + Math.random()) * 0x10000) | 0)
+ (((1 + Math.random()) * 0x10000) | 0);
this._part3 = Number(process.hrtime().join(""));
this._part2 = (process.pid * process.ppid ? process.ppid : (((1 + Math.random()) * 0x10000) | 0)
+ (((1 + Math.random()) * 0x10000) | 0)) + Number(randomize("0", 5));
this._part3 = Number(process.hrtime().join("")) + Number(randomize("0", 9));
}
}
......
......@@ -41,11 +41,13 @@
"js-base64": "^2.5.1",
"object-hash": "^1.3.1",
"on-finished": "^2.3.0",
"randomatic": "^3.1.1",
"resolve": "^1.8.1",
"semver": "^5.5.1",
"uuid": "^3.2.1"
},
"devDependencies": {
"cz-conventional-changelog": "^2.1.0",
"eslint": "^4.19.1",
"eslint-config-google": "^0.9.1",
"eslint-plugin-header": "^1.2.0",
......@@ -58,5 +60,10 @@
"lib/network/common/*.js",
"lib/network/language-agent-v2/*.js",
"lib/network/register/*.js"
]
],
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册