Documentation
¶
Index ¶
- Constants
- Variables
- func Attach(stack *Stack)
- func Detach()
- func Export(stack *Stack, offsetNS int64) *stack_model.Stack
- func ExportFuncInfo(entry *Entry) *stack_model.FuncInfo
- func ExportStackEntries(entries []*Entry, rootBegin time.Time, offsetNS int64) []*stack_model.StackEntry
- func ExportStackEntry(entry *Entry, rootBegin time.Time, offsetNS int64) *stack_model.StackEntry
- type Entry
- type EntryData
- type Field
- type G
- type Stack
- func (c *Stack) AppendGoChild(beginNs int64, getStack func() *Stack)
- func (c *Stack) Finish(cur *Entry, oldTop *Entry, end time.Time, setStackEnd bool, ...)
- func (c *Stack) GetData(key interface{}) interface{}
- func (c *Stack) NewEntry(begin time.Time, fnName string) *Entry
- func (c *Stack) Push(cur *Entry) *Entry
- func (c *Stack) PushNew(begin time.Time, fnName string, setup func(*Entry)) (cur *Entry, oldTop *Entry)
- func (c *Stack) SetData(key, value interface{})
- func (c *Stack) SetEndIfZero(t time.Time)
- func (c *Stack) Snapshot() (begin, end time.Time, roots []*Entry)
- type StackArgs
Constants ¶
const NilG = G(uintptr(0)) // nil
Variables ¶
var InitGStack = &Stack{}
InitGStack special stack during init
var NilGStack = &Stack{}
NilGStack is a guard pointer for when g is nil because m is just starting on g0
Functions ¶
func ExportFuncInfo ¶
func ExportFuncInfo(entry *Entry) *stack_model.FuncInfo
func ExportStackEntries ¶
func ExportStackEntries(entries []*Entry, rootBegin time.Time, offsetNS int64) []*stack_model.StackEntry
func ExportStackEntry ¶
func ExportStackEntry(entry *Entry, rootBegin time.Time, offsetNS int64) *stack_model.StackEntry
Types ¶
type Entry ¶
type Entry struct {
ID int
ParentID int
FuncInfo *core.FuncInfo
BeginNs int64
EndNs int64
Finished bool
Children []*Entry
Data EntryData
Go bool // has go keyword
// only valid when Go==true
GetStack func() *Stack
FuncName string
File string
Line int
HitMock bool
Panic bool
PanicLine int
Error string
Args interface{}
Results interface{}
}
type G ¶
type G uintptr
G points to runtime.G
func (G) AttachStack ¶
func (G) DetachStack ¶
func (g G) DetachStack()
func (G) GetOrAttachStack ¶
type Stack ¶
type Stack struct {
// Begin is fixed after stack creation; safe to read without mu for
// computing relative nanoseconds outside the lock.
Begin time.Time
End time.Time
MaxEntryID int
Roots []*Entry
Top *Entry
Depth int
Data map[interface{}]interface{}
// contains filtered or unexported fields
}
Stack is a per-goroutine call tree. All tree mutations and export snapshots go through mu so concurrent Push (child) vs Export (parent) is race-free under -race (see race_export / issue #341 follow-up Phase 1).
IMPORTANT: never call instrumented functions (e.g. time.Time methods that may trap) while holding mu — trap re-enters GetData and deadlocks.
func GetOrAttach ¶
func GetOrAttach() *Stack
func (*Stack) AppendGoChild ¶ added in v1.2.3
AppendGoChild attaches a synthetic "go" node under the current Top under lock.
func (*Stack) Finish ¶ added in v1.2.3
func (c *Stack) Finish(cur *Entry, oldTop *Entry, end time.Time, setStackEnd bool, finish func(*Entry))
Finish completes an entry, restores Top, decrements Depth under lock. finish must not call instrumented functions (no time.Time methods, no traps).
func (*Stack) PushNew ¶ added in v1.2.3
func (c *Stack) PushNew(begin time.Time, fnName string, setup func(*Entry)) (cur *Entry, oldTop *Entry)
PushNew creates an entry, pushes it, runs setup, and increments Depth under one lock so the tree is never observed half-updated by Export. MaxEntryID is bumped twice (newEntry + push), matching historical NewEntry+Push.
func (*Stack) SetEndIfZero ¶ added in v1.2.3
SetEndIfZero records stack end time once (goroutine exit).