Skip to content

Commit

Permalink
fix null pointer in jaeger-spark-dependencies
Browse files Browse the repository at this point in the history
fixes jaegertracing/jaeger-operator#1113

Signed-off-by: Moritz Johner <[email protected]>
  • Loading branch information
moolen committed Jul 4, 2020
1 parent 00b6e96 commit ce93dec
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func toTime(nano pdata.TimestampUnixNano) time.Time {
func references(links pdata.SpanLinkSlice, parentSpanID pdata.SpanID, traceID dbmodel.TraceID) ([]dbmodel.Reference, error) {
parentSpanIDSet := len(parentSpanID.Bytes()) != 0
if !parentSpanIDSet && links.Len() == 0 {
return nil, nil
return []dbmodel.Reference{}, nil
}

refsCount := links.Len()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,33 @@ func TestConvertSpan(t *testing.T) {
}, spans[0])
}

func TestSpanEmptyRef(t *testing.T) {
traces := traces("myservice")
span := addSpan(traces, "root", traceID, spanID)
span.SetStartTime(pdata.TimestampUnixNano(1000000))
span.SetEndTime(pdata.TimestampUnixNano(2000000))

c := &Translator{}
spans, err := c.ConvertSpans(traces)
require.NoError(t, err)
assert.Equal(t, 1, len(spans))
assert.Equal(t, &dbmodel.Span{
TraceID: "30313233343536373839616263646566",
SpanID: "3031323334353637",
StartTime: 1000,
Duration: 1000,
OperationName: "root",
StartTimeMillis: 1,
Tags: nil,
Logs: nil,
References: []dbmodel.Reference{}, // should not be nil
Process: dbmodel.Process{
ServiceName: "myservice",
Tags: nil,
},
}, spans[0])
}

func TestEmpty(t *testing.T) {
c := &Translator{}
spans, err := c.ConvertSpans(pdata.NewTraces())
Expand Down

0 comments on commit ce93dec

Please sign in to comment.