type resource … const noResource … type gState … // newGState constructs a new goroutine state for the goroutine // identified by the provided ID. func newGState[R resource](goID trace.GoID) *gState[R] { … } // augmentName attempts to use stk to augment the name of the goroutine // with stack information. This stack must be related to the goroutine // in some way, but it doesn't really matter which stack. func (gs *gState[R]) augmentName(stk trace.Stack) { … } // setLabel adds an additional label to the goroutine's name. func (gs *gState[R]) setLabel(label string) { … } // name returns a name for the goroutine. func (gs *gState[R]) name() string { … } // setStartCause sets the reason a goroutine will be allowed to start soon. // For example, via unblocking or exiting a blocked syscall. func (gs *gState[R]) setStartCause(ts trace.Time, name string, resource uint64, stack trace.Stack) { … } // created indicates that this goroutine was just created by the provided creator. func (gs *gState[R]) created(ts trace.Time, creator R, stack trace.Stack) { … } // start indicates that a goroutine has started running on a proc. func (gs *gState[R]) start(ts trace.Time, resource R, ctx *traceContext) { … } // syscallBegin indicates that the goroutine entered a syscall on a proc. func (gs *gState[R]) syscallBegin(ts trace.Time, resource R, stack trace.Stack) { … } // syscallEnd ends the syscall slice, wherever the syscall is at. This is orthogonal // to blockedSyscallEnd -- both must be called when a syscall ends and that syscall // blocked. They're kept separate because syscallEnd indicates the point at which the // goroutine is no longer executing on the resource (e.g. a proc) whereas blockedSyscallEnd // is the point at which the goroutine actually exited the syscall regardless of which // resource that happened on. func (gs *gState[R]) syscallEnd(ts trace.Time, blocked bool, ctx *traceContext) { … } // blockedSyscallEnd indicates the point at which the blocked syscall ended. This is distinct // and orthogonal to syscallEnd; both must be called if the syscall blocked. This sets up an instant // to emit a flow event from, indicating explicitly that this goroutine was unblocked by the system. func (gs *gState[R]) blockedSyscallEnd(ts trace.Time, stack trace.Stack, ctx *traceContext) { … } // unblock indicates that the goroutine gs represents has been unblocked. func (gs *gState[R]) unblock(ts trace.Time, stack trace.Stack, resource R, ctx *traceContext) { … } // block indicates that the goroutine has stopped executing on a proc -- specifically, // it blocked for some reason. func (gs *gState[R]) block(ts trace.Time, stack trace.Stack, reason string, ctx *traceContext) { … } // stop indicates that the goroutine has stopped executing on a proc. func (gs *gState[R]) stop(ts trace.Time, stack trace.Stack, ctx *traceContext) { … } // finalize writes out any in-progress slices as if the goroutine stopped. // This must only be used once the trace has been fully processed and no // further events will be processed. This method may leave the gState in // an inconsistent state. func (gs *gState[R]) finish(ctx *traceContext) { … } // rangeBegin indicates the start of a special range of time. func (gs *gState[R]) rangeBegin(ts trace.Time, name string, stack trace.Stack) { … } // rangeActive indicates that a special range of time has been in progress. func (gs *gState[R]) rangeActive(name string) { … } // rangeEnd indicates the end of a special range of time. func (gs *gState[R]) rangeEnd(ts trace.Time, name string, stack trace.Stack, ctx *traceContext) { … } func lastFunc(s trace.Stack) (fn string) { … }