From 814a8eb21c70a507bbb1a9f4c9f4f2c36e245114 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Mon, 13 Jan 2025 10:09:25 +0100 Subject: [PATCH] Use literals for creating BigInts when possible (#5093) --- packages/dd-trace/src/datastreams/fnv.js | 2 +- packages/dd-trace/src/debugger/devtools_client/index.js | 4 ++-- packages/dd-trace/test/llmobs/span_processor.spec.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/dd-trace/src/datastreams/fnv.js b/packages/dd-trace/src/datastreams/fnv.js index c226ec40cd4..3c7d1e66ce9 100644 --- a/packages/dd-trace/src/datastreams/fnv.js +++ b/packages/dd-trace/src/datastreams/fnv.js @@ -15,7 +15,7 @@ function fnv64 (data) { data = Buffer.from(data, 'utf-8') } const byteArray = new Uint8Array(data) - return fnv(byteArray, FNV1_64_INIT, FNV_64_PRIME, BigInt(2) ** BigInt(64)) + return fnv(byteArray, FNV1_64_INIT, FNV_64_PRIME, 2n ** 64n) } module.exports = { diff --git a/packages/dd-trace/src/debugger/devtools_client/index.js b/packages/dd-trace/src/debugger/devtools_client/index.js index c7d59fc1f89..be466b06bd9 100644 --- a/packages/dd-trace/src/debugger/devtools_client/index.js +++ b/packages/dd-trace/src/debugger/devtools_client/index.js @@ -25,8 +25,8 @@ const expression = ` const threadId = parentThreadId === 0 ? `pid:${process.pid}` : `pid:${process.pid};tid:${parentThreadId}` const threadName = parentThreadId === 0 ? 'MainThread' : `WorkerThread:${parentThreadId}` -const oneSecondNs = BigInt(1_000_000_000) -let globalSnapshotSamplingRateWindowStart = BigInt(0) +const oneSecondNs = 1_000_000_000n +let globalSnapshotSamplingRateWindowStart = 0n let snapshotsSampledWithinTheLastSecond = 0 // WARNING: The code above the line `await session.post('Debugger.resume')` is highly optimized. Please edit with care! diff --git a/packages/dd-trace/test/llmobs/span_processor.spec.js b/packages/dd-trace/test/llmobs/span_processor.spec.js index e7ec975ec17..ec69cfc4523 100644 --- a/packages/dd-trace/test/llmobs/span_processor.spec.js +++ b/packages/dd-trace/test/llmobs/span_processor.spec.js @@ -119,7 +119,7 @@ describe('span processor', () => { it('removes problematic fields from the metadata', () => { // problematic fields are circular references or bigints const metadata = { - bigint: BigInt(1), + bigint: 1n, deep: { foo: 'bar' },