fix(zipkin-exporter): round duration for zipkin (#4064)

Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
This commit is contained in:
Gabriel Poulenard-Talbot 2023-08-17 11:16:42 -04:00 committed by GitHub
parent 5259a0b928
commit b400c2e5d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View File

@ -15,6 +15,8 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
### :bug: (Bug Fix)
* fix(exporter-zipkin): rounding duration to the nearest int to be compliant with zipkin protocol [#4064](https://github.com/open-telemetry/opentelemetry-js/pull/4064) @n0cloud
### :books: (Refine Doc)
### :house: (Internal)

View File

@ -48,7 +48,7 @@ export function toZipkinSpan(
id: span.spanContext().spanId,
kind: ZIPKIN_SPAN_KIND_MAPPING[span.kind],
timestamp: hrTimeToMicroseconds(span.startTime),
duration: hrTimeToMicroseconds(span.duration),
duration: Math.round(hrTimeToMicroseconds(span.duration)),
localEndpoint: { serviceName },
tags: _toZipkinTags(span, statusCodeTagName, statusErrorTagName),
annotations: span.events.length

View File

@ -85,8 +85,8 @@ describe('transform', () => {
timestamp: hrTimeToMicroseconds(span.events[0].time),
},
],
duration: hrTimeToMicroseconds(
hrTimeDuration(span.startTime, span.endTime)
duration: Math.round(
hrTimeToMicroseconds(hrTimeDuration(span.startTime, span.endTime))
),
id: span.spanContext().spanId,
localEndpoint: {
@ -128,8 +128,8 @@ describe('transform', () => {
assert.deepStrictEqual(zipkinSpan, {
kind: 'SERVER',
annotations: undefined,
duration: hrTimeToMicroseconds(
hrTimeDuration(span.startTime, span.endTime)
duration: Math.round(
hrTimeToMicroseconds(hrTimeDuration(span.startTime, span.endTime))
),
id: span.spanContext().spanId,
localEndpoint: {
@ -179,8 +179,8 @@ describe('transform', () => {
assert.deepStrictEqual(zipkinSpan, {
kind: item.zipkin,
annotations: undefined,
duration: hrTimeToMicroseconds(
hrTimeDuration(span.startTime, span.endTime)
duration: Math.round(
hrTimeToMicroseconds(hrTimeDuration(span.startTime, span.endTime))
),
id: span.spanContext().spanId,
localEndpoint: {