tracker

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregateCaseStats added in v1.1.0

func AggregateCaseStats(caseStats []*sharedtypes.CaseJSON) map[string]*sharedtypes.CaseJSON

AggregateCaseStats combines statistics for cases with the same name

func FileExists added in v1.1.1

func FileExists(path string) bool

func GetMaxValue added in v1.1.0

func GetMaxValue(stats []*sharedtypes.CaseJSON, visType sharedtypes.VisualizationType) float64

GetMaxValue returns the maximum value for the given visualization type

func GetValueForCase added in v1.1.0

func GetValueForCase(stat *sharedtypes.CaseJSON, visType sharedtypes.VisualizationType) float64

GetValueForCase returns the value for a case based on the visualization type

func PrintAndSaveStatsJSON added in v1.0.7

func PrintAndSaveStatsJSON(stats map[GoroutineId]*GoroutineStats, title string)

PrintAndSaveStatsJSON prints and saves goroutine performance statistics as JSON

func PrintAndSaveStatsText added in v1.0.7

func PrintAndSaveStatsText(stats map[GoroutineId]*GoroutineStats, title string)

PrintStats prints a summary of goroutine performance statistics

func PrintBlockedTimeHistogram added in v1.1.2

func PrintBlockedTimeHistogram(stats map[GoroutineId]*GoroutineStats, title string)

func PrintStatsJSON added in v1.1.0

func PrintStatsJSON(stats map[GoroutineId]*GoroutineStats, title string)

PrintStatsJSON prints goroutine performance statistics as JSON to stdout

func PrintStatsText added in v1.1.0

func PrintStatsText(stats map[GoroutineId]*GoroutineStats, title string)

PrintStatsText prints a summary of goroutine performance statistics to stdout

func SaveStatsJSON added in v1.0.7

func SaveStatsJSON(stats map[GoroutineId]*GoroutineStats, title string) error

SaveStats saves goroutine performance statistics to a JSON file in a directory named after the stage

func SaveStatsText added in v1.0.7

func SaveStatsText(stats map[GoroutineId]*GoroutineStats, title string)

SaveStatsText saves a summary of goroutine performance statistics to a text file

func SortCaseStats added in v1.1.0

func SortCaseStats(stats []*sharedtypes.CaseJSON, visType sharedtypes.VisualizationType)

SortCaseStats sorts the aggregated statistics based on the visualization type

func WriteBlockedTimeHistogramDot added in v1.1.5

func WriteBlockedTimeHistogramDot(stats map[GoroutineId]*GoroutineStats, stageName string) error

WriteBlockedTimeHistogramDot writes the blocked time histogram DOT graph to a file named "<stageName>.dot"

Types

type Action added in v1.1.0

type Action string
const (
	PrintAndSave Action = "print_and_save"
	Save         Action = "save"
	Print        Action = "print"
	None         Action = "none"
)

type CaseJSON added in v1.0.4

type CaseJSON struct {
	Hits             int64         `json:"hits"`
	TotalBlockedTime time.Duration `json:"total_blocked_time"`
	AvgBlockedTime   time.Duration `json:"average_blocked_time,omitempty"`
	Percentile90     time.Duration `json:"percentile_90,omitempty"`
	Percentile99     time.Duration `json:"percentile_99,omitempty"`
}

CaseJSON represents statistics for a single select case in JSON format

type GoroutineId

type GoroutineId int

GoroutineManager manages statistics for multiple goroutines

type GoroutineJSON added in v1.0.4

type GoroutineJSON struct {
	Lifetime        time.Duration       `json:"lifetime"`
	TotalSelectTime time.Duration       `json:"total_select_blocked_time"`
	SelectCaseStats map[string]CaseJSON `json:"select_case_statistics"`
}

GoroutineJSON represents a single goroutine's statistics in JSON format

type GoroutineManager

type GoroutineManager struct {
	Stats map[GoroutineId]*GoroutineStats

	Wg       *sync.WaitGroup
	FileType string // text or json
	Action   Action
	// contains filtered or unexported fields
}

