diff --git a/CHANGELOG.md b/CHANGELOG.md index ad5c780983..ee112f73dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/ ### :bug: (Bug Fix) * fix(sdk-metrics): allow instrument names to contain '/' [#4155](https://github.com/open-telemetry/opentelemetry-js/pull/4155) +* fix(exporter-zipkin): round duration to the nearest int in annotations to be compliant with zipkin protocol [#4167](https://github.com/open-telemetry/opentelemetry-js/pull/4167) @FelipeEmerim ### :books: (Refine Doc) diff --git a/packages/opentelemetry-exporter-zipkin/src/transform.ts b/packages/opentelemetry-exporter-zipkin/src/transform.ts index 54392321f8..06fbe5973a 100644 --- a/packages/opentelemetry-exporter-zipkin/src/transform.ts +++ b/packages/opentelemetry-exporter-zipkin/src/transform.ts @@ -111,7 +111,7 @@ export function _toZipkinAnnotations( events: TimedEvent[] ): zipkinTypes.Annotation[] { return events.map(event => ({ - timestamp: hrTimeToMicroseconds(event.time), + timestamp: Math.round(hrTimeToMicroseconds(event.time)), value: event.name, })); } diff --git a/packages/opentelemetry-exporter-zipkin/test/common/transform.test.ts b/packages/opentelemetry-exporter-zipkin/test/common/transform.test.ts index 810b9e32f9..4df7f73f6c 100644 --- a/packages/opentelemetry-exporter-zipkin/test/common/transform.test.ts +++ b/packages/opentelemetry-exporter-zipkin/test/common/transform.test.ts @@ -82,7 +82,7 @@ describe('transform', () => { annotations: [ { value: 'my-event', - timestamp: hrTimeToMicroseconds(span.events[0].time), + timestamp: Math.round(hrTimeToMicroseconds(span.events[0].time)), }, ], duration: Math.round( @@ -329,11 +329,11 @@ describe('transform', () => { assert.deepStrictEqual(annotations, [ { value: 'my-event1', - timestamp: hrTimeToMicroseconds(span.events[0].time), + timestamp: Math.round(hrTimeToMicroseconds(span.events[0].time)), }, { value: 'my-event2', - timestamp: hrTimeToMicroseconds(span.events[1].time), + timestamp: Math.round(hrTimeToMicroseconds(span.events[1].time)), }, ]); });