Tracing: fix span tagging and add LazyFields
Created by: camdencheek
This adds a couple things to our trace
package to fix some issues I
was running into when trying to expand our instrumentation coverage in
the search package.
First, it adds a LazyFields
function, which is like log.Lazy
except
it takes a function that generates a set of fields to log. This is
convenient when you have a set of potentially-expensive-to-generate
fields that you want to log, or also if you have self-describing objects
(such as the example CommitSearch.Tags()
method).
Second, it adds spanTagEncoder
. This is a bug fix.
opentracing.Span.SetTags
only accepts numeric types, strings, and
bools, so when we would try to set a tag to an object type or a lazy
field, it would just set a tag with the memory address of that object.
Super not sure who to tag on this, so