func NewGoroutineManager

func NewGoroutineManager() *GoroutineManager

NewGoroutineManager creates a new goroutine statistics manager

func (*GoroutineManager) Done added in v1.0.7

func (gm *GoroutineManager) Done() error

Done waits for all goroutines to finish and then saves the final stats

func (*GoroutineManager) GetAllStats

func (gm *GoroutineManager) GetAllStats() map[GoroutineId]*GoroutineStats

GetAllStats returns statistics for all goroutines

func (*GoroutineManager) GetGoroutineStats

func (gm *GoroutineManager) GetGoroutineStats(id GoroutineId) *GoroutineStats

GetGoroutineStats returns statistics for a specific goroutine

func (*GoroutineManager) TrackGoroutineEnd

func (gm *GoroutineManager) TrackGoroutineEnd(id GoroutineId)

TrackGoroutineEnd records the end of a goroutine

func (*GoroutineManager) TrackGoroutineStart

func (gm *GoroutineManager) TrackGoroutineStart() GoroutineId

TrackGoroutineStart records the start of a goroutine tracking

func (*GoroutineManager) TrackSelectCase

func (gm *GoroutineManager) TrackSelectCase(caseName string, duration time.Duration, id GoroutineId)

TrackSelectCase records statistics for a select case

type GoroutineStats

type GoroutineStats struct {
	GoroutineId GoroutineId
	SelectStats map[string]*SelectStats
	StartTime   time.Time
	EndTime     time.Time
}

GoroutineStats holds statistics for a single goroutine

func (*GoroutineStats) GetGoroutineLifetime

func (gs *GoroutineStats) GetGoroutineLifetime() time.Duration

GetGoroutineLifetime returns the lifetime duration of a goroutine

func (*GoroutineStats) GetSelectCaseStats

func (gs *GoroutineStats) GetSelectCaseStats(caseName string) *SelectStats

GetSelectCaseStats returns statistics for a specific select case

func (*GoroutineStats) GetSelectStats

func (gs *GoroutineStats) GetSelectStats() map[string]*SelectStats

GetSelectStats returns a map of select case statistics

func (*GoroutineStats) GetTotalSelectBlockedTime added in v1.1.1

func (gs *GoroutineStats) GetTotalSelectBlockedTime() time.Duration

GetTotalSelectTime returns the total time spent in select cases for a goroutine

type JSONStats added in v1.0.4

type JSONStats struct {
	Title      string                   `json:"title"`
	Goroutines map[string]GoroutineJSON `json:"goroutines"`
}

JSONStats represents the complete statistics structure for JSON output

type SelectStats

type SelectStats struct {
	// how long the case was blocked
	BlockedCaseTime time.Duration
	// how many times the case was hit
	CaseHits int
	// contains filtered or unexported fields
}

SelectStats holds statistics for a select case

func (*SelectStats) AddLatency

func (s *SelectStats) AddLatency(latency time.Duration)

AddLatency adds a new latency measurement to the stats

func (*SelectStats) GetAverage added in v1.1.1

func (ss *SelectStats) GetAverage() time.Duration

Get Average

func (*SelectStats) GetCaseHits

func (ss *SelectStats) GetCaseHits() int

GetCaseHits returns the number of times this case was hit

func (*SelectStats) GetCaseTime

func (ss *SelectStats) GetCaseTime() time.Duration

GetCaseTime returns the total time spent in this case

func (*SelectStats) GetPercentile

func (s *SelectStats) GetPercentile(n float64) time.Duration

GetPercentile returns the nth percentile latency

type VisualizationType added in v1.1.0

type VisualizationType int

VisualizationType represents the type of visualization to use

const (
	TotalBlockedTime VisualizationType = iota
	AverageTime
	Percentile90
	Percentile99
	TotalHits
)

func (VisualizationType) String added in v1.1.0

func (vt VisualizationType) String() string

Jump to

Keyboard shortcuts

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