Skip to content

Commit

Permalink
fix(core): stop rounding to nearest int in hrTimeTo*seconds() functions
Browse files Browse the repository at this point in the history
  • Loading branch information
aabmass committed Jul 21, 2023
1 parent 87f21ef commit be3bf19
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/

### :bug: (Bug Fix)

* 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)

### :house: (Internal)
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 be3bf19

Please sign in to comment.