profiler

package
v2.11.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEdgeMetricValue

func GetEdgeMetricValue(e *EdgeRow, metric string) int64

GetEdgeMetricValue returns the cost value for the given metric on an edge.

func GetEdgePercent

func GetEdgePercent(e *EdgeRow, metric string) float64

GetEdgePercent returns the percentage value for the given metric on an edge.

func GetFuncMetric

func GetFuncMetric(f *FuncStats, metric string) int64

GetFuncMetric returns the value of the specified metric for a function.

func SortFunctions

func SortFunctions(funcs []FuncStats, metric string)

SortFunctions sorts function stats by the given metric in descending order.

Types

type Diffs

type Diffs struct {
	WallTime int64 `json:"d_wt"`
	CPU      int64 `json:"d_cpu"`
	Memory   int64 `json:"d_mu"`
	PeakMem  int64 `json:"d_pmu"`
	Calls    int64 `json:"d_ct"`
}

Diffs (exclusive metrics).

type Edge

type Edge struct {
	ID       string      `json:"id"`
	Caller   *string     `json:"caller"`
	Callee   string      `json:"callee"`
	Cost     Metrics     `json:"cost"`
	Diff     Diffs       `json:"diff"`
	Percents Percentages `json:"percents"`
	Parent   *string     `json:"parent"`
}

Edge represents a processed caller→callee relationship.

type EdgeRow

type EdgeRow struct {
	UUID       string
	Callee     string
	Caller     *string
	ParentUUID *string
	Cost       Metrics
	Diff       Diffs
	Percents   Percentages
}

EdgeRow represents a processed caller→callee relationship from the database.

func LoadAllEdges

func LoadAllEdges(db *sql.DB, profileUUID string) ([]EdgeRow, error)

LoadAllEdges loads all edges for a profile from the database.

type FuncStats

type FuncStats struct {
	Callee                                   string
	Ct, CPU, Wt, Mu, Pmu                     int64
	ExclCPU, ExclWt, ExclMu, ExclPmu, ExclCt int64
	PCPU, PWt, PMu, PPmu                     float64
	PExclCPU, PExclWt, PExclMu, PExclPmu     float64
}

FuncStats holds aggregated statistics for a function.

func AggregateFunctions

func AggregateFunctions(edges []EdgeRow, peaks Metrics) []FuncStats

AggregateFunctions aggregates edge data into per-function statistics.

func (*FuncStats) ToMap

func (f *FuncStats) ToMap() map[string]any

ToMap converts FuncStats to a map representation.

type IncomingProfile

type IncomingProfile struct {
	Profile  map[string]Metrics `json:"profile"`
	AppName  string             `json:"app_name"`
	Hostname string             `json:"hostname"`
	Date     int64              `json:"date"`
	Tags     map[string]any     `json:"tags,omitempty"`
}

IncomingProfile is the raw XHProf payload.

type Metrics

type Metrics struct {
	WallTime int64 `json:"wt"`
	CPU      int64 `json:"cpu"`
	Memory   int64 `json:"mu"`
	PeakMem  int64 `json:"pmu"`
	Calls    int64 `json:"ct"`
}

Metrics holds XHProf metric values.

func LoadPeaks

func LoadPeaks(db *sql.DB, uuid string) (Metrics, string, error)

LoadPeaks loads the peak metrics and name for a profile.

func Process

func Process(incoming *IncomingProfile) (peaks Metrics, edges map[string]Edge)

Process takes raw XHProf data and produces processed edges with diffs/percentages.

type Module

type Module struct {
	module.BaseModule
	// contains filtered or unexported fields
}

func New

func New() *Module

func (*Module) HTTPHandler

func (m *Module) HTTPHandler() module.HTTPIngestionHandler

func (*Module) Name

func (m *Module) Name() string

func (*Module) OnEventStored

func (m *Module) OnEventStored(ev event.Event)

func (*Module) OnInit

func (m *Module) OnInit(db *sql.DB) error

func (*Module) PreviewMapper

func (m *Module) PreviewMapper() event.PreviewMapper

func (*Module) RegisterMigrations

func (m *Module) RegisterMigrations(migrator *storage.Migrator) error

func (*Module) RegisterProtectedRoutes

func (m *Module) RegisterProtectedRoutes(mux *http.ServeMux, protect func(http.Handler) http.Handler)

RegisterProtectedRoutes adds the profiler UI API behind the API auth.

func (*Module) Type

func (m *Module) Type() string

type Percentages

type Percentages struct {
	WallTime float64 `json:"p_wt"`
	CPU      float64 `json:"p_cpu"`
	Memory   float64 `json:"p_mu"`
	PeakMem  float64 `json:"p_pmu"`
	Calls    float64 `json:"p_ct"`
}

Percentages of peak values.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL