lightstep / lightstep-tracer-go

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

allow lazy loggers to emit 0 -> N log entries instead of just 1 #213

Closed MatthewDolan closed 5 years ago

MatthewDolan commented 5 years ago

R: @bg451 @iredelmeier

CC: @jmacd

Summary of Change

I wanted to extend the functionality of the lazy logger to allow emitting 0 fields (for optional fields) or more than one field (for multiple lazy fields computed from the same object).

The one downside I see is that this makes it so the number of fields encoded is not equal to the number of fields passed in. This means that the array can't be pre-allocated to the exact right capacity. I think that's a reasonable trade-off though.

For the expected use case (emitting exactly one field form a lazy logger), this should work mostly as expected. For unexpected use cases, this might be a change in behavior. Before, it was last write wins, but now it will emit all fields.

MatthewDolan commented 5 years ago

thanks @bg451!