Documentation ¶
Overview ¶
Package generic implements the container check.
Index ¶
- Constants
- func ConvertNanosecondsToHz(val float64) float64
- func Factory(store workloadmeta.Component, tagger tagger.Component) optional.Option[func() check.Check]
- func NewCappedSender(cappedMetrics map[string]float64, sender sender.Sender) sender.Sender
- type ANDContainerFilter
- type CappedSender
- type ContainerAccessor
- type ContainerCheck
- type ContainerConfig
- type ContainerFilter
- type FuncContainerFilter
- type GenericMetricsAdapter
- type LegacyContainerFilter
- type MetadataContainerAccessor
- type MetricsAdapter
- type Processor
- type ProcessorExtension
- type ProcessorNetwork
- type RuntimeContainerFilter
- type SenderFunc
Constants ¶
const (
// CheckName is the name of the check
CheckName = "container"
)
const (
// NetworkExtensionID uniquely identifies network extensions
NetworkExtensionID = "network"
)
Variables ¶
This section is empty.
Functions ¶
func ConvertNanosecondsToHz ¶
ConvertNanosecondsToHz converts nanoseconds to User Hz (1/100s)
Types ¶
type ANDContainerFilter ¶
type ANDContainerFilter struct {
Filters []ContainerFilter
}
ANDContainerFilter implements a logical AND between given filters
func (ANDContainerFilter) IsExcluded ¶
func (f ANDContainerFilter) IsExcluded(container *workloadmeta.Container) bool
IsExcluded returns if a container should be excluded or not
type CappedSender ¶
CappedSender wraps around the standard Sender and overrides the Rate method to implement rate capping
type ContainerAccessor ¶
type ContainerAccessor interface {
ListRunning() []*workloadmeta.Container
}
ContainerAccessor abstracts away how to list all running containers
type ContainerCheck ¶
ContainerCheck generates metrics for all containers
func (*ContainerCheck) Configure ¶
func (c *ContainerCheck) Configure(senderManager sender.SenderManager, _ uint64, config, initConfig integration.Data, source string) error
Configure parses the check configuration and init the check
type ContainerConfig ¶
type ContainerConfig struct{}
ContainerConfig holds the check configuration
func (*ContainerConfig) Parse ¶
func (c *ContainerConfig) Parse(data []byte) error
Parse parses the container check config and set default values
type ContainerFilter ¶
type ContainerFilter interface {
IsExcluded(container *workloadmeta.Container) bool
}
ContainerFilter defines an interface to exclude containers based on Metadata
type FuncContainerFilter ¶
type FuncContainerFilter func(container *workloadmeta.Container) bool
FuncContainerFilter allows any function to be used as a ContainerFilter
func (FuncContainerFilter) IsExcluded ¶
func (f FuncContainerFilter) IsExcluded(container *workloadmeta.Container) bool
IsExcluded returns if a container should be excluded or not
type GenericMetricsAdapter ¶
type GenericMetricsAdapter struct{}
GenericMetricsAdapter implements MetricsAdapter API in a basic way. Adds `runtime` tag and do not change metrics.
func (GenericMetricsAdapter) AdaptMetrics ¶
func (a GenericMetricsAdapter) AdaptMetrics(metricName string, value float64) (string, float64)
AdaptMetrics is a passthrough (does not change anything)
func (GenericMetricsAdapter) AdaptTags ¶
func (a GenericMetricsAdapter) AdaptTags(tags []string, c *workloadmeta.Container) []string
AdaptTags adds a `runtime` tag for all containers
type LegacyContainerFilter ¶
type LegacyContainerFilter struct { OldFilter *containers.Filter Store workloadmeta.Component }
LegacyContainerFilter allows to use old containers.Filter within this new framework
func (LegacyContainerFilter) IsExcluded ¶
func (f LegacyContainerFilter) IsExcluded(container *workloadmeta.Container) bool
IsExcluded returns if a container should be excluded or not
type MetadataContainerAccessor ¶
type MetadataContainerAccessor struct {
// contains filtered or unexported fields
}
MetadataContainerAccessor implements ContainerLister interface using Workload meta service
func NewMetadataContainerAccessor ¶
func NewMetadataContainerAccessor(store workloadmeta.Component) MetadataContainerAccessor
NewMetadataContainerAccessor returns a new MetadataContainerAccessor
func (MetadataContainerAccessor) ListRunning ¶
func (l MetadataContainerAccessor) ListRunning() []*workloadmeta.Container
ListRunning returns all running containers
type MetricsAdapter ¶
type MetricsAdapter interface { // AdaptTags can be used to change Tagger tags before submitting the metrics AdaptTags(tags []string, c *workloadmeta.Container) []string // AdaptMetrics can be used to change metrics (change name or value) before submitting the metric. AdaptMetrics(metricName string, value float64) (string, float64) }
MetricsAdapter provides a way to change metrics and tags before sending them out
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
Processor contains the core logic of the generic check, allowing reusability
func NewProcessor ¶
func NewProcessor(provider metrics.Provider, lister ContainerAccessor, adapter MetricsAdapter, filter ContainerFilter, tagger tagger.Component) Processor
NewProcessor creates a new processor
func (*Processor) RegisterExtension ¶
func (p *Processor) RegisterExtension(id string, extension ProcessorExtension)
RegisterExtension allows to register (or override) an extension
type ProcessorExtension ¶
type ProcessorExtension interface { // PreProcess is called once during check run, before any call to `Process` PreProcess(sender SenderFunc, aggSender sender.Sender) // Process is called after core process (regardless of encountered error) // Tags are given after `AdaptTags()` has been called // aggSender is only passed as the sender function (sender.Gauge for instance) needs to be passed back to sender Process(tags []string, container *workloadmeta.Container, collector metrics.Collector, cacheValidity time.Duration) // PostProcess is called once during each check run, after all calls to `Process` PostProcess(tagger tagger.Component) }
ProcessorExtension allows to replace or add optional parts of the core check
func NewProcessorNetwork ¶
func NewProcessorNetwork() ProcessorExtension
NewProcessorNetwork returns a default ProcessorExtension
type ProcessorNetwork ¶
type ProcessorNetwork struct {
// contains filtered or unexported fields
}
ProcessorNetwork is a Processor extension taking care of network metrics
func (*ProcessorNetwork) PostProcess ¶
func (pn *ProcessorNetwork) PostProcess(tagger tagger.Component)
PostProcess actually computes the metrics
func (*ProcessorNetwork) PreProcess ¶
func (pn *ProcessorNetwork) PreProcess(sender SenderFunc, aggSender sender.Sender)
PreProcess is called once during check run, before any call to `Process`
func (*ProcessorNetwork) Process ¶
func (pn *ProcessorNetwork) Process(tags []string, container *workloadmeta.Container, collector metrics.Collector, cacheValidity time.Duration)
Process stores each container in relevant network group
type RuntimeContainerFilter ¶
type RuntimeContainerFilter struct {
Runtime workloadmeta.ContainerRuntime
}
RuntimeContainerFilter filters containers by runtime
func (RuntimeContainerFilter) IsExcluded ¶
func (f RuntimeContainerFilter) IsExcluded(container *workloadmeta.Container) bool
IsExcluded returns if a container should be excluded or not