@arms/rum-core
Advanced tools
Comparing version 0.0.25-beta.9 to 0.0.25-beta.11
@@ -153,2 +153,3 @@ export declare enum RumEventType { | ||
events: Array<RumEvent>; | ||
_v: string; | ||
} |
@@ -11,8 +11,21 @@ /** | ||
/** | ||
* @description: 唯一的字符串 universe unique id | ||
* @param len {String} | ||
* @description: 随机生成 traceId 或 sessionId | ||
* @return {String} | ||
*/ | ||
export declare function generateUUID(len?: number): string; | ||
export declare function generateTraceId(): string; | ||
/** | ||
* @description: 随机生成 spanId | ||
* @param len {number} | ||
* @return {String} | ||
*/ | ||
export declare function generateSpanId(len?: number): string; | ||
/** | ||
* @description: 随机生成 eventId | ||
* @param sessionId {string} sessionId | ||
* @param sampled {boolean} 是否命中采样 | ||
* @param samplingType {string} 采样类型 | ||
* @return {String} | ||
*/ | ||
export declare function generateEventId(sessionId: string, sampled?: boolean, samplingType?: string): string; | ||
/** | ||
* @desc 函数防抖 | ||
@@ -19,0 +32,0 @@ * @param func 回调函数 |
@@ -6,4 +6,6 @@ "use strict"; | ||
exports.delay = delay; | ||
exports.generateEventId = generateEventId; | ||
exports.generateGUID = generateGUID; | ||
exports.generateUUID = generateUUID; | ||
exports.generateSpanId = generateSpanId; | ||
exports.generateTraceId = generateTraceId; | ||
exports.interceptFunction = interceptFunction; | ||
@@ -49,22 +51,53 @@ var _is = require("./is"); | ||
/** | ||
* @description: 唯一的字符串 universe unique id | ||
* @param len {String} | ||
* @description: 随机生成 traceId 或 sessionId | ||
* @return {String} | ||
*/ | ||
function generateUUID(len) { | ||
function generateTraceId() { | ||
var traceId = generateGUID().replace(/-/g, ''); | ||
// 适配OpenTracing 实现(long long转成16进制最高位不能为0) | ||
if (traceId[0] === '0') { | ||
traceId = '1' + traceId.substring(1); | ||
} | ||
if (traceId[16] === '0') { | ||
traceId = traceId.substring(0, 16) + '1' + traceId.substring(17); | ||
} | ||
return traceId; | ||
} | ||
/** | ||
* @description: 随机生成 spanId | ||
* @param len {number} | ||
* @return {String} | ||
*/ | ||
function generateSpanId(len) { | ||
if (len === void 0) { | ||
len = 8; | ||
len = 16; | ||
} | ||
var str = new Array(len); | ||
var d = Date.now().toString(36).split(''); | ||
var r, c; | ||
while (len-- > 0) { | ||
r = Math.random() * 36 | 0; | ||
c = r.toString(36); | ||
str[len] = r % 3 ? c : c.toUpperCase(); | ||
var list = Array(len); | ||
for (var i = 0; i < len; i++) { | ||
list[i] = Math.floor(Math.random() * 16) + 48; | ||
// valid hex characters in the range 48-57 and 97-102 | ||
if (list[i] >= 58) { | ||
list[i] += 39; | ||
} | ||
} | ||
for (var i = 0; i < 8; i++) { | ||
str.splice(i * 3 + 2, 0, d[i]); | ||
return String.fromCharCode.apply(null, list); | ||
} | ||
/** | ||
* @description: 随机生成 eventId | ||
* @param sessionId {string} sessionId | ||
* @param sampled {boolean} 是否命中采样 | ||
* @param samplingType {string} 采样类型 | ||
* @return {String} | ||
*/ | ||
function generateEventId(sessionId, sampled, samplingType) { | ||
if (sampled === void 0) { | ||
sampled = true; | ||
} | ||
return str.join(''); | ||
if (samplingType === void 0) { | ||
samplingType = '0'; | ||
} | ||
var spanId = generateSpanId(); | ||
return "00-" + sessionId + "-" + spanId + "-" + samplingType + (sampled ? '1' : '0'); | ||
} | ||
@@ -71,0 +104,0 @@ |
@@ -16,4 +16,2 @@ import { MatchOption } from "./match"; | ||
} | ||
export declare function generateTraceId(): string; | ||
export declare function generateSpanId(): any; | ||
export interface ITracingHeaders { | ||
@@ -20,0 +18,0 @@ [key: string]: string; |
"use strict"; | ||
exports.__esModule = true; | ||
exports.generateSpanId = generateSpanId; | ||
exports.generateTraceId = generateTraceId; | ||
exports.isTraceOption = isTraceOption; | ||
@@ -11,3 +9,2 @@ exports.makeTracingHeaders = makeTracingHeaders; | ||
var _is = require("./is"); | ||
var _base = require("./base"); | ||
var _jsBase = require("js-base64"); | ||
@@ -17,24 +14,2 @@ function isTraceOption(option) { | ||
} | ||
function generateTraceId() { | ||
var traceId = (0, _base.generateGUID)().replace(/-/g, ''); | ||
// 适配OpenTracing 实现(long long转成16进制最高位不能为0) | ||
if (traceId[0] === '0') { | ||
traceId = '1' + traceId.substring(1); | ||
} | ||
if (traceId[16] === '0') { | ||
traceId = traceId.substring(0, 16) + '1' + traceId.substring(17); | ||
} | ||
return traceId; | ||
} | ||
function generateSpanId() { | ||
var list = Array(16); | ||
for (var i = 0; i < 16; i++) { | ||
list[i] = Math.floor(Math.random() * 16) + 48; | ||
// valid hex characters in the range 48-57 and 97-102 | ||
if (list[i] >= 58) { | ||
list[i] += 39; | ||
} | ||
} | ||
return String.fromCharCode.apply(null, list); | ||
} | ||
function makeTracingHeaders(traceId, spanId, sampled, propagatorTypes, subOption) { | ||
@@ -41,0 +16,0 @@ if (subOption === void 0) { |
{ | ||
"name": "@arms/rum-core", | ||
"version": "0.0.25-beta.9", | ||
"version": "0.0.25-beta.11", | ||
"description": "arms rum javascript sdk core", | ||
@@ -5,0 +5,0 @@ "author": "guangli.fj <guangli.fj@alibaba-inc.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45588
1389