diff --git a/CHANGELOG.md b/CHANGELOG.md index b7b8a06ef3..c5f1569a88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/ ### :bug: (Bug Fix) * fix(opentelemetry-exporter-logs-otlp-http): Add otel-api as dev dep for tests as they are directly importing the api and which is breaking the web-sandbox tests which is using rollup +* fix(core): stop rounding to nearest int in hrTimeTo*seconds() functions [#4014](https://github.com/open-telemetry/opentelemetry-js/pull/4014/) @aabmass ### :books: (Refine Doc) diff --git a/packages/opentelemetry-core/src/common/time.ts b/packages/opentelemetry-core/src/common/time.ts index 8dd650a992..8d3051b00c 100644 --- a/packages/opentelemetry-core/src/common/time.ts +++ b/packages/opentelemetry-core/src/common/time.ts @@ -129,7 +129,7 @@ export function hrTimeToNanoseconds(time: api.HrTime): number { * @param time */ export function hrTimeToMilliseconds(time: api.HrTime): number { - return Math.round(time[0] * 1e3 + time[1] / 1e6); + return time[0] * 1e3 + time[1] / 1e6; } /** @@ -137,7 +137,7 @@ export function hrTimeToMilliseconds(time: api.HrTime): number { * @param time */ export function hrTimeToMicroseconds(time: api.HrTime): number { - return Math.round(time[0] * 1e6 + time[1] / 1e3); + return time[0] * 1e6 + time[1] / 1e3; } /** diff --git a/packages/opentelemetry-shim-opentracing/test/Shim.test.ts b/packages/opentelemetry-shim-opentracing/test/Shim.test.ts index cd3749a681..2da2f80003 100644 --- a/packages/opentelemetry-shim-opentracing/test/Shim.test.ts +++ b/packages/opentelemetry-shim-opentracing/test/Shim.test.ts @@ -261,7 +261,7 @@ describe('OpenTracing Shim', () => { assert.strictEqual(otSpan.links.length, 1); assert.deepStrictEqual( hrTimeToMilliseconds(otSpan.startTime), - Math.round(now + adjustment + performance.timeOrigin) + now + adjustment + performance.timeOrigin ); assert.deepStrictEqual(otSpan.attributes, opentracingOptions.tags); }); @@ -495,7 +495,7 @@ describe('OpenTracing Shim', () => { const adjustment = otSpan['_performanceOffset']; assert.deepStrictEqual( hrTimeToMilliseconds(otSpan.endTime), - Math.round(now + adjustment + performance.timeOrigin) + now + adjustment + performance.timeOrigin ); });