probers

package
v0.0.0-...-5b94510 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Registry is the global mapping of all `Configurer` types. Types
	// are added to this mapping on import by including a call to
	// `Register` in their `init` function.
	Registry = make(map[string]Configurer)
)

Functions

func Register

func Register(c Configurer)

Register is called by the `init` function of every `Configurer` to add the caller to the global `Registry` map. If the caller attempts to add a `Configurer` to the registry using the same name as a prior `Configurer` Observer will exit after logging an error.

Types

type Configurer

type Configurer interface {
	// Kind returns a name that uniquely identifies the `Kind` of
	// `Configurer`.
	Kind() string

	// UnmarshalSettings unmarshals YAML as bytes to a `Configurer`
	// object.
	UnmarshalSettings([]byte) (Configurer, error)

	// MakeProber constructs a `Prober` object from the contents of the
	// bound `Configurer` object. If the `Configurer` cannot be
	// validated, an error appropriate for end-user consumption is
	// returned instead. The map of `prometheus.Collector` objects passed to
	// MakeProber should be the same as the return value from Instrument()
	MakeProber(map[string]prometheus.Collector) (Prober, error)

	// Instrument constructs any `prometheus.Collector` objects that a prober of
	// the configured type will need to report its own metrics. A map is
	// returned containing the constructed objects, indexed by the name of the
	// prometheus metric. If no objects were constructed, nil is returned.
	Instrument() map[string]prometheus.Collector
}

Configurer is the interface for `Configurer` types.

func GetConfigurer

func GetConfigurer(kind string) (Configurer, error)

GetConfigurer returns the probe configurer specified by name from `Registry`.

type Prober

type Prober interface {
	// Name returns a name that uniquely identifies the monitor that
	// configured this `Prober`.
	Name() string

	// Kind returns a name that uniquely identifies the `Kind` of
	// `Prober`.
	Kind() string

	// Probe attempts the configured request or query, Each `Prober`
	// must treat the duration passed to it as a timeout.
	Probe(time.Duration) (bool, time.Duration)
}

Prober is the interface for `Prober` types.

type Settings

type Settings map[string]interface{}

Settings is exported as a temporary receiver for the `settings` field of `MonConf`. `Settings` is always marshaled back to bytes and then unmarshalled into the `Configurer` specified by the `Kind` field of the `MonConf`.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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