Documentation
¶
Index ¶
- func FormatBytes(bytes int64) string
- func FormatDuration(d time.Duration) string
- type FunctionMetrics
- type FunctionProfile
- type Profiler
- func (p *Profiler) GetAllProfiles() map[string]*FunctionProfile
- func (p *Profiler) GetFunctionProfile(functionName string) *FunctionProfile
- func (p *Profiler) GetMemoryProfile(w http.ResponseWriter, r *http.Request)
- func (p *Profiler) ProfileFunction(functionName, packageName string, fn func() error) error
- func (p *Profiler) ProfileFunctionWithContext(ctx context.Context, functionName, packageName string, ...) error
- func (p *Profiler) SetupRoutes(router *gin.Engine)
- func (p *Profiler) StartCPUProfile(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatBytes ¶
FormatBytes formats bytes to human readable format
func FormatDuration ¶
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 ¶
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 ¶
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 ¶
SetupRoutes sets up profiling and monitoring routes
func (*Profiler) StartCPUProfile ¶
func (p *Profiler) StartCPUProfile(w http.ResponseWriter, r *http.Request)
StartCPUProfile starts CPU profiling