dataloader
dataloader copied to clipboard
wrong time to call 'TraceBatchFinishFunc'
ctx, finish := b.tracer.TraceBatch(originalContext, keys)
defer finish(items) // this should be moved
func() {
defer func() {
if r := recover(); r != nil {
panicErr = r
if b.silent {
return
}
const size = 64 << 10
buf := make([]byte, size)
buf = buf[:runtime.Stack(buf, false)]
log.Printf("Dataloader: Panic received in batch function:: %v\n%s", panicErr, buf)
}
}()
items = b.batchFn(ctx, keys)
}()
// defer finish(items)
I just noticed this too. By calling it here, it captures the wrong items slice, so the finish function from the tracing always gets an empty slice.
PRs are open :)