diff --git a/jaeger.go b/jaeger.go index 2fd480b..d173acf 100644 --- a/jaeger.go +++ b/jaeger.go @@ -218,7 +218,7 @@ func spanDataToThrift(data *trace.SpanData) *jaeger.Span { tags = append(tags, attributeToTag("error", true)) } - var logs []*jaeger.Log + logs := make([]*jaeger.Log, 0, len(data.Annotations)) for _, a := range data.Annotations { fields := make([]*jaeger.Tag, 0, len(a.Attributes)) for k, v := range a.Attributes { @@ -233,7 +233,7 @@ func spanDataToThrift(data *trace.SpanData) *jaeger.Span { Fields: fields, }) } - var refs []*jaeger.SpanRef + refs := make([]*jaeger.SpanRef, 0, len(data.Links)) for _, link := range data.Links { refs = append(refs, &jaeger.SpanRef{ TraceIdHigh: bytesToInt64(link.TraceID[0:8]), diff --git a/jaeger_test.go b/jaeger_test.go index f78b0e2..7b1c3c8 100644 --- a/jaeger_test.go +++ b/jaeger_test.go @@ -16,14 +16,13 @@ package jaeger import ( "fmt" - "reflect" + "sort" "testing" "time" "github.com/uber/jaeger-client-go/thrift-gen/jaeger" "go.opencensus.io/trace" - "sort" ) // TODO(jbd): Test export. @@ -129,6 +128,7 @@ func Test_spanDataToThrift(t *testing.T) { {Key: "message", VType: jaeger.TagType_STRING, VStr: &statusMessage}, }}, }, + References: []*jaeger.SpanRef{}, }, }, } @@ -141,7 +141,15 @@ func Test_spanDataToThrift(t *testing.T) { sort.Slice(tt.want.Tags, func(i, j int) bool { return tt.want.Tags[i].Key < tt.want.Tags[j].Key }) - if !reflect.DeepEqual(got, tt.want) { + gotBuf, err := serialize(got) + if err != nil { + t.Fatalf("failed to serialize: %v", err) + } + wantBuf, err := serialize(tt.want) + if err != nil { + t.Fatalf("failed to serialize: %v", err) + } + if gotBuf.String() != wantBuf.String() { t.Errorf("spanDataToThrift()\nGot:\n%v\nWant;\n%v", got, tt.want) } })