package traceviewer
import "internal/trace/traceviewer"
Index
- Constants
- func BuildProfile(prof []ProfileRecord) *profile.Profile
- func MMUHandlerFunc(ranges []Range, f MutatorUtilFunc) http.HandlerFunc
- func MainHandler(views []View) http.Handler
- func SVGProfileHandlerFunc(f ProfileFunc) http.HandlerFunc
- func StaticHandler() http.Handler
- func TraceHandler() http.Handler
- func WalkStackFrames(allFrames map[string]format.Frame, id int, fn func(id int))
- type ArrowEvent
- type AsyncSliceEvent
-
type Emitter
- func NewEmitter(c TraceConsumer, rangeStart, rangeEnd time.Duration) *Emitter
- func (e *Emitter) Arrow(a ArrowEvent)
- func (e *Emitter) AsyncSlice(s AsyncSliceEvent)
- func (e *Emitter) Err() error
- func (e *Emitter) Event(ev *format.Event)
- func (e *Emitter) Flush()
- func (e *Emitter) Focus(id uint64)
- func (e *Emitter) Gomaxprocs(v uint64)
- func (e *Emitter) GoroutineTransition(ts time.Duration, from, to GState)
- func (e *Emitter) HeapAlloc(ts time.Duration, v uint64)
- func (e *Emitter) HeapGoal(ts time.Duration, v uint64)
- func (e *Emitter) IncThreadStateCount(ts time.Duration, state ThreadState, delta int64)
- func (e *Emitter) Instant(i InstantEvent)
- func (e *Emitter) OptionalEvent(ev *format.Event)
- func (e *Emitter) Resource(id uint64, name string)
- func (e *Emitter) SetResourceFilter(filter func(uint64) bool)
- func (e *Emitter) SetResourceType(name string)
- func (e *Emitter) Slice(s SliceEvent)
- func (e *Emitter) Stack(stk []*trace.Frame) int
- func (e *Emitter) Task(id uint64, name string, sortIndex int)
- func (e *Emitter) TaskArrow(a ArrowEvent)
- func (e *Emitter) TaskSlice(s SliceEvent)
- type GState
- type InstantEvent
- type Mode
- type MutatorUtilFunc
- type ProfileFunc
- type ProfileRecord
- type Range
- type SliceEvent
- type ThreadState
- type TimeHistogram
- type TraceConsumer
- type View
- type ViewType
Constants
const CommonStyle = ` /* See https://github.com/golang/pkgsite/blob/master/static/shared/typography/typography.css */ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'; font-size: 1rem; line-height: normal; max-width: 9in; margin: 1em; } h1 { font-size: 1.5rem; } h2 { font-size: 1.375rem; } h1,h2 { font-weight: 600; line-height: 1.25em; word-break: break-word; } p { color: grey85; font-size:85%; } code, pre, textarea.code { font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace; font-size: 0.875rem; line-height: 1.5em; } pre, textarea.code { background-color: var(--color-background-accented); border: var(--border); border-radius: var(--border-radius); color: var(--color-text); overflow-x: auto; padding: 0.625rem; tab-size: 4; white-space: pre; } `
Functions
func BuildProfile
func BuildProfile(prof []ProfileRecord) *profile.Profile
func MMUHandlerFunc
func MMUHandlerFunc(ranges []Range, f MutatorUtilFunc) http.HandlerFunc
func MainHandler
func MainHandler(views []View) http.Handler
func SVGProfileHandlerFunc
func SVGProfileHandlerFunc(f ProfileFunc) http.HandlerFunc
SVGProfileHandlerFunc serves pprof-like profile generated by prof as svg.
func StaticHandler
func StaticHandler() http.Handler
func TraceHandler
func TraceHandler() http.Handler
func WalkStackFrames
func WalkStackFrames(allFrames map[string]format.Frame, id int, fn func(id int))
WalkStackFrames calls fn for id and all of its parent frames from allFrames.
Types
type ArrowEvent
type ArrowEvent struct { Name string Start time.Duration End time.Duration FromResource uint64 FromStack int ToResource uint64 }
type AsyncSliceEvent
type AsyncSliceEvent struct { SliceEvent Category string Scope string TaskColorIndex uint64 // Take on the same color as the task with this ID. }
type Emitter
type Emitter struct { // contains filtered or unexported fields }
func NewEmitter
func NewEmitter(c TraceConsumer, rangeStart, rangeEnd time.Duration) *Emitter
NewEmitter returns a new Emitter that writes to c. The rangeStart and rangeEnd args are used for splitting large traces.
func (*Emitter) Arrow
func (e *Emitter) Arrow(a ArrowEvent)
func (*Emitter) AsyncSlice
func (e *Emitter) AsyncSlice(s AsyncSliceEvent)
func (*Emitter) Err
func (e *Emitter) Err() error
Err returns an error if the emitter is in an invalid state.
func (*Emitter) Event
func (e *Emitter) Event(ev *format.Event)
func (*Emitter) Flush
func (e *Emitter) Flush()
func (*Emitter) Focus
func (e *Emitter) Focus(id uint64)
func (*Emitter) Gomaxprocs
func (e *Emitter) Gomaxprocs(v uint64)
func (*Emitter) GoroutineTransition
func (e *Emitter) GoroutineTransition(ts time.Duration, from, to GState)
func (*Emitter) HeapAlloc
func (e *Emitter) HeapAlloc(ts time.Duration, v uint64)
func (*Emitter) HeapGoal
func (e *Emitter) HeapGoal(ts time.Duration, v uint64)
func (*Emitter) IncThreadStateCount
func (e *Emitter) IncThreadStateCount(ts time.Duration, state ThreadState, delta int64)
func (*Emitter) Instant
func (e *Emitter) Instant(i InstantEvent)
func (*Emitter) OptionalEvent
func (e *Emitter) OptionalEvent(ev *format.Event)
OptionalEvent emits ev if it's within the time range of of the consumer, i.e. the selected trace split range.
func (*Emitter) Resource
func (e *Emitter) Resource(id uint64, name string)
func (*Emitter) SetResourceFilter
func (e *Emitter) SetResourceFilter(filter func(uint64) bool)
func (*Emitter) SetResourceType
func (e *Emitter) SetResourceType(name string)
func (*Emitter) Slice
func (e *Emitter) Slice(s SliceEvent)
func (*Emitter) Stack
func (e *Emitter) Stack(stk []*trace.Frame) int
Stack emits the given frames and returns a unique id for the stack. No pointers to the given data are being retained beyond the call to Stack.
func (*Emitter) Task
func (e *Emitter) Task(id uint64, name string, sortIndex int)
func (*Emitter) TaskArrow
func (e *Emitter) TaskArrow(a ArrowEvent)
func (*Emitter) TaskSlice
func (e *Emitter) TaskSlice(s SliceEvent)
type GState
type GState int
const ( GDead GState = iota GRunnable GRunning GWaiting GWaitingGC )
type InstantEvent
type InstantEvent struct { Ts time.Duration Name string Category string Resource uint64 Stack int Arg any }
type Mode
type Mode int
const ( ModeGoroutineOriented Mode = 1 << iota ModeTaskOriented ModeThreadOriented // Mutually exclusive with ModeGoroutineOriented. )
type MutatorUtilFunc
type MutatorUtilFunc func(trace.UtilFlags) ([][]trace.MutatorUtil, error)
type ProfileFunc
type ProfileFunc func(r *http.Request) ([]ProfileRecord, error)
type ProfileRecord
type ProfileRecord struct { Stack []*trace.Frame Count uint64 Time time.Duration }
type Range
type Range struct { Name string Start int End int StartTime int64 EndTime int64 }
func (Range) URL
func (r Range) URL(viewType ViewType) string
type SliceEvent
type SliceEvent struct { Name string Ts time.Duration Dur time.Duration Resource uint64 Stack int EndStack int Arg any }
type ThreadState
type ThreadState int
const ( ThreadStateInSyscall ThreadState = iota ThreadStateInSyscallRuntime ThreadStateRunning )
type TimeHistogram
type TimeHistogram struct { Count int Buckets []int MinBucket, MaxBucket int }
TimeHistogram is an high-dynamic-range histogram for durations.
func (*TimeHistogram) Add
func (h *TimeHistogram) Add(d time.Duration)
Add adds a single sample to the histogram.
func (*TimeHistogram) BucketMin
func (h *TimeHistogram) BucketMin(bucket int) time.Duration
BucketMin returns the minimum duration value for a provided bucket.
func (*TimeHistogram) ToHTML
func (h *TimeHistogram) ToHTML(urlmaker func(min, max time.Duration) string) template.HTML
ToHTML renders the histogram as HTML.
type TraceConsumer
type TraceConsumer struct { ConsumeTimeUnit func(unit string) ConsumeViewerEvent func(v *format.Event, required bool) ConsumeViewerFrame func(key string, f format.Frame) Flush func() }
func SplittingTraceConsumer
func SplittingTraceConsumer(max int) (*splitter, TraceConsumer)
func ViewerDataTraceConsumer
func ViewerDataTraceConsumer(w io.Writer, startIdx, endIdx int64) TraceConsumer
ViewerDataTraceConsumer returns a TraceConsumer that writes to w. The startIdx and endIdx are used for splitting large traces. They refer to indexes in the traceEvents output array, not the events in the trace input.
type View
type View struct { Type ViewType Ranges []Range }
func (View) URL
func (v View) URL(rangeIdx int) string
type ViewType
type ViewType string
const ( ViewProc ViewType = "proc" ViewThread ViewType = "thread" )
Directories
format | Package traceviewer provides definitions of the JSON data structures used by the Chrome trace viewer. |