return ctx, childSpan
}
-// Goroutine associates the context with a new Thread ID. The Chrome trace viewer associates each
+// StartGoroutine associates the context with a new Thread ID. The Chrome trace viewer associates each
// trace event with a thread, and doesn't expect events with the same thread id to happen at the
// same time.
-func Goroutine(ctx context.Context) context.Context {
+func StartGoroutine(ctx context.Context) context.Context {
tc, ok := getTraceContext(ctx)
if !ok {
return ctx
// Handle runs a single action and takes care of triggering
// any actions that are runnable as a result.
- handle := func(a *Action) {
+ handle := func(ctx context.Context, a *Action) {
if a.json != nil {
a.json.TimeStart = time.Now()
}
var err error
if a.Func != nil && (!a.Failed || a.IgnoreFail) {
+ // TODO(matloob): Better action descriptions
+ desc := "Executing action "
+ if a.Package != nil {
+ desc += "(" + a.Mode + " " + a.Package.Desc() + ")"
+ }
+ ctx, span := trace.StartSpan(ctx, desc)
+ _ = ctx
err = a.Func(b, a)
+ span.Done()
}
if a.json != nil {
a.json.TimeDone = time.Now()
for i := 0; i < par; i++ {
wg.Add(1)
go func() {
+ ctx := trace.StartGoroutine(ctx)
defer wg.Done()
for {
select {
b.exec.Lock()
a := b.ready.pop()
b.exec.Unlock()
- handle(a)
+ handle(ctx, a)
case <-base.Interrupted:
base.SetExitStatus(1)
return