You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@opentelemetry/sdk-trace-base

Package Overview
Dependencies
Maintainers
2
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/sdk-trace-base - npm Package Compare versions

Comparing version
2.5.0
to
2.5.1
+2
-2
build/esm/platform/browser/RandomIdGenerator.d.ts

@@ -7,3 +7,3 @@ import { IdGenerator } from '../../IdGenerator';

*/
generateTraceId: () => string;
generateTraceId(): string;
/**

@@ -13,4 +13,4 @@ * Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex

*/
generateSpanId: () => string;
generateSpanId(): string;
}
//# sourceMappingURL=RandomIdGenerator.d.ts.map

@@ -16,4 +16,30 @@ /*

*/
const TRACE_ID_BYTES = 16;
const SPAN_ID_BYTES = 8;
const TRACE_ID_BYTES = 16;
const TRACE_BUFFER = new Uint8Array(TRACE_ID_BYTES);
const SPAN_BUFFER = new Uint8Array(SPAN_ID_BYTES);
// Byte-to-hex lookup is faster than toString(16) in browsers
const HEX = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
/**
* Fills buffer with random bytes, ensuring at least one is non-zero
* per W3C Trace Context spec.
*/
function randomFill(buf) {
for (let i = 0; i < buf.length; i++) {
buf[i] = (Math.random() * 256) >>> 0;
}
// Ensure non-zero
for (let i = 0; i < buf.length; i++) {
if (buf[i] > 0)
return;
}
buf[buf.length - 1] = 1;
}
function toHex(buf) {
let hex = '';
for (let i = 0; i < buf.length; i++) {
hex += HEX[buf[i]];
}
return hex;
}
export class RandomIdGenerator {

@@ -24,3 +50,6 @@ /**

*/
generateTraceId = getIdGenerator(TRACE_ID_BYTES);
generateTraceId() {
randomFill(TRACE_BUFFER);
return toHex(TRACE_BUFFER);
}
/**

@@ -30,17 +59,7 @@ * Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex

*/
generateSpanId = getIdGenerator(SPAN_ID_BYTES);
generateSpanId() {
randomFill(SPAN_BUFFER);
return toHex(SPAN_BUFFER);
}
}
const SHARED_CHAR_CODES_ARRAY = Array(32);
function getIdGenerator(bytes) {
return function generateId() {
for (let i = 0; i < bytes * 2; i++) {
SHARED_CHAR_CODES_ARRAY[i] = Math.floor(Math.random() * 16) + 48;
// valid hex characters in the range 48-57 and 97-102
if (SHARED_CHAR_CODES_ARRAY[i] >= 58) {
SHARED_CHAR_CODES_ARRAY[i] += 39;
}
}
return String.fromCharCode.apply(null, SHARED_CHAR_CODES_ARRAY.slice(0, bytes * 2));
};
}
//# sourceMappingURL=RandomIdGenerator.js.map

@@ -43,2 +43,3 @@ import { Context, Exception, HrTime, Link, Span as APISpan, Attributes, AttributeValue, SpanContext, SpanKind, SpanStatus, TimeInput } from '@opentelemetry/api';

private _droppedLinksCount;
private _attributesCount;
name: string;

@@ -45,0 +46,0 @@ status: SpanStatus;

@@ -38,2 +38,3 @@ /*

_droppedLinksCount = 0;
_attributesCount = 0;
name;

@@ -93,5 +94,6 @@ status = {

const { attributeCountLimit } = this._spanLimits;
const isNewKey = !Object.prototype.hasOwnProperty.call(this.attributes, key);
if (attributeCountLimit !== undefined &&
Object.keys(this.attributes).length >= attributeCountLimit &&
!Object.prototype.hasOwnProperty.call(this.attributes, key)) {
this._attributesCount >= attributeCountLimit &&
isNewKey) {
this._droppedAttributesCount++;

@@ -101,2 +103,5 @@ return this;

this.attributes[key] = this._truncateToSize(value);
if (isNewKey) {
this._attributesCount++;
}
return this;

@@ -103,0 +108,0 @@ }

@@ -1,2 +0,2 @@

export declare const VERSION = "2.5.0";
export declare const VERSION = "2.5.1";
//# sourceMappingURL=version.d.ts.map

@@ -17,3 +17,3 @@ /*

// this is autogenerated file, see scripts/version-update.js
export const VERSION = '2.5.0';
export const VERSION = '2.5.1';
//# sourceMappingURL=version.js.map

@@ -7,3 +7,3 @@ import { IdGenerator } from '../../IdGenerator';

*/
generateTraceId: () => string;
generateTraceId(): string;
/**

@@ -13,4 +13,4 @@ * Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex

*/
generateSpanId: () => string;
generateSpanId(): string;
}
//# sourceMappingURL=RandomIdGenerator.d.ts.map

