profiling

package
v0.0.0-...-19dc864 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBytes

func FormatBytes(bytes int64) string

FormatBytes formats bytes to human readable format

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats duration to human readable format

Types

type FunctionMetrics

type FunctionMetrics struct {
	FunctionDuration *prometheus.HistogramVec
	FunctionCalls    *prometheus.CounterVec
	FunctionErrors   *prometheus.CounterVec
	FunctionMemory   *prometheus.HistogramVec
	Goroutines       prometheus.Gauge
	HeapAlloc        prometheus.Gauge
	HeapSys          prometheus.Gauge
	HeapIdle         prometheus.Gauge
	HeapInuse        prometheus.Gauge
	HeapReleased     prometheus.Gauge
	HeapObjects      prometheus.Gauge
}

FunctionMetrics holds Prometheus metrics for function monitoring

type FunctionProfile

type FunctionProfile struct {
	Name          string
	CallCount     int64
	TotalDuration time.Duration
	MaxDuration   time.Duration
	MinDuration   time.Duration
	AvgDuration   time.Duration
	TotalMemory   int64
	MaxMemory     int64
	LastCallTime  time.Time
	ErrorCount    int64
	// contains filtered or unexported fields
}

FunctionProfile tracks resource usage for a specific function

type Profiler

type Profiler struct {
	// contains filtered or unexported fields
}

Profiler provides comprehensive function-level resource monitoring

func NewProfiler

func NewProfiler(logger zerolog.Logger, enabled bool, debugPath string) *Profiler

NewProfiler creates a new profiler instance

func (*Profiler) GetAllProfiles

func (p *Profiler) GetAllProfiles() map[string]*FunctionProfile

GetAllProfiles returns all function profiles

func (*Profiler) GetFunctionProfile

func (p *Profiler) GetFunctionProfile(functionName string) *FunctionProfile

GetFunctionProfile returns profile for a specific function

func (*Profiler) GetMemoryProfile

func (p *Profiler) GetMemoryProfile(w http.ResponseWriter, r *http.Request)

GetMemoryProfile returns memory profile

func (*Profiler) ProfileFunction

func (p *Profiler) ProfileFunction(functionName, packageName string, fn func() error) error

ProfileFunction wraps a function to track its performance

func (*Profiler) ProfileFunctionWithContext

func (p *Profiler) ProfileFunctionWithContext(ctx context.Context, functionName, packageName string, fn func(context.Context) error) error

ProfileFunctionWithContext wraps a function with context

func (*Profiler) SetupRoutes

func (p *Profiler) SetupRoutes(router *gin.Engine)

SetupRoutes sets up profiling and monitoring routes

func (*Profiler) StartCPUProfile

func (p *Profiler) StartCPUProfile(w http.ResponseWriter, r *http.Request)

StartCPUProfile starts CPU profiling

Jump to

Keyboard shortcuts

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