github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/go/internal/trace/trace.go (about) 1 // Copyright 2020 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package trace 6 7 import ( 8 "github.com/shogo82148/std/context" 9 "github.com/shogo82148/std/time" 10 ) 11 12 // StartSpan starts a trace event with the given name. The Span ends when its Done method is called. 13 func StartSpan(ctx context.Context, name string) (context.Context, *Span) 14 15 // StartGoroutine associates the context with a new Thread ID. The Chrome trace viewer associates each 16 // trace event with a thread, and doesn't expect events with the same thread id to happen at the 17 // same time. 18 func StartGoroutine(ctx context.Context) context.Context 19 20 // Flow marks a flow indicating that the 'to' span depends on the 'from' span. 21 // Flow should be called while the 'to' span is in progress. 22 func Flow(ctx context.Context, from *Span, to *Span) 23 24 type Span struct { 25 t *tracer 26 27 name string 28 tid uint64 29 start time.Time 30 end time.Time 31 } 32 33 func (s *Span) Done() 34 35 // Start starts a trace which writes to the given file. 36 func Start(ctx context.Context, file string) (context.Context, func() error, error)