@opentelemetry/id-generator-aws-xray
Advanced tools
Comparing version 0.22.0 to 0.23.0
@@ -17,9 +17,9 @@ /* | ||
import { INVALID_SPANID } from '@opentelemetry/api'; | ||
export const TRACE_ID_BYTES = 16; | ||
const SPAN_ID_BYTES = 8; | ||
const EPOCH_BYTES = 4; | ||
const FALLBACK_SPANID = '0000000000000001'; | ||
export var TRACE_ID_BYTES = 16; | ||
var SPAN_ID_BYTES = 8; | ||
var EPOCH_BYTES = 4; | ||
var FALLBACK_SPANID = '0000000000000001'; | ||
export function generateTraceId(generateRandomBytes) { | ||
const epoch = Math.floor(Date.now() / 1000).toString(16); | ||
const rand = generateRandomBytes(TRACE_ID_BYTES - EPOCH_BYTES); | ||
var epoch = Math.floor(Date.now() / 1000).toString(16); | ||
var rand = generateRandomBytes(TRACE_ID_BYTES - EPOCH_BYTES); | ||
// Starts with epoch so guaranteed to be valid. | ||
@@ -29,3 +29,3 @@ return epoch + rand; | ||
export function generateSpanId(generateRandomBytes) { | ||
const spanId = generateRandomBytes(SPAN_ID_BYTES); | ||
var spanId = generateRandomBytes(SPAN_ID_BYTES); | ||
if (spanId === INVALID_SPANID) { | ||
@@ -32,0 +32,0 @@ // Random was all zero. Very low chance, but in case it happens return a non-0 span ID to ensure it is valid. |
@@ -21,3 +21,5 @@ /* | ||
*/ | ||
export class AWSXRayIdGenerator { | ||
var AWSXRayIdGenerator = /** @class */ (function () { | ||
function AWSXRayIdGenerator() { | ||
} | ||
/** | ||
@@ -28,5 +30,5 @@ * Returns a random 16-byte trace ID formatted/encoded as a 32 lowercase hex | ||
*/ | ||
generateTraceId() { | ||
AWSXRayIdGenerator.prototype.generateTraceId = function () { | ||
return generateTraceId(generateRandomBytes); | ||
} | ||
}; | ||
/** | ||
@@ -36,9 +38,11 @@ * Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex | ||
*/ | ||
generateSpanId() { | ||
AWSXRayIdGenerator.prototype.generateSpanId = function () { | ||
return generateSpanId(generateRandomBytes); | ||
} | ||
} | ||
const SHARED_CHAR_CODES_ARRAY = Array(TRACE_ID_BYTES * 2); | ||
}; | ||
return AWSXRayIdGenerator; | ||
}()); | ||
export { AWSXRayIdGenerator }; | ||
var SHARED_CHAR_CODES_ARRAY = Array(TRACE_ID_BYTES * 2); | ||
function generateRandomBytes(bytes) { | ||
for (let i = 0; i < bytes * 2; i++) { | ||
for (var i = 0; i < bytes * 2; i++) { | ||
SHARED_CHAR_CODES_ARRAY[i] = Math.floor(Math.random() * 16) + 48; | ||
@@ -45,0 +49,0 @@ // valid hex characters in the range 48-57 and 97-102 |
@@ -21,3 +21,5 @@ /* | ||
*/ | ||
export class AWSXRayIdGenerator { | ||
var AWSXRayIdGenerator = /** @class */ (function () { | ||
function AWSXRayIdGenerator() { | ||
} | ||
/** | ||
@@ -28,5 +30,5 @@ * Returns a random 16-byte trace ID formatted/encoded as a 32 lowercase hex | ||
*/ | ||
generateTraceId() { | ||
AWSXRayIdGenerator.prototype.generateTraceId = function () { | ||
return generateTraceId(generateRandomBytes); | ||
} | ||
}; | ||
/** | ||
@@ -36,12 +38,14 @@ * Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex | ||
*/ | ||
generateSpanId() { | ||
AWSXRayIdGenerator.prototype.generateSpanId = function () { | ||
return generateSpanId(generateRandomBytes); | ||
} | ||
} | ||
const SHARED_BUFFER = Buffer.allocUnsafe(TRACE_ID_BYTES); | ||
}; | ||
return AWSXRayIdGenerator; | ||
}()); | ||
export { AWSXRayIdGenerator }; | ||
var SHARED_BUFFER = Buffer.allocUnsafe(TRACE_ID_BYTES); | ||
function generateRandomBytes(bytes) { | ||
for (let i = 0; i < bytes / 4; i++) { | ||
for (var i = 0; i < bytes / 4; i++) { | ||
// unsigned right shift drops decimal part of the number | ||
// it is required because if a number between 2**32 and 2**32 - 1 is generated, an out of range error is thrown by writeUInt32BE | ||
SHARED_BUFFER.writeUInt32BE((Math.random() * 2 ** 32) >>> 0, i * 4); | ||
SHARED_BUFFER.writeUInt32BE((Math.random() * Math.pow(2, 32)) >>> 0, i * 4); | ||
} | ||
@@ -48,0 +52,0 @@ return SHARED_BUFFER.toString('hex', 0, bytes); |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.22.0"; | ||
export declare const VERSION = "0.23.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -17,3 +17,3 @@ /* | ||
// this is autogenerated file, see scripts/version-update.js | ||
export const VERSION = '0.22.0'; | ||
export var VERSION = '0.23.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.22.0"; | ||
export declare const VERSION = "0.23.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.22.0'; | ||
exports.VERSION = '0.23.0'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/id-generator-aws-xray", | ||
"version": "0.22.0", | ||
"version": "0.23.0", | ||
"description": "AWS X-Ray ID generator for OpenTelemetry", | ||
@@ -55,10 +55,10 @@ "main": "build/src/index.js", | ||
"peerDependencies": { | ||
"@opentelemetry/api": "^1.0.0" | ||
"@opentelemetry/api": "^1.0.1" | ||
}, | ||
"devDependencies": { | ||
"@opentelemetry/api": "1.0.0", | ||
"@opentelemetry/api": "1.0.1", | ||
"@types/mocha": "8.2.2", | ||
"@types/node": "14.17.3", | ||
"@types/node": "14.17.4", | ||
"@types/sinon": "10.0.2", | ||
"@types/webpack-env": "1.16.0", | ||
"@types/webpack-env": "1.16.1", | ||
"codecov": "3.8.2", | ||
@@ -79,9 +79,9 @@ "gts": "3.1.0", | ||
"ts-mocha": "8.0.0", | ||
"typescript": "4.3.2", | ||
"typescript": "4.3.5", | ||
"webpack": "4.46.0" | ||
}, | ||
"dependencies": { | ||
"@opentelemetry/core": "^0.22.0" | ||
"@opentelemetry/core": "^0.23.0" | ||
}, | ||
"gitHead": "a52deeca96cdd7e8b75734094ed84de075e9517d" | ||
"gitHead": "eea5f3ef0382c3c8f6d5aca796e3babf7ad4a6c8" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
49318
582
+ Added@opentelemetry/core@0.23.0(transitive)
+ Added@opentelemetry/semantic-conventions@0.23.0(transitive)
- Removed@opentelemetry/core@0.22.0(transitive)
- Removed@opentelemetry/semantic-conventions@0.22.0(transitive)
Updated@opentelemetry/core@^0.23.0