Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeginProfile

func BeginProfile(rootFnName string)

    BeginProfile creates a new profile.

    func EndProfile

    func EndProfile()

      EndProfile finalizes and ships a currently active profile.

      func Enter

      func Enter(fnName string)

        Enter adds a new nested function call to the profile linked to the current go-routine ID.

        func Init

        func Init(sink Sink, capturedProfileLabel string)

          Init handles the initialization of the prism profiler. This method must be called before invoking any other method from this package.

          func Leave

          func Leave()

            Leave exits the current function in the profile linked to the current go-routine ID.

            func Shutdown

            func Shutdown()

              Shutdown waits for shippers to fully dequeue any buffered profiles and shuts them down. This method should be called by main() before the program exits to ensure that no profile data is lost if the program executes too fast.

              Types

              type CallMetrics

              type CallMetrics struct {
              	FnName string `json:"fn"`
              
              	// Total time spent in this call.
              	TotalTime time.Duration `json:"total_time"`
              
              	// Min and max time.
              	MinTime time.Duration `json:"min_time"`
              	MaxTime time.Duration `json:"max_time"`
              
              	// Mean and median time.
              	MeanTime   time.Duration `json:"mean_time"`
              	MedianTime time.Duration `json:"median_time"`
              
              	// Percentiles.
              	P50Time time.Duration `json:"p50_time"`
              	P75Time time.Duration `json:"p75_time"`
              	P90Time time.Duration `json:"p90_time"`
              	P99Time time.Duration `json:"p99_time"`
              
              	// Std of time valus.
              	StdDev float64 `json:"std_dev"`
              
              	// The number of times a scope was entered by the same parent function call.
              	Invocations int `json:"invocations"`
              
              	NestedCalls []*CallMetrics `json:"calls"`
              }

                CallMetrics encapsulates all collected metrics about a function call that is reachable by a profile target.

                type Profile

                type Profile struct {
                	ID        uint64    `json:"-"`
                	CreatedAt time.Time `json:"-"`
                
                	Label  string       `json:"label"`
                	Target *CallMetrics `json:"target"`
                }

                  Profile wraps the processed metrics for a particular execution of a prism-hooked target.

                  type Sink

                  type Sink interface {
                  	// Initialize the sink input channel with the specified buffer capacity.
                  	Open(inputBufferSize int) error
                  
                  	// Shutdown the sink.
                  	Close() error
                  
                  	// Get a channel for piping profile entries to the sink.
                  	Input() chan<- *Profile
                  }

                    Sink defines an interface for processing profile entries emitted by the profiler.

                    Directories

                    Path Synopsis