Documentation
¶
Index ¶
- func ProfileGlobalDecryption(ctx context.Context, operationName string, dataSize int64, ...) error
- func ProfileGlobalEncryption(ctx context.Context, operationName string, dataSize int64, ...) error
- func ProfileGlobalHashing(ctx context.Context, operationName string, dataSize int64, ...) error
- func ProfileGlobalKeyOperation(ctx context.Context, operationName string, operation func() error) error
- func ProfileGlobalOperation(ctx context.Context, operationName string, operation func() error) error
- func RegisterPprofHandlers(mux *http.ServeMux)
- func StartGlobalProfiling(ctx context.Context) error
- func StopGlobalProfiling(ctx context.Context) error
- type CryptoMetricsReport
- type CryptoProfiler
- func (cp *CryptoProfiler) GetAllMetrics() CryptoMetricsReport
- func (cp *CryptoProfiler) GetDecryptionMetrics() map[string]*OperationMetrics
- func (cp *CryptoProfiler) GetEncryptionMetrics() map[string]*OperationMetrics
- func (cp *CryptoProfiler) GetHashingMetrics() map[string]*OperationMetrics
- func (cp *CryptoProfiler) GetKeyMetrics() map[string]*OperationMetrics
- func (cp *CryptoProfiler) GetMemoryIntensiveOperations(n int) []MemoryOperationInfo
- func (cp *CryptoProfiler) GetTopSlowOperations(n int) []SlowOperationInfo
- func (cp *CryptoProfiler) ProfileDecryption(ctx context.Context, operationName string, dataSize int64, ...) error
- func (cp *CryptoProfiler) ProfileEncryption(ctx context.Context, operationName string, dataSize int64, ...) error
- func (cp *CryptoProfiler) ProfileHashing(ctx context.Context, operationName string, dataSize int64, ...) error
- func (cp *CryptoProfiler) ProfileKeyOperation(ctx context.Context, operationName string, operation func() error) error
- func (cp *CryptoProfiler) ResetMetrics()
- type CryptoProfilingConfig
- type MemoryOperationInfo
- type OperationMetrics
- type ProfileSession
- type ProfileThresholds
- type ProfileType
- type Profiler
- func (p *Profiler) GetActiveProfiles() map[ProfileType]*ProfileSession
- func (p *Profiler) GetProfileHistory() map[ProfileType]*ProfileSession
- func (p *Profiler) GetStats() ProfilerStats
- func (p *Profiler) ProfileOperation(ctx context.Context, operationName string, operation func() error) error
- func (p *Profiler) Start(ctx context.Context) error
- func (p *Profiler) StartProfile(profileType ProfileType) error
- func (p *Profiler) Stop(ctx context.Context) error
- func (p *Profiler) StopProfile(profileType ProfileType) error
- type ProfilerStats
- type ProfilingConfig
- type SlowOperationInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProfileGlobalDecryption ¶
func ProfileGlobalDecryption(ctx context.Context, operationName string, dataSize int64, operation func() error) error
ProfileGlobalDecryption profiles a decryption operation using the global crypto profiler
func ProfileGlobalEncryption ¶
func ProfileGlobalEncryption(ctx context.Context, operationName string, dataSize int64, operation func() error) error
ProfileGlobalEncryption profiles an encryption operation using the global crypto profiler
func ProfileGlobalHashing ¶
func ProfileGlobalHashing(ctx context.Context, operationName string, dataSize int64, operation func() error) error
ProfileGlobalHashing profiles a hashing operation using the global crypto profiler
func ProfileGlobalKeyOperation ¶
func ProfileGlobalKeyOperation(ctx context.Context, operationName string, operation func() error) error
ProfileGlobalKeyOperation profiles a key operation using the global crypto profiler
func ProfileGlobalOperation ¶
func ProfileGlobalOperation(ctx context.Context, operationName string, operation func() error) error
ProfileGlobalOperation profiles an operation using the global profiler
func RegisterPprofHandlers ¶
RegisterPprofHandlers registers pprof HTTP handlers for debugging This should ONLY be called when ENABLE_PROFILING environment variable is set to "true" In production, this should never be called to avoid exposing sensitive information
func StartGlobalProfiling ¶
StartGlobalProfiling starts the global profiler
func StopGlobalProfiling ¶
StopGlobalProfiling stops the global profiler
Types ¶
type CryptoMetricsReport ¶
type CryptoMetricsReport struct {
Encryption map[string]*OperationMetrics `json:"encryption"`
Decryption map[string]*OperationMetrics `json:"decryption"`
KeyOperations map[string]*OperationMetrics `json:"key_operations"`
Hashing map[string]*OperationMetrics `json:"hashing"`
Timestamp time.Time `json:"timestamp"`
}
CryptoMetricsReport contains all crypto metrics
type CryptoProfiler ¶
type CryptoProfiler struct {
// contains filtered or unexported fields
}
CryptoProfiler provides crypto-specific performance profiling
func GetGlobalCryptoProfiler ¶
func GetGlobalCryptoProfiler() *CryptoProfiler
GetGlobalCryptoProfiler returns the global crypto profiler instance
func NewCryptoProfiler ¶
func NewCryptoProfiler(profiler *Profiler) *CryptoProfiler
NewCryptoProfiler creates a new crypto profiler
func (*CryptoProfiler) GetAllMetrics ¶
func (cp *CryptoProfiler) GetAllMetrics() CryptoMetricsReport
GetAllMetrics returns all crypto operation metrics
func (*CryptoProfiler) GetDecryptionMetrics ¶
func (cp *CryptoProfiler) GetDecryptionMetrics() map[string]*OperationMetrics
GetDecryptionMetrics returns decryption metrics
func (*CryptoProfiler) GetEncryptionMetrics ¶
func (cp *CryptoProfiler) GetEncryptionMetrics() map[string]*OperationMetrics
GetEncryptionMetrics returns encryption metrics
func (*CryptoProfiler) GetHashingMetrics ¶
func (cp *CryptoProfiler) GetHashingMetrics() map[string]*OperationMetrics
GetHashingMetrics returns hashing metrics
func (*CryptoProfiler) GetKeyMetrics ¶
func (cp *CryptoProfiler) GetKeyMetrics() map[string]*OperationMetrics
GetKeyMetrics returns key operation metrics
func (*CryptoProfiler) GetMemoryIntensiveOperations ¶
func (cp *CryptoProfiler) GetMemoryIntensiveOperations(n int) []MemoryOperationInfo
GetMemoryIntensiveOperations returns operations that use the most memory
func (*CryptoProfiler) GetTopSlowOperations ¶
func (cp *CryptoProfiler) GetTopSlowOperations(n int) []SlowOperationInfo
GetTopSlowOperations returns the top N slowest operations across all categories
func (*CryptoProfiler) ProfileDecryption ¶
func (cp *CryptoProfiler) ProfileDecryption(ctx context.Context, operationName string, dataSize int64, operation func() error) error
ProfileDecryption profiles a decryption operation
func (*CryptoProfiler) ProfileEncryption ¶
func (cp *CryptoProfiler) ProfileEncryption(ctx context.Context, operationName string, dataSize int64, operation func() error) error
ProfileEncryption profiles an encryption operation
func (*CryptoProfiler) ProfileHashing ¶
func (cp *CryptoProfiler) ProfileHashing(ctx context.Context, operationName string, dataSize int64, operation func() error) error
ProfileHashing profiles a hashing operation
func (*CryptoProfiler) ProfileKeyOperation ¶
func (cp *CryptoProfiler) ProfileKeyOperation(ctx context.Context, operationName string, operation func() error) error
ProfileKeyOperation profiles a key management operation
func (*CryptoProfiler) ResetMetrics ¶
func (cp *CryptoProfiler) ResetMetrics()
ResetMetrics resets all crypto operation metrics
type CryptoProfilingConfig ¶
type CryptoProfilingConfig struct {
// Enable profiling for different crypto operations
EnableEncryptionProfiling bool
EnableDecryptionProfiling bool
EnableKeyOperationsProfiling bool
EnableHashingProfiling bool
// Performance thresholds
EncryptionSlowThreshold time.Duration
DecryptionSlowThreshold time.Duration
KeyOperationSlowThreshold time.Duration
HashingSlowThreshold time.Duration
// Memory thresholds for triggering profiling
MemoryAllocationThreshold uint64
// Auto-profiling triggers
AutoProfileSlowOperations bool
AutoProfileHighMemory bool
// Sample rates (0.0 = never, 1.0 = always)
OperationSampleRate float64
MemorySampleRate float64
}
CryptoProfilingConfig holds configuration for crypto profiling
func DefaultCryptoProfilingConfig ¶
func DefaultCryptoProfilingConfig() CryptoProfilingConfig
DefaultCryptoProfilingConfig returns default crypto profiling configuration
type MemoryOperationInfo ¶
type MemoryOperationInfo struct {
Category string `json:"category"`
Name string `json:"name"`
TotalBytes uint64 `json:"total_bytes"`
TotalAllocs uint64 `json:"total_allocs"`
AverageBytes uint64 `json:"average_bytes"`
AverageAllocs uint64 `json:"average_allocs"`
}
MemoryOperationInfo contains information about memory usage of operations
type OperationMetrics ¶
type OperationMetrics struct {
TotalCalls int64 `json:"total_calls"`
TotalDuration time.Duration `json:"total_duration"`
AverageDuration time.Duration `json:"average_duration"`
MinDuration time.Duration `json:"min_duration"`
MaxDuration time.Duration `json:"max_duration"`
ErrorCount int64 `json:"error_count"`
LastCall time.Time `json:"last_call"`
// Memory metrics
TotalAllocs uint64 `json:"total_allocs"`
TotalBytes uint64 `json:"total_bytes"`
// Performance thresholds exceeded
SlowCallsCount int64 `json:"slow_calls_count"`
SlowThreshold time.Duration `json:"slow_threshold"`
}
OperationMetrics tracks metrics for specific crypto operations
type ProfileSession ¶
type ProfileSession struct {
Type ProfileType `json:"type"`
StartTime time.Time `json:"start_time"`
Duration time.Duration `json:"duration"`
FilePath string `json:"file_path,omitempty"`
Active bool `json:"active"`
}
ProfileSession represents an active profiling session
type ProfileThresholds ¶
type ProfileThresholds struct {
// CPUThreshold triggers CPU profiling when CPU usage exceeds this percentage
CPUThreshold float64
// MemoryThreshold triggers memory profiling when memory usage exceeds this (in bytes)
MemoryThreshold uint64
// GoroutineThreshold triggers goroutine profiling when count exceeds this
GoroutineThreshold int
// OperationLatencyThreshold triggers profiling when operations exceed this duration
OperationLatencyThreshold time.Duration
}
ProfileThresholds defines thresholds for automatic profiling
type ProfileType ¶
type ProfileType string
ProfileType represents different types of profiling
const ( ProfileTypeCPU ProfileType = "cpu" ProfileTypeMemory ProfileType = "memory" ProfileTypeGoroutine ProfileType = "goroutine" ProfileTypeBlock ProfileType = "block" ProfileTypeMutex ProfileType = "mutex" ProfileTypeTrace ProfileType = "trace" )
type Profiler ¶
type Profiler struct {
// contains filtered or unexported fields
}
Profiler manages performance profiling for the ENCX library
func GetGlobalProfiler ¶
func GetGlobalProfiler() *Profiler
GetGlobalProfiler returns the global profiler instance
func InitializeGlobalProfiler ¶
func InitializeGlobalProfiler(config ProfilingConfig) *Profiler
InitializeGlobalProfiler initializes the global profiler with custom config
func NewProfiler ¶
func NewProfiler(config ProfilingConfig) *Profiler
NewProfiler creates a new profiler instance
func (*Profiler) GetActiveProfiles ¶
func (p *Profiler) GetActiveProfiles() map[ProfileType]*ProfileSession
GetActiveProfiles returns information about active profiling sessions
func (*Profiler) GetProfileHistory ¶
func (p *Profiler) GetProfileHistory() map[ProfileType]*ProfileSession
GetProfileHistory returns information about all profiling sessions
func (*Profiler) GetStats ¶
func (p *Profiler) GetStats() ProfilerStats
GetStats returns profiling statistics
func (*Profiler) ProfileOperation ¶
func (p *Profiler) ProfileOperation(ctx context.Context, operationName string, operation func() error) error
ProfileOperation profiles a specific operation
func (*Profiler) StartProfile ¶
func (p *Profiler) StartProfile(profileType ProfileType) error
StartProfile starts profiling for a specific type
func (*Profiler) StopProfile ¶
func (p *Profiler) StopProfile(profileType ProfileType) error
StopProfile stops profiling for a specific type
type ProfilerStats ¶
type ProfilerStats struct {
IsRunning bool `json:"is_running"`
ActiveProfiles int `json:"active_profiles"`
TotalSessions int `json:"total_sessions"`
OperationCount int64 `json:"operation_count"`
AverageLatency time.Duration `json:"average_latency"`
ProfileTriggers map[string]int64 `json:"profile_triggers"`
HTTPEndpoint string `json:"http_endpoint"`
}
ProfilerStats contains statistics about the profiler
type ProfilingConfig ¶
type ProfilingConfig struct {
// EnableCPUProfiling enables CPU profiling
EnableCPUProfiling bool
// EnableMemoryProfiling enables memory profiling
EnableMemoryProfiling bool
// EnableBlockProfiling enables block profiling
EnableBlockProfiling bool
// EnableMutexProfiling enables mutex profiling
EnableMutexProfiling bool
// SampleRate for profiling (0 = default, 1 = all operations)
SampleRate int
// ProfileDuration for timed profiles
ProfileDuration time.Duration
// OutputDir for profile files
OutputDir string
// HTTPEndpoint enables pprof HTTP endpoint
HTTPEndpoint string
// AutoProfile enables automatic profiling triggers
AutoProfile bool
// ProfileThresholds for automatic profiling
ProfileThresholds ProfileThresholds
}
ProfilingConfig holds configuration for performance profiling
func DefaultProfilingConfig ¶
func DefaultProfilingConfig() ProfilingConfig
DefaultProfilingConfig returns a default profiling configuration
type SlowOperationInfo ¶
type SlowOperationInfo struct {
Category string `json:"category"`
Name string `json:"name"`
AverageDuration time.Duration `json:"average_duration"`
MaxDuration time.Duration `json:"max_duration"`
SlowCallsCount int64 `json:"slow_calls_count"`
TotalCalls int64 `json:"total_calls"`
}
SlowOperationInfo contains information about slow operations