@@ -16,4 +16,30 @@ /*

*/
const TRACE_ID_BYTES = 16;
const SPAN_ID_BYTES = 8;
const TRACE_ID_BYTES = 16;
const TRACE_BUFFER = new Uint8Array(TRACE_ID_BYTES);
const SPAN_BUFFER = new Uint8Array(SPAN_ID_BYTES);
// Byte-to-hex lookup is faster than toString(16) in browsers
const HEX = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
/**
* Fills buffer with random bytes, ensuring at least one is non-zero
* per W3C Trace Context spec.
*/
function randomFill(buf) {
for (let i = 0; i < buf.length; i++) {
buf[i] = (Math.random() * 256) >>> 0;
}
// Ensure non-zero
for (let i = 0; i < buf.length; i++) {
if (buf[i] > 0)
return;
}
buf[buf.length - 1] = 1;
}
function toHex(buf) {
let hex = '';
for (let i = 0; i < buf.length; i++) {
hex += HEX[buf[i]];
}
return hex;
}
export class RandomIdGenerator {

@@ -24,3 +50,6 @@ /**

*/
generateTraceId = getIdGenerator(TRACE_ID_BYTES);
generateTraceId() {
randomFill(TRACE_BUFFER);
return toHex(TRACE_BUFFER);
}
/**

@@ -30,17 +59,7 @@ * Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex

*/
generateSpanId = getIdGenerator(SPAN_ID_BYTES);
generateSpanId() {
randomFill(SPAN_BUFFER);
return toHex(SPAN_BUFFER);
}
}
const SHARED_CHAR_CODES_ARRAY = Array(32);
function getIdGenerator(bytes) {
return function generateId() {
for (let i = 0; i < bytes * 2; i++) {
SHARED_CHAR_CODES_ARRAY[i] = Math.floor(Math.random() * 16) + 48;
// valid hex characters in the range 48-57 and 97-102
if (SHARED_CHAR_CODES_ARRAY[i] >= 58) {
SHARED_CHAR_CODES_ARRAY[i] += 39;
}
}
return String.fromCharCode.apply(null, SHARED_CHAR_CODES_ARRAY.slice(0, bytes * 2));
};
}
//# sourceMappingURL=RandomIdGenerator.js.map

@@ -43,2 +43,3 @@ import { Context, Exception, HrTime, Link, Span as APISpan, Attributes, AttributeValue, SpanContext, SpanKind, SpanStatus, TimeInput } from '@opentelemetry/api';

private _droppedLinksCount;
private _attributesCount;
name: string;

@@ -45,0 +46,0 @@ status: SpanStatus;

@@ -38,2 +38,3 @@ /*

_droppedLinksCount = 0;
_attributesCount = 0;
name;

@@ -93,5 +94,6 @@ status = {

const { attributeCountLimit } = this._spanLimits;
const isNewKey = !Object.prototype.hasOwnProperty.call(this.attributes, key);
if (attributeCountLimit !== undefined &&
Object.keys(this.attributes).length >= attributeCountLimit &&
!Object.prototype.hasOwnProperty.call(this.attributes, key)) {
this._attributesCount >= attributeCountLimit &&
isNewKey) {
this._droppedAttributesCount++;

@@ -101,2 +103,5 @@ return this;

this.attributes[key] = this._truncateToSize(value);
if (isNewKey) {
this._attributesCount++;
}
return this;

@@ -103,0 +108,0 @@ }

@@ -1,2 +0,2 @@

export declare const VERSION = "2.5.0";
export declare const VERSION = "2.5.1";
//# sourceMappingURL=version.d.ts.map

@@ -17,3 +17,3 @@ /*

// this is autogenerated file, see scripts/version-update.js
export const VERSION = '2.5.0';
export const VERSION = '2.5.1';
//# sourceMappingURL=version.js.map

@@ -7,3 +7,3 @@ import { IdGenerator } from '../../IdGenerator';

*/
generateTraceId: () => string;
generateTraceId(): string;
/**

@@ -13,4 +13,4 @@ * Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex

*/
generateSpanId: () => string;
generateSpanId(): string;
}
//# sourceMappingURL=RandomIdGenerator.d.ts.map

@@ -19,4 +19,30 @@ "use strict";

exports.RandomIdGenerator = void 0;
const TRACE_ID_BYTES = 16;
const SPAN_ID_BYTES = 8;
const TRACE_ID_BYTES = 16;
const TRACE_BUFFER = new Uint8Array(TRACE_ID_BYTES);
const SPAN_BUFFER = new Uint8Array(SPAN_ID_BYTES);
// Byte-to-hex lookup is faster than toString(16) in browsers
const HEX = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
/**
* Fills buffer with random bytes, ensuring at least one is non-zero
* per W3C Trace Context spec.
*/
function randomFill(buf) {
for (let i = 0; i < buf.length; i++) {
buf[i] = (Math.random() * 256) >>> 0;
}
// Ensure non-zero
for (let i = 0; i < buf.length; i++) {
if (buf[i] > 0)
return;
}
buf[buf.length - 1] = 1;
}
function toHex(buf) {
let hex = '';
for (let i = 0; i < buf.length; i++) {
hex += HEX[buf[i]];
}
return hex;
}
class RandomIdGenerator {

@@ -27,3 +53,6 @@ /**

*/
generateTraceId = getIdGenerator(TRACE_ID_BYTES);
generateTraceId() {
randomFill(TRACE_BUFFER);
return toHex(TRACE_BUFFER);
}
/**

@@ -33,18 +62,8 @@ * Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex

*/
generateSpanId = getIdGenerator(SPAN_ID_BYTES);
generateSpanId() {
randomFill(SPAN_BUFFER);
return toHex(SPAN_BUFFER);
}
}
exports.RandomIdGenerator = RandomIdGenerator;
const SHARED_CHAR_CODES_ARRAY = Array(32);
function getIdGenerator(bytes) {
return function generateId() {
for (let i = 0; i < bytes * 2; i++) {
SHARED_CHAR_CODES_ARRAY[i] = Math.floor(Math.random() * 16) + 48;
// valid hex characters in the range 48-57 and 97-102
if (SHARED_CHAR_CODES_ARRAY[i] >= 58) {
SHARED_CHAR_CODES_ARRAY[i] += 39;
}
}
return String.fromCharCode.apply(null, SHARED_CHAR_CODES_ARRAY.slice(0, bytes * 2));
};
}
//# sourceMappingURL=RandomIdGenerator.js.map

@@ -43,2 +43,3 @@ import { Context, Exception, HrTime, Link, Span as APISpan, Attributes, AttributeValue, SpanContext, SpanKind, SpanStatus, TimeInput } from '@opentelemetry/api';

private _droppedLinksCount;
private _attributesCount;
name: string;

@@ -45,0 +46,0 @@ status: SpanStatus;

@@ -41,2 +41,3 @@ "use strict";

_droppedLinksCount = 0;
_attributesCount = 0;
name;

@@ -96,5 +97,6 @@ status = {

const { attributeCountLimit } = this._spanLimits;
const isNewKey = !Object.prototype.hasOwnProperty.call(this.attributes, key);
if (attributeCountLimit !== undefined &&
Object.keys(this.attributes).length >= attributeCountLimit &&
!Object.prototype.hasOwnProperty.call(this.attributes, key)) {
this._attributesCount >= attributeCountLimit &&
isNewKey) {
this._droppedAttributesCount++;

@@ -104,2 +106,5 @@ return this;

this.attributes[key] = this._truncateToSize(value);
if (isNewKey) {
this._attributesCount++;
}
return this;

@@ -106,0 +111,0 @@ }

@@ -1,2 +0,2 @@

export declare const VERSION = "2.5.0";
export declare const VERSION = "2.5.1";
//# sourceMappingURL=version.d.ts.map

@@ -20,3 +20,3 @@ "use strict";

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '2.5.0';
exports.VERSION = '2.5.1';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/sdk-trace-base",
"version": "2.5.0",
"version": "2.5.1",
"description": "OpenTelemetry Tracing",

@@ -23,3 +23,4 @@ "main": "build/src/index.js",

"test:webworker": "karma start karma.worker.js --single-run",
"test:bench": "node test/performance/benchmark/index.js | tee .benchmark-results.txt",
"test:bench": "mocha 'test/node/**/*.bench.ts' | grep 'ops/sec' | tee test/node/.benchmark-results.txt",
"test:bench:browser": "karma start karma.bench.js --single-run",
"tdd": "npm run tdd:node",

@@ -68,2 +69,3 @@ "tdd:node": "npm run test -- --watch-extensions ts --watch",

"@opentelemetry/api": ">=1.3.0 <1.10.0",
"@types/benchmark": "2.1.5",
"@types/mocha": "10.0.10",

@@ -86,3 +88,3 @@ "@types/node": "18.19.130",

"typescript": "5.0.4",
"webpack": "5.101.3"
"webpack": "5.104.1"
},

@@ -93,4 +95,4 @@ "peerDependencies": {

"dependencies": {
"@opentelemetry/core": "2.5.0",
"@opentelemetry/resources": "2.5.0",
"@opentelemetry/core": "2.5.1",
"@opentelemetry/resources": "2.5.1",
"@opentelemetry/semantic-conventions": "^1.29.0"

@@ -100,3 +102,3 @@ },

"sideEffects": false,
"gitHead": "38924cbff2a6e924ce8a2a227d3a72de52fbcd35"
"gitHead": "ad92be4c2c1094745a85b0b7eeff1444a11b1b4a"
}

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

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

Sorry, the diff of this file is not supported yet