Skip to content

Commit 70d6c4d

Browse files
committed
fix(exporter-zipkin): round timestamp in zipkin annotations
1 parent 2499708 commit 70d6c4d

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
1414
### :bug: (Bug Fix)
1515

1616
* fix(sdk-metrics): allow instrument names to contain '/' [#4155](https://github.com/open-telemetry/opentelemetry-js/pull/4155)
17+
* fix(exporter-zipkin): round duration to the nearest int in annotations to be compliant with zipkin protocol [#]() @FelipeEmerim
1718

1819
### :books: (Refine Doc)
1920

packages/opentelemetry-exporter-zipkin/src/transform.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export function _toZipkinAnnotations(
111111
events: TimedEvent[]
112112
): zipkinTypes.Annotation[] {
113113
return events.map(event => ({
114-
timestamp: hrTimeToMicroseconds(event.time),
114+
timestamp: Math.round(hrTimeToMicroseconds(event.time)),
115115
value: event.name,
116116
}));
117117
}

packages/opentelemetry-exporter-zipkin/test/common/transform.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('transform', () => {
8282
annotations: [
8383
{
8484
value: 'my-event',
85-
timestamp: hrTimeToMicroseconds(span.events[0].time),
85+
timestamp: Math.round(hrTimeToMicroseconds(span.events[0].time)),
8686
},
8787
],
8888
duration: Math.round(
@@ -329,11 +329,11 @@ describe('transform', () => {
329329
assert.deepStrictEqual(annotations, [
330330
{
331331
value: 'my-event1',
332-
timestamp: hrTimeToMicroseconds(span.events[0].time),
332+
timestamp: Math.round(hrTimeToMicroseconds(span.events[0].time)),
333333
},
334334
{
335335
value: 'my-event2',
336-
timestamp: hrTimeToMicroseconds(span.events[1].time),
336+
timestamp: Math.round(hrTimeToMicroseconds(span.events[1].time)),
337337
},
338338
]);
339339
});

0 commit comments

Comments
 (0)