Skip to content

Commit

Permalink
inject-core: InMemoryTracer.ZipkinFormatter should use microseconds
Browse files Browse the repository at this point in the history
Problem/Solution

The `InMemoryTracer.ZipkinFormatter` mistakenly uses
milliseconds instead of microseconds in a few places,
per the documentation at https://zipkin.io/zipkin-api/zipkin2-api.yaml.
The formatter also doesn't properly render a local trace span's
id. Let's fix this.

Differential Revision: https://phabricator.twitter.biz/D914692
  • Loading branch information
enbnt authored and jenkins committed Jun 17, 2022
1 parent 5b5ccf4 commit cc7c24b
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ object InMemoryTracer {
name = records.collectFirst {
case Record(_, _, Annotation.Rpc(name), _) => name
},
timestamp = records.lastOption.map(_.timestamp.inMillis),
timestamp = records.lastOption.map(_.timestamp.inMicroseconds),
duration = duration,
localEndpoint = records.collectFirst {
case Record(_, _, Annotation.LocalAddr(ia), _) =>
Expand All @@ -125,6 +125,14 @@ object InMemoryTracer {
ipv4 = Some(ia.getHostString),
ipv6 = None,
port = Some(ia.getPort))
case Record(_, _, Annotation.ServiceName(svc), _) =>
// this is a secondary case for Local Tracing
EndpointNode(
serviceName = Some(svc),
ipv4 = None,
ipv6 = None,
port = None
)
},
remoteEndpoint = records.collectFirst {
case Record(_, _, Annotation.ClientAddr(ia), _) =>
Expand All @@ -136,11 +144,11 @@ object InMemoryTracer {
},
annotations = records.collect {
case Record(_, timestamp, Annotation.WireRecv, _) =>
AnnotationNode(timestamp.inMillis, "wr")
AnnotationNode(timestamp.inMicroseconds, "wr")
case Record(_, timestamp, Annotation.WireSend, _) =>
AnnotationNode(timestamp.inMillis, "ws")
AnnotationNode(timestamp.inMicroseconds, "ws")
case Record(_, timestamp, Annotation.Message(msg), _) =>
AnnotationNode(timestamp.inMillis, msg)
AnnotationNode(timestamp.inMicroseconds, msg)
},
tags = records.collect {
case Record(_, _, Annotation.BinaryAnnotation(k, v), _) => (k -> v.toString)
Expand Down

0 comments on commit cc7c24b

Please sign in to comment.