lightstep / lightstep-tracer-go

The Lightstep distributed tracing library for Go
https://lightstep.com
MIT License
98 stars 54 forks source link

tracerImpl.Flush: nil pointer exception #161

Closed joyzheng closed 5 years ago

joyzheng commented 5 years ago

In tracerImpl.Flush, there is the following code snippet:

    req, flushErr := tracer.client.Translate(ctx, &tracer.flushing)
    resp, flushErr := tracer.client.Report(ctx, req)

    if flushErr != nil {
        flushErrorEvent = newEventFlushError(flushErr, FlushErrorTransport)
    } else if len(resp.GetErrors()) > 0 {
        flushErrorEvent = newEventFlushError(fmt.Errorf(resp.GetErrors()[0]), FlushErrorReport)
    }

which is not checking for any flushErr from tracer.client.Translate before using the results in tracer.client.Report. This leads to a panic at

    /github.com/lightstep/lightstep-tracer-go/tracer.go:356 +0x20a
github.com/lightstep/lightstep-tracer-go.(*tracerImpl).reportLoop(0xc00027e800)
    /github.com/lightstep/lightstep-tracer-go/tracer.go:122 +0x733
github.com/lightstep/lightstep-tracer-go.(*tracerImpl).Flush(0xc00027e800, 0x2a77ea0, 0xc00131e540)
    /github.com/lightstep/lightstep-tracer-go/collector_client_http.go:109 +0x4d
    /github.com/lightstep/lightstep-tracer-go/tracer.go:234 +0x1aa
github.com/lightstep/lightstep-tracer-go.(*httpCollectorClient).Report(0xc0007e51c0, 0x2a77ea0, 0xc00131e540, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/local/go/src/net/http/client.go:518 +0x8f
net/http.(*Client).do(0xc000ceeba0, 0x0, 0x0, 0x0, 0x0)
bg451 commented 5 years ago

Hey @joyzheng, a new release has been created with a fix for this issue. https://github.com/lightstep/lightstep-tracer-go/releases/tag/v0.15.5

joyzheng commented 5 years ago

Thank you!