go-zap icon indicating copy to clipboard operation
go-zap copied to clipboard

Bug: Slice is initialised with nil field values

Open swdee opened this issue 5 years ago • 1 comments

Concerning the following line of code the initialisation of the slice opentracingFields creates a slice of the size of the number of fields plus one presumable for the log string.

https://github.com/opentracing-contrib/go-zap/blob/641545003d88df10d21dd244dba39c3b7aaf0af5/log/log.go#L141

However the method the real log fields are added to opentracingFields is done with an append function which causes these additional fields to be added after the nil fields initialized by make. As a result nil/empty fields are passed to span.LogFields() which causes empty log lines to be displayed in the WebUI of Jaeger.

To stop these empty fields being passed the opentracingFields slice should be initialized as zero size, eg: Line 141 above should be;

opentracingFields := make([]opentracinglog.Field, 0)

swdee avatar Jan 23 '20 03:01 swdee

Thanks for reporting, I confirmed this after a quick test. I will issue a PR for this.

bvandewalle avatar Feb 07 '20 18:02 bvandewalle