Skip to content

Commit

Permalink
Remove extra send/receive annotations with using zipkin v1
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-smith-zocdoc committed May 19, 2020
1 parent f588c89 commit 54c9ed8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 130 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/golang/protobuf v1.3.5
github.com/golangci/golangci-lint v1.24.0
github.com/google/addlicense v0.0.0-20200301095109-7c013a14f2e2
github.com/google/go-cmp v0.4.1
github.com/google/uuid v1.1.1
github.com/gorilla/handlers v1.4.2 // indirect
github.com/gorilla/mux v1.7.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.4.1 h1:/exdXoGamhu5ONeUJH0deniYLWYvQwW66yvlfiiKTu0=
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
Expand Down
5 changes: 3 additions & 2 deletions translator/trace/zipkin/zipkinv1_thrift_to_protospan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package zipkin
import (
"encoding/binary"
"encoding/json"
"github.com/google/go-cmp/cmp"
"io/ioutil"
"math"
"reflect"
Expand Down Expand Up @@ -90,8 +91,8 @@ func TestV1ThriftToOCProto(t *testing.T) {
sortTraceByNodeName(want)
sortTraceByNodeName(got)

if !reflect.DeepEqual(got, want) {
t.Fatalf("got different data than want")
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("Diff mismatch (-want +got):\n%s", diff)
}
}

Expand Down
5 changes: 5 additions & 0 deletions translator/trace/zipkin/zipkinv1_to_protospan.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ func parseZipkinV1Annotations(annotations []*annotation) *annotationParseResult
res.LateAnnotationTime = ts
}

if annotationHasSpanKind {
// If this annotation is for the send/receive timestamps, no need to create the annotation
continue
}

timeEvent := &tracepb.Span_TimeEvent{
Time: ts,
// More economically we could use a tracepb.Span_TimeEvent_Message, however, it will mean the loss of some information.
Expand Down
132 changes: 4 additions & 128 deletions translator/trace/zipkin/zipkinv1_to_protospan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,38 +582,7 @@ var ocBatchesFromZipkinV1 = []consumerdata.TraceData{
Kind: tracepb.Span_CLIENT,
StartTime: &timestamp.Timestamp{Seconds: 1544805927, Nanos: 446743000},
EndTime: &timestamp.Timestamp{Seconds: 1544805927, Nanos: 459699000},
TimeEvents: &tracepb.Span_TimeEvents{
TimeEvent: []*tracepb.Span_TimeEvent{
{
Time: &timestamp.Timestamp{Seconds: 1544805927, Nanos: 446743000},
Value: &tracepb.Span_TimeEvent_Annotation_{
Annotation: &tracepb.Span_TimeEvent_Annotation{
Attributes: &tracepb.Span_Attributes{
AttributeMap: map[string]*tracepb.AttributeValue{
"cs": {
Value: &tracepb.AttributeValue_StringValue{StringValue: &tracepb.TruncatableString{Value: "front-proxy"}},
},
},
},
},
},
},
{
Time: &timestamp.Timestamp{Seconds: 1544805927, Nanos: 460510000},
Value: &tracepb.Span_TimeEvent_Annotation_{
Annotation: &tracepb.Span_TimeEvent_Annotation{
Attributes: &tracepb.Span_Attributes{
AttributeMap: map[string]*tracepb.AttributeValue{
"cr": {
Value: &tracepb.AttributeValue_StringValue{StringValue: &tracepb.TruncatableString{Value: "front-proxy"}},
},
},
},
},
},
},
},
},
TimeEvents: nil,
},
},
},
Expand All @@ -631,38 +600,7 @@ var ocBatchesFromZipkinV1 = []consumerdata.TraceData{
Kind: tracepb.Span_SERVER,
StartTime: &timestamp.Timestamp{Seconds: 1544805927, Nanos: 448081000},
EndTime: &timestamp.Timestamp{Seconds: 1544805927, Nanos: 460102000},
TimeEvents: &tracepb.Span_TimeEvents{
TimeEvent: []*tracepb.Span_TimeEvent{
{
Time: &timestamp.Timestamp{Seconds: 1544805927, Nanos: 448081000},
Value: &tracepb.Span_TimeEvent_Annotation_{
Annotation: &tracepb.Span_TimeEvent_Annotation{
Attributes: &tracepb.Span_Attributes{
AttributeMap: map[string]*tracepb.AttributeValue{
"sr": {
Value: &tracepb.AttributeValue_StringValue{StringValue: &tracepb.TruncatableString{Value: "service1"}},
},
},
},
},
},
},
{
Time: &timestamp.Timestamp{Seconds: 1544805927, Nanos: 460102000},
Value: &tracepb.Span_TimeEvent_Annotation_{
Annotation: &tracepb.Span_TimeEvent_Annotation{
Attributes: &tracepb.Span_Attributes{
AttributeMap: map[string]*tracepb.AttributeValue{
"ss": {
Value: &tracepb.AttributeValue_StringValue{StringValue: &tracepb.TruncatableString{Value: "service1"}},
},
},
},
},
},
},
},
},
TimeEvents: nil,
},
{
TraceId: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0xd2, 0xe6, 0x3c, 0xbe, 0x71, 0xf5, 0xa8},
Expand All @@ -672,38 +610,7 @@ var ocBatchesFromZipkinV1 = []consumerdata.TraceData{
Kind: tracepb.Span_CLIENT,
StartTime: &timestamp.Timestamp{Seconds: 1544805927, Nanos: 453923000},
EndTime: &timestamp.Timestamp{Seconds: 1544805927, Nanos: 457663000},
TimeEvents: &tracepb.Span_TimeEvents{
TimeEvent: []*tracepb.Span_TimeEvent{
{
Time: &timestamp.Timestamp{Seconds: 1544805927, Nanos: 453923000},
Value: &tracepb.Span_TimeEvent_Annotation_{
Annotation: &tracepb.Span_TimeEvent_Annotation{
Attributes: &tracepb.Span_Attributes{
AttributeMap: map[string]*tracepb.AttributeValue{
"cs": {
Value: &tracepb.AttributeValue_StringValue{StringValue: &tracepb.TruncatableString{Value: "service1"}},
},
},
},
},
},
},
{
Time: &timestamp.Timestamp{Seconds: 1544805927, Nanos: 457717000},
Value: &tracepb.Span_TimeEvent_Annotation_{
Annotation: &tracepb.Span_TimeEvent_Annotation{
Attributes: &tracepb.Span_Attributes{
AttributeMap: map[string]*tracepb.AttributeValue{
"cr": {
Value: &tracepb.AttributeValue_StringValue{StringValue: &tracepb.TruncatableString{Value: "service1"}},
},
},
},
},
},
},
},
},
TimeEvents: nil,
},
},
},
Expand Down Expand Up @@ -737,38 +644,7 @@ var ocBatchesFromZipkinV1 = []consumerdata.TraceData{
},
},
},
TimeEvents: &tracepb.Span_TimeEvents{
TimeEvent: []*tracepb.Span_TimeEvent{
{
Time: &timestamp.Timestamp{Seconds: 1544805927, Nanos: 454487000},
Value: &tracepb.Span_TimeEvent_Annotation_{
Annotation: &tracepb.Span_TimeEvent_Annotation{
Attributes: &tracepb.Span_Attributes{
AttributeMap: map[string]*tracepb.AttributeValue{
"sr": {
Value: &tracepb.AttributeValue_StringValue{StringValue: &tracepb.TruncatableString{Value: "service2"}},
},
},
},
},
},
},
{
Time: &timestamp.Timestamp{Seconds: 1544805927, Nanos: 457320000},
Value: &tracepb.Span_TimeEvent_Annotation_{
Annotation: &tracepb.Span_TimeEvent_Annotation{
Attributes: &tracepb.Span_Attributes{
AttributeMap: map[string]*tracepb.AttributeValue{
"ss": {
Value: &tracepb.AttributeValue_StringValue{StringValue: &tracepb.TruncatableString{Value: "service2"}},
},
},
},
},
},
},
},
},
TimeEvents: nil,
},
},
},
Expand Down

0 comments on commit 54c9ed8

Please sign in to comment.