backend/tardigrade: Upgrade to uplink v1.0.6

This fixes an important bug with listing that affects users with more
than 500 objects in a listing operation.
This commit is contained in:
Caleb Case 2020-05-29 09:08:11 -04:00 committed by Nick Craig-Wood
parent 764b90a519
commit e7bd392a69
154 changed files with 1242 additions and 1028 deletions

View file

@ -272,6 +272,33 @@ func (f *Func) ResetTrace(ctx *context.Context,
return exit
}
// RestartTrace is like Func.Task, except it always creates a new Trace and inherient
// all tags from the existing trace.
func (f *Func) RestartTrace(ctx *context.Context, args ...interface{}) func(*error) {
existingSpan := SpanFromCtx(*ctx)
if existingSpan == nil {
return f.ResetTrace(ctx, args)
}
existingTrace := existingSpan.Trace()
if existingTrace == nil {
return f.ResetTrace(ctx, args)
}
ctx = cleanCtx(ctx)
if ctx == &taskSecret && taskArgs(f, args) {
return nil
}
trace := NewTrace(NewId())
trace.copyFrom(existingTrace)
f.scope.r.observeTrace(trace)
s, exit := newSpan(*ctx, f, args, trace.Id(), trace)
if ctx != &unparented {
*ctx = s
}
return exit
}
var unparented = context.Background()
func cleanCtx(ctx *context.Context) *context.Context {

View file

@ -108,6 +108,17 @@ func removeObserverFrom(parent **spanObserverTuple, ref *spanObserverTuple) (
// Id returns the id of the Trace
func (t *Trace) Id() int64 { return t.id }
// GetAll returns values associated with a trace. See SetAll.
func (t *Trace) GetAll() (val map[interface{}]interface{}) {
t.mtx.Lock()
defer t.mtx.Unlock()
new := make(map[interface{}]interface{}, len(t.vals))
for k, v := range t.vals {
new[k] = v
}
return new
}
// Get returns a value associated with a key on a trace. See Set.
func (t *Trace) Get(key interface{}) (val interface{}) {
t.mtx.Lock()
@ -129,6 +140,14 @@ func (t *Trace) Set(key, val interface{}) {
t.mtx.Unlock()
}
// copyFrom replace all key/value on a trace with a new sets of key/value.
func (t *Trace) copyFrom(s *Trace) {
vals := s.GetAll()
t.mtx.Lock()
defer t.mtx.Unlock()
t.vals = vals
}
func (t *Trace) incrementSpans() { atomic.AddInt64(&t.spanCount, 1) }
func (t *Trace) decrementSpans() { atomic.AddInt64(&t.spanCount, -1) }