Documentation ¶
Index ¶
Constants ¶
const ( ArgTimestamp = `Timestamp` ArgRealTimestamp = `RealTimestamp` ArgFrequency = `Frequency` ArgSequence = `Sequence` ArgSequenceGC = `SequenceGC` ArgStackID = `StackID` ArgStackSize = `StackSize` ArgNewStackID = `NewStackID` ArgStringID = `StringID` ArgLabelStringID = `LabelStringID` ArgThreadID = `ThreadID` ArgProcessorID = `ProcessorID` ArgGoroutineID = `GoroutineID` ArgNewGoroutineID = `NewGoroutineID` ArgGomaxprocs = `Gomaxprocs` ArgHeapAlloc = `HeapAlloc` ArgNextGC = `NextGC` ArgKind = `Kind` )
Arguments that may exist within an event, 1 or more of these are returned from calls to the Args method of Type.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct { // Type is the type of this Event. Type Type // Args will contain all the Event specific arguments, excluding sequences // and timestamps. All uleb128 values are decoded here including arbitrary // length events like Stack. Args []uint64 // Data may be nil or a slice containing Event data for arguments that are not // uleb128 encoded. Currently only the string event fits this criteria. // // @TODO Remove all together in favor of storing in *Trace? Data []byte // Id's of the P and G associated with this event. With G being a goroutine // and P a resource that is required to execute Go code. P, G int64 // Ts is the timestamp of the event. Ts int64 // Off is the offset of the first byte for this Event relative to the // beginning of the input stream. Off int }
Event provides access to trace data for the Go execution tracer.
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
Frame is a single frame within an stack trace.
type Trace ¶
type Trace struct { Version Version Strings map[uint64]string Stacks map[uint64]Stack Count int // contains filtered or unexported fields }
Trace maintains the shared satate across events.
func NewTrace ¶
NewTrace will create a new trace for the given version, or return an error if the version is unknown.
func (*Trace) Stack ¶
Stack returns the Stack trace associated with the given event, if any. It's possible that events which should have a stack are the zero value for one o two reasons, the stack event was not yet sent over the wire or the Stack was omitted entirely by the runtime. Stacks may be shared across multiple events and should not be mutated, make a copy instead. This will not retrieve the new stack of a EvCreate event, you may use e.Get(ArgNewStackID) tr.Stacks for that.
type Type ¶
type Type byte
Type represents the type of trace event.
const ( EvNone Type = 0 // unused EvBatch Type = 1 // start of per-P batch of events [pid, timestamp] EvFrequency Type = 2 // contains tracer timer frequency [frequency (ticks per second)] EvStack Type = 3 // stack [stack id, number of PCs, array of {PC, func string ID, file string ID, line}] EvGomaxprocs Type = 4 // current value of GOMAXPROCS [timestamp, GOMAXPROCS, stack id] EvProcStart Type = 5 // start of P [timestamp, thread id] EvProcStop Type = 6 // stop of P [timestamp] EvGCStart Type = 7 // GC start [timestamp, seq, stack id] EvGCDone Type = 8 // GC done [timestamp] EvGCSTWStart Type = 9 // GC mark termination start [timestamp, kind] EvGCSTWDone Type = 10 // GC mark termination done [timestamp] EvGCSweepStart Type = 11 // GC sweep start [timestamp, stack id] EvGCSweepDone Type = 12 // GC sweep done [timestamp] EvGoCreate Type = 13 // goroutine creation [timestamp, new goroutine id, new stack id, stack id] EvGoStart Type = 14 // goroutine starts running [timestamp, goroutine id, seq] EvGoEnd Type = 15 // goroutine ends [timestamp] EvGoStop Type = 16 // goroutine stops (like in select{}) [timestamp, stack] EvGoSched Type = 17 // goroutine calls Gosched [timestamp, stack] EvGoPreempt Type = 18 // goroutine is preempted [timestamp, stack] EvGoSleep Type = 19 // goroutine calls Sleep [timestamp, stack] EvGoBlock Type = 20 // goroutine blocks [timestamp, stack] EvGoUnblock Type = 21 // goroutine is unblocked [timestamp, goroutine id, seq, stack] EvGoBlockSend Type = 22 // goroutine blocks on chan send [timestamp, stack] EvGoBlockRecv Type = 23 // goroutine blocks on chan recv [timestamp, stack] EvGoBlockSelect Type = 24 // goroutine blocks on select [timestamp, stack] EvGoBlockSync Type = 25 // goroutine blocks on Mutex/RWMutex [timestamp, stack] EvGoBlockCond Type = 26 // goroutine blocks on Cond [timestamp, stack] EvGoBlockNet Type = 27 // goroutine blocks on network [timestamp, stack] EvGoSysCall Type = 28 // syscall enter [timestamp, stack] EvGoSysExit Type = 29 // syscall exit [timestamp, goroutine id, seq, real timestamp] EvGoSysBlock Type = 30 // syscall blocks [timestamp] EvGoWaiting Type = 31 // denotes that goroutine is blocked when tracing starts [timestamp, goroutine id] EvGoInSyscall Type = 32 // denotes that goroutine is in syscall when tracing starts [timestamp, goroutine id] EvHeapAlloc Type = 33 // memstats.heap_live change [timestamp, heap_alloc] EvNextGC Type = 34 // memstats.next_gc change [timestamp, next_gc] EvTimerGoroutine Type = 35 // denotes timer goroutine [timer goroutine id] EvFutileWakeup Type = 36 // denotes that the previous wakeup of this goroutine was futile [timestamp] EvString Type = 37 // string dictionary entry [ID, length, string] EvGoStartLocal Type = 38 // goroutine starts running on the same P as the last event [timestamp, goroutine id] EvGoUnblockLocal Type = 39 // goroutine is unblocked on the same P as the last event [timestamp, goroutine id, stack] EvGoSysExitLocal Type = 40 // syscall exit on the same P as the last event [timestamp, goroutine id, real timestamp] EvGoStartLabel Type = 41 // goroutine starts running with label [timestamp, goroutine id, seq, label string id] EvGoBlockGC Type = 42 // goroutine blocks on GC assist [timestamp, stack] EvGCMarkAssistStart Type = 43 // GC mark assist start [timestamp, stack] EvGCMarkAssistDone Type = 44 // GC mark assist done [timestamp] EvCount Type = 45 )
These are the types of events that may be emitted. They are copied directly from the runtime/trace.go source file.
func (Type) Arg ¶
Arg returns the arg index and a boolean true, or -1 and false if arg does not exist in this event type.
type Version ¶
type Version byte
Version of Go declared in the header of the trace. Each version is represented in constant declarations with comments mentioning the associated Go version.
const ( // Version1 was released in Go version 1.5 - 2015/08/19 Version1 Version = 1 // Version2 was released in Go version 1.7 - 2016/08/15 Version2 Version = 2 // Version3 was released in Go version 1.8 - 2017/02/16 Version3 Version = 3 // Version4 is in tip, currently marked in the header as 1.9. Version4 Version = 4 // Latest always points to the newest released version for convenience. Latest = Version4 )