Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2
### :bug: Bug Fixes

* fix(instrumentation-http): respect requireParent flag when INVALID_SPAN_CONTEXT is used [#4788](https://github.com/open-telemetry/opentelemetry-js/pull/4788) @reberhardt7
* fix(otlp-transformer): trunc hrTime to int for nanos converting [#5924](https://github.com/open-telemetry/opentelemetry-js/pull/5924) @blumamir

### :books: Documentation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import { hexToBinary } from './hex-to-binary';

export function hrTimeToNanos(hrTime: HrTime): bigint {
const NANOSECONDS = BigInt(1_000_000_000);
return BigInt(hrTime[0]) * NANOSECONDS + BigInt(hrTime[1]);
return (
BigInt(Math.trunc(hrTime[0])) * NANOSECONDS + BigInt(Math.trunc(hrTime[1]))
);
}

export function toLongBits(value: bigint): LongBits {
Expand Down
6 changes: 6 additions & 0 deletions experimental/packages/otlp-transformer/test/trace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,12 @@ describe('Trace', () => {
assert.deepStrictEqual(JSON.parse(decoder.decode(serialized)), expected);
});

it('hrtime contains float value', () => {
const span = createSpanWithResource(resource);
(span as any).startTime = [1640715557.5, 342725388.5];
JsonTraceSerializer.serializeRequest([span]);
});

it('deserializes a response', () => {
const expectedResponse = {
partialSuccess: {
Expand Down
Loading