Skip to content

Commit

Permalink
fix(core): stop rounding to nearest int in hrTimeTo*seconds() functio…
Browse files Browse the repository at this point in the history
…ns (#4014)
  • Loading branch information
aabmass authored Jul 31, 2023
1 parent 2b20565 commit c021b10
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-core/src/common/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ 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;
}

/**
* Convert hrTime to microseconds.
* @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;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-shim-opentracing/test/Shim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down Expand Up @@ -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
);
});

Expand Down

0 comments on commit c021b10

Please sign in to comment.