provider

package
v0.0.0-...-7983b3b Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuntimeNameDocker     string = "docker"
	RuntimeNameContainerd string = "containerd"
	RuntimeNameCRIO       string = "cri-o"
	RuntimeNameGarden     string = "garden"
)

Known container runtimes

Variables

View Source
var (
	// ErrNothingYet is returned when no collector is currently detected.
	// This might change in the future if new collectors are valid.
	ErrNothingYet = &retry.Error{
		LogicError:    errors.New("no collector detected for runtime"),
		RessourceName: "catalog",
		RetryStatus:   retry.FailWillRetry,
	}

	// ErrPermaFail is returned when a collector will never be available
	ErrPermaFail = &retry.Error{
		LogicError:    errors.New("no collector available for runtime"),
		RessourceName: "catalog",
		RetryStatus:   retry.PermaFail,
	}

	// AllLinuxRuntimes lists all runtimes available on Linux
	// nolint: deadcode, unused
	AllLinuxRuntimes = []string{
		RuntimeNameDocker,
		RuntimeNameContainerd,
		RuntimeNameCRIO,
	}
	// AllWindowsRuntimes lists all runtimes available on Windows
	// nolint: deadcode, unused
	AllWindowsRuntimes = []string{
		RuntimeNameDocker,
		RuntimeNameContainerd,
	}
)

Functions

func ConvertRetrierErr

func ConvertRetrierErr(err error) error

ConvertRetrierErr converts a retrier error into a metrics error

Types

type Collector

type Collector interface {
	ID() string
	GetContainerStats(containerID string, cacheValidity time.Duration) (*ContainerStats, error)
	GetContainerNetworkStats(containerID string, cacheValidity time.Duration, networks map[string]string) (*ContainerNetworkStats, error)
}

Collector defines an interface allowing to get stats from a containerID. All implementations should allow for concurrent access.

type CollectorMetadata

type CollectorMetadata struct {
	ID       string
	Priority int // lowest gets higher priority (0 more prioritary than 1)
	Runtimes []string
	Factory  collectorFactory
}

CollectorMetadata contains the characteristics of a collector to be registered with RegisterCollector

type ContainerCPUStats

type ContainerCPUStats struct {
	// Common fields
	Total  *float64
	System *float64
	User   *float64
	Limit  *float64 // Percentage 0-100*numCPU

	// Linux-only fields
	Shares           *float64
	ElapsedPeriods   *float64
	ThrottledPeriods *float64
	ThrottledTime    *float64
}

ContainerCPUStats stores CPU stats.

type ContainerIOStats

type ContainerIOStats struct {
	// Common fields
	ReadBytes       *float64
	WriteBytes      *float64
	ReadOperations  *float64
	WriteOperations *float64
	OpenFiles       *float64

	Devices map[string]DeviceIOStats
}

ContainerIOStats store I/O statistics about a container.

type ContainerMemStats

type ContainerMemStats struct {
	// Common fields
	UsageTotal   *float64
	KernelMemory *float64
	Limit        *float64
	Softlimit    *float64

	// Linux-only fields
	RSS       *float64
	Cache     *float64
	Swap      *float64
	OOMEvents *float64 // Number of events where memory allocation failed

	// Windows-only fields
	PrivateWorkingSet *float64
	CommitBytes       *float64
	CommitPeakBytes   *float64
}

ContainerMemStats stores memory statistics.

type ContainerNetworkStats

type ContainerNetworkStats struct {
	BytesSent   *float64
	BytesRcvd   *float64
	PacketsSent *float64
	PacketsRcvd *float64
	Interfaces  map[string]InterfaceNetStats
}

ContainerNetworkStats stores network statistics about a container per interface

type ContainerPIDStats

type ContainerPIDStats struct {
	// Common fields
	PIDs        []int
	ThreadCount *float64
	ThreadLimit *float64
}

ContainerPIDStats stores stats about threads & processes.

type ContainerStats

type ContainerStats struct {
	Timestamp time.Time
	CPU       *ContainerCPUStats
	Memory    *ContainerMemStats
	IO        *ContainerIOStats
	PID       *ContainerPIDStats
}

ContainerStats wraps all container metrics

type DeviceIOStats

type DeviceIOStats struct {
	// Common fields
	ReadBytes       *float64
	WriteBytes      *float64
	ReadOperations  *float64
	WriteOperations *float64
}

DeviceIOStats stores Device IO stats.

type GenericProvider

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

GenericProvider offers an interface to retrieve a metrics collector

func (*GenericProvider) GetCollector

func (mp *GenericProvider) GetCollector(runtime string) Collector

GetCollector returns the best collector for given runtime. The best collector may change depending on other collectors availability. You should not cache the result from this function.

func (*GenericProvider) RegisterCollector

func (mp *GenericProvider) RegisterCollector(collectorMeta CollectorMetadata)

RegisterCollector registers a collector

type InterfaceNetStats

type InterfaceNetStats struct {
	BytesSent   *float64
	BytesRcvd   *float64
	PacketsSent *float64
	PacketsRcvd *float64
}

InterfaceNetStats stores network statistics about a network interface

type Provider

type Provider interface {
	GetCollector(runtime string) Collector
	RegisterCollector(collectorMeta CollectorMetadata)
}

Provider interface allows to mock the metrics provider

func GetProvider

func GetProvider() Provider

GetProvider returns the metrics provider singleton

Jump to

Keyboard shortcuts

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