Documentation
¶
Overview ¶
Package check contains the interface for the check.
Index ¶
- Variables
- func CollectDefaultMetrics(c integration.Config) bool
- func GetInventoryChecksContext() (inventorychecks.Component, error)
- func GetMetadata(c Info, includeConfig bool) map[string]interface{}
- func InitializeInventoryChecksContext(ic inventorychecks.Component)
- func IsJMXConfig(config integration.Config) bool
- func IsJMXInstance(name string, instance integration.Data, initConfig integration.Data) bool
- func ReleaseContext()
- func Retry(retryDuration time.Duration, retries int, callback func() error, ...) (err error)
- type Check
- type Info
- type Loader
- type MockInfo
- func (m MockInfo) ConfigProvider() string
- func (m MockInfo) ConfigSource() string
- func (m MockInfo) ID() checkid.ID
- func (m MockInfo) InitConfig() string
- func (m MockInfo) InstanceConfig() string
- func (m MockInfo) Interval() time.Duration
- func (m MockInfo) Loader() string
- func (m MockInfo) String() string
- func (m MockInfo) Version() string
- type RetryableError
Constants ¶
This section is empty.
Variables ¶
var ErrSkipCheckInstance = errors.New("refused to load the check instance")
ErrSkipCheckInstance is returned from Configure() when a check is intentionally refusing to load a check instance, and NOT due to an error. The distinction is important for deciding whether or not to log the error and report it on the status page.
Loaders should check for this error after calling Configure() and should not log it as an error. The scheduler reports this error to the agent status if and only if all loaders fail to load the check instance.
Usage example: one version of the check is written in Python, and another is written in Golang. Each loader is called on the given configuration, and will reject the configuration if it does not match the right version, without raising errors to the log or agent status. If another error is returned then the errors will be properly logged and reported in the agent status.
Functions ¶
func CollectDefaultMetrics ¶
func CollectDefaultMetrics(c integration.Config) bool
CollectDefaultMetrics returns if the config is for a JMX check which has collect_default_metrics: true
func GetInventoryChecksContext ¶
func GetInventoryChecksContext() (inventorychecks.Component, error)
GetInventoryChecksContext returns a reference to the inventorychecks component for Python and Go checks to use.
func GetMetadata ¶
GetMetadata returns information about a specific check instances. If 'includeConfig' it true, the instance configuration will be scrubbed and included in the returned map
func InitializeInventoryChecksContext ¶
func InitializeInventoryChecksContext(ic inventorychecks.Component)
InitializeInventoryChecksContext set the reference to inventorychecks in checkContext
func IsJMXConfig ¶
func IsJMXConfig(config integration.Config) bool
IsJMXConfig checks if a certain YAML config contains at least one instance of a JMX config
func IsJMXInstance ¶
func IsJMXInstance(name string, instance integration.Data, initConfig integration.Data) bool
IsJMXInstance checks if a certain YAML instance is a JMX config
func ReleaseContext ¶
func ReleaseContext()
ReleaseContext reset to nil all the references hold by the current context
Types ¶
type Check ¶
type Check interface {
// Run runs the check
Run() error
// Stop stops the check if it's running
Stop()
// Cancel cancels the check. Cancel is called when the check is unscheduled:
// - unlike Stop, it is called even if the check is not running when it's unscheduled
// - if the check is running, Cancel is called after Stop and may be called before the call to Stop completes
Cancel()
// String provides a printable version of the check name
String() string
// Loader returns the name of the check loader
// This is used in tags so should match the tag value format constraints (eg. lowercase, no spaces)
Loader() string
// Configure configures the check
Configure(senderManger sender.SenderManager, integrationConfigDigest uint64, config, initConfig integration.Data, source string, provider string) error
// Interval returns the interval time for the check
Interval() time.Duration
// ID provides a unique identifier for every check instance
ID() checkid.ID
// GetWarnings returns the last warning registered by the check
GetWarnings() []error
// GetSenderStats returns the stats from the last run of the check.
GetSenderStats() (stats.SenderStats, error)
// Version returns the version of the check if available
Version() string
// ConfigSource returns the configuration source of the check
ConfigSource() string
// ConfigProvider returns the name of the config provider that issued the check config
ConfigProvider() string
// IsTelemetryEnabled returns if telemetry is enabled for this check
IsTelemetryEnabled() bool
// InitConfig returns the init_config configuration of the check
InitConfig() string
// InstanceConfig returns the instance configuration of the check
InstanceConfig() string
// GetDiagnoses returns the diagnoses cached in last run or diagnose explicitly
GetDiagnoses() ([]diagnose.Diagnosis, error)
// IsHASupported returns if the check is compatible with High Availability
IsHASupported() bool
}
Check is an interface for types capable to run checks
type Info ¶
type Info interface {
// String provides a printable version of the check name
String() string
// Interval returns the interval time for the check
Interval() time.Duration
// ID provides a unique identifier for every check instance
ID() checkid.ID
// Version returns the version of the check if available
Version() string
// ConfigSource returns the configuration source of the check
ConfigSource() string
// ConfigProvider returns the configuration provider of the check
ConfigProvider() string
// InitConfig returns the init_config configuration of the check
InitConfig() string
// InstanceConfig returns the instance configuration of the check
InstanceConfig() string
}
Info is an interface to pull information from types capable to run checks. This is a subsection from the Check interface with only read only method.
type Loader ¶
type Loader interface {
Name() string
Load(senderManager sender.SenderManager, config integration.Config, instance integration.Data, instanceIndex int) (Check, error)
}
Loader is the interface wrapping the operations to load a check from different sources, like Python modules or Go objects.
A single check is loaded for the given `instance` YAML.
type MockInfo ¶
type MockInfo struct {
Name string
LoaderName string
CheckID checkid.ID
Source string
Provider string
InitConf string
InstanceConf string
}
MockInfo is a mock for test using check.Info interface
func (MockInfo) ConfigProvider ¶
ConfigProvider returns the provider of the check
func (MockInfo) ConfigSource ¶
ConfigSource returns the source of the check
func (MockInfo) InitConfig ¶
InitConfig returns the init_config of the check
func (MockInfo) InstanceConfig ¶
InstanceConfig returns the instance config of the check
type RetryableError ¶
type RetryableError struct {
Err error
}
RetryableError is the error type that Retry interprets as a request to retry the callback
func (RetryableError) Error ¶
func (e RetryableError) Error() string