Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrDataRefused will be returned to callers of ConsumeTraceData to indicate // that data is being refused due to high memory usage. ErrDataRefused = errors.New("data refused due to high memory usage") // ErrShutdownNotStarted indicates no memorylimiter has not start when shutdown ErrShutdownNotStarted = errors.New("no existing monitoring routine is running") // GetMemoryFn and ReadMemStatsFn make it overridable by tests GetMemoryFn = iruntime.TotalMemory ReadMemStatsFn = runtime.ReadMemStats )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // CheckInterval is the time between measurements of memory usage for the // purposes of avoiding going over the limits. Defaults to zero, so no // checks will be performed. CheckInterval time.Duration `mapstructure:"check_interval"` // MemoryLimitMiB is the maximum amount of memory, in MiB, targeted to be // allocated by the process. MemoryLimitMiB uint32 `mapstructure:"limit_mib"` // MemorySpikeLimitMiB is the maximum, in MiB, spike expected between the // measurements of memory usage. MemorySpikeLimitMiB uint32 `mapstructure:"spike_limit_mib"` // MemoryLimitPercentage is the maximum amount of memory, in %, targeted to be // allocated by the process. The fixed memory settings MemoryLimitMiB has a higher precedence. MemoryLimitPercentage uint32 `mapstructure:"limit_percentage"` // MemorySpikePercentage is the maximum, in percents against the total memory, // spike expected between the measurements of memory usage. MemorySpikePercentage uint32 `mapstructure:"spike_limit_percentage"` }
Config defines configuration for memory memoryLimiter processor.
type MemoryLimiter ¶
type MemoryLimiter struct {
// contains filtered or unexported fields
}
MemoryLimiter is used to prevent out of memory situations on the collector.
func NewMemoryLimiter ¶
func NewMemoryLimiter(cfg *Config, logger *zap.Logger) (*MemoryLimiter, error)
NewMemoryLimiter returns a new memory limiter component
func (*MemoryLimiter) CheckMemLimits ¶
func (ml *MemoryLimiter) CheckMemLimits()
CheckMemLimits inspects current memory usage against threshold and toggle mustRefuse when threshold is exceeded
func (*MemoryLimiter) MustRefuse ¶
func (ml *MemoryLimiter) MustRefuse() bool
MustRefuse returns if the caller should deny because memory has reached it's configured limits
Directories ¶
Path | Synopsis |
---|---|
Package cgroups provides utilities to access Linux control group (CGroups) parameters (total memory, for example) for a given process.
|
Package cgroups provides utilities to access Linux control group (CGroups) parameters (total memory, for example) for a given process. |
Click to show internal directories.
Click to hide internal directories.