Skip to content

Commit

Permalink
fix(zipkin-exporter): round duration for zipkin (#4064)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
  • Loading branch information
n0cloud and dyladan authored Aug 17, 2023
1 parent 5259a0b commit b400c2e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-exporter-zipkin/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit b400c2e

Please sign in to comment.