leak

package
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// ComparisonModePercentage compares start and end values in percentage
	ComparisonModePercentage = "percentage"
	// ComparisonModeDiff compares start and end values by subtracting start from end
	ComparisonModeDiff = "diff"
	// ComparisonModeAbsolute compares only end values with threshold
	ComparisonModeAbsolute = "absolute"
)
View Source
const (
	DefaultPyroscopeBinaryVersion = "1.18.0"
	DefaultOutputPath             = "alloc.pprof"
	DefaultProfileType            = "memory:alloc_space:bytes:space:bytes"
	DefaultFrom                   = "now-12h"
	DefaultTo                     = "now"
)

Variables

This section is empty.

Functions

func PromSingleValueResponse

func PromSingleValueResponse(val string) *f.PrometheusQueryResponse

func WithCPUQuery

func WithCPUQuery(q string) func(*CLNodesLeakDetector)

WithCPUQuery allows to override CPU leak query (Prometheus)

func WithMemoryQuery

func WithMemoryQuery(q string) func(*CLNodesLeakDetector)

WithMemoryQuery allows to override Memory leak query (Prometheus)

func WithNodesetName added in v0.15.4

func WithNodesetName(name string) func(*CLNodesLeakDetector)

WithNodesetName overrides the default nodeset name "don" in all Prometheus queries. The name is used to build container labels like "name-node0", "name-node1", etc. Name should be alphanumeric with hyphens/underscores; characters that could break format strings (% or PromQL literals like ", \) are escaped for safety.

func WithProfileCLIPath added in v0.13.4

func WithProfileCLIPath(path string) func(*ProfileDumper)

WithProfileCLIPath sets a custom path to profilecli binary

func WithPrometheusBaseURL

func WithPrometheusBaseURL(url string) func(*ResourceLeakChecker)

WithPrometheusBaseURL sets Prometheus base URL, example http://localhost:9099

func WithQueryClient

func WithQueryClient(c PromQuerier) func(*ResourceLeakChecker)

WithQueryClient sets Prometheus query client

Types

type CLNodesCheck

type CLNodesCheck struct {
	// ComparisonMode how do we compaore start/end values: percentage, diff or absolute
	ComparisonMode string
	// NumNodes number of Chainlink nodes
	NumNodes int
	// Start start time
	Start time.Time
	// End end time
	End time.Time
	// WarmUpDuration duration that will be excluded from comparison, load/soak test warmup duration
	WarmUpDuration time.Duration
	// CPUThreshold CPU threshold as a float: 200.0 means full 2 CPU cores
	CPUThreshold float64
	// MemoryThreshold memory threshold in Megabytes
	MemoryThreshold float64
}

ClNodesCheck contains thresholds which can be verified for each Chainlink node it is recommended to set some WarmUpDuration, 20% of overall test time to have more stable results

type CLNodesLeakDetector

type CLNodesLeakDetector struct {
	// CPUQuery Prometheus query for CPU
	CPUQuery string
	// MemoryQuery Prometheus query for memory
	MemoryQuery         string
	CPUQueryAbsolute    string
	MemoryQueryAbsolute string
	// ContainerAliveQuery Prometheus memory for checking if container was alive the whole time
	ContainerAliveQuery string
	// contains filtered or unexported fields
}

CLNodesLeakDetector is Chainlink node specific resource leak detector can be used with both local and remote Chainlink node sets (DONs)

func NewCLNodesLeakDetector

func NewCLNodesLeakDetector(c *ResourceLeakChecker, opts ...func(*CLNodesLeakDetector)) (*CLNodesLeakDetector, error)

NewCLNodesLeakDetector create new Chainlink node specific resource leak detector with Prometheus client

func (*CLNodesLeakDetector) Check

func (cd *CLNodesLeakDetector) Check(t *CLNodesCheck) error

Check runs all resource leak checks and returns errors if threshold reached for any of them

type CheckConfig

type CheckConfig struct {
	// ComparisonMode how do we compaore start/end values: percentage, diff or absolute
	ComparisonMode string
	// Query prometheus query
	Query string
	// Start start time
	Start time.Time
	// End end time
	End time.Time
	// WarmUpDuration duration that will be excluded from comparison, load/soak test warmup duration
	WarmUpDuration time.Duration
}

CheckConfig describes leak check configuration

type FakeQueryClient

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

func NewFakeQueryClient

func NewFakeQueryClient() *FakeQueryClient

func (*FakeQueryClient) Query

func (qc *FakeQueryClient) Query(query string, timestamp time.Time) (*f.PrometheusQueryResponse, error)

func (*FakeQueryClient) SetResponses

type Measurement added in v0.13.10

type Measurement struct {
	Start float64
	End   float64
	Delta float64
}

Measurement measurement of start/end test timestamps + delta between them

type ProfileDumper added in v0.13.4

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

ProfileDumper is responsible for downloading profiles from Pyroscope

func NewProfileDumper added in v0.13.4

func NewProfileDumper(pyroscopeURL string, opts ...func(*ProfileDumper)) *ProfileDumper

NewProfileDumper creates a new profile dumper instance

func (*ProfileDumper) DownloadProfile added in v0.13.4

func (d *ProfileDumper) DownloadProfile(config *ProfileDumperConfig) (string, error)

DownloadProfile runs profilecli to download a profile

func (*ProfileDumper) InstallProfileCLI added in v0.13.4

func (d *ProfileDumper) InstallProfileCLI() (string, error)

InstallProfileCLI downloads and installs profilecli if not already available

func (*ProfileDumper) MemoryProfile added in v0.13.4

func (d *ProfileDumper) MemoryProfile(config *ProfileDumperConfig) (string, error)

MemoryProfile downloads memory profile and saves it

type ProfileDumperConfig added in v0.13.4

type ProfileDumperConfig struct {
	PyroscopeURL string
	ServiceName  string
	ProfileType  string
	From         string // Relative time like "now-30m" or unix timestamp (seconds)
	To           string // Relative time like "now" or unix timestamp (seconds)
	OutputPath   string // Output file path
}

ProfileDumperConfig describes profile dump configuration

type PromQuerier

type PromQuerier interface {
	Query(query string, timestamp time.Time) (*f.PrometheusQueryResponse, error)
}

PromQueries is an interface for querying Prometheus containing only methods we need for detecting resource leaks

type ResourceLeakChecker

type ResourceLeakChecker struct {
	PrometheusURL string
	// contains filtered or unexported fields
}

ResourceLeakChecker is resource leak cheker instance

func NewResourceLeakChecker

func NewResourceLeakChecker(opts ...func(*ResourceLeakChecker)) *ResourceLeakChecker

NewResourceLeakChecker creates a new resource leak checker

func (*ResourceLeakChecker) MeasureDelta added in v0.13.2

func (rc *ResourceLeakChecker) MeasureDelta(
	c *CheckConfig,
) (*Measurement, error)

MeasureDelta measures resource leak delta between start and end timestamps WarmUpDuration is used to ignore warm up interval results for more stable comparison

type ResourceLeakCheckerConfig

type ResourceLeakCheckerConfig struct {
	PrometheusBaseURL string
}

ResourceLeakCheckerConfig is resource leak checker config with Prometheus base URL

Jump to

Keyboard shortcuts

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