Skip to content

Commit

Permalink
Merge pull request #684 from DataDog/marcosaia/RUM-1830/128-bit-trace…
Browse files Browse the repository at this point in the history
…-ids

[RUM-1830] Replaced bigint literals with BigInt
  • Loading branch information
marco-saia-datadog committed Jul 4, 2024
2 parents 3cff869 + 78a1d49 commit 13fe986
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ export enum TracingIdType {
/**
* Value used to mask the low 64 bits of the trace identifier.
*/
const LOW_64BIT_MASK = (BigInt('0xffffffff') << 32n) + BigInt('0xffffffff');
const LOW_64BIT_MASK =
(BigInt('0xffffffff') << BigInt(32)) + BigInt('0xffffffff');

/**
* Value used to mask the low 32 bits of the trace identifier.
*/
const LOW_32BIT_MASK = (BigInt('0xffff') << 16n) + BigInt('0xffff');
const LOW_32BIT_MASK = (BigInt('0xffff') << BigInt(16)) + BigInt('0xffff');

/**
* A {@link TracingIdentifier} is a unique UUID that can be 64bit or 128bit, and provides
Expand Down Expand Up @@ -181,7 +182,8 @@ export class TracingIdentifier {
public toString(format: TracingIdFormat): string {
const lowTraceMask =
this.type === TracingIdType.trace ? LOW_64BIT_MASK : LOW_32BIT_MASK;
const highTraceMask = this.type === TracingIdType.trace ? 64n : 32n;
const highTraceMask =
this.type === TracingIdType.trace ? BigInt(64) : BigInt(32);
const padding = this.type === TracingIdType.trace ? 32 : 16;

switch (format) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe('TracingIdentifier', () => {
it('M return valid string representations for zero ID w toString', () => {
// GIVEN
const tracingId = TracingIdentifier.createTraceId();
(tracingId as any)['id'] = 0n;
(tracingId as any)['id'] = BigInt(0);

// THEN

Expand Down Expand Up @@ -314,7 +314,7 @@ describe('TracingIdentifier', () => {
it('M return valid string representations for zero ID w toString', () => {
// GIVEN
const tracingId = TracingIdentifier.createSpanId();
(tracingId as any)['id'] = 0n;
(tracingId as any)['id'] = BigInt(0);

// THEN

Expand Down

0 comments on commit 13fe986

Please sign in to comment.