metrics

package
v0.8.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// MinPollInterval is the most frequent allowed polling interval.
	MinPollInterval = 5 * time.Second
	// DefaultPollInterval is the default interval for polling collectors.
	DefaultPollInterval = 30 * time.Second
)

Variables

This section is empty.

Functions

func MustRegister added in v0.8.0

func MustRegister(name string, collector prometheus.Collector, opts ...RegisterOption)

MustRegister registers a collector with the default registry, panicking on error.

func Register added in v0.8.0

func Register(name string, collector prometheus.Collector, opts ...RegisterOption) error

Register registers a collector with the default registry.

Types

type Collector added in v0.8.0

type Collector struct {
	State
	// contains filtered or unexported fields
}

Collector is a registered prometheus.Collector.

func NewCollector added in v0.8.0

func NewCollector(name string, collector prometheus.Collector, options ...CollectorOption) *Collector

NewCollector creates a new collector with the given name and collector.

func (*Collector) Collect added in v0.8.0

func (c *Collector) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface.

func (*Collector) Describe added in v0.8.0

func (c *Collector) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface.

func (*Collector) Enable added in v0.8.0

func (c *Collector) Enable(state bool)

Enable enables or disables the collector.

func (*Collector) Matches added in v0.8.0

func (c *Collector) Matches(glob string) bool

Matches returns true if the collector matches the given glob pattern.

func (*Collector) Name added in v0.8.0

func (c *Collector) Name() string

Name returns the name of the collector.

func (*Collector) Poll added in v0.8.0

func (c *Collector) Poll()

Poll collects metrics from the collector if it is polled.

func (*Collector) Polled added in v0.8.0

func (c *Collector) Polled(state bool)

Polled marks the collector polled or non-polled.

type CollectorOption added in v0.8.0

type CollectorOption func(*Collector)

CollectorOption is an option for a Collector.

func WithPolled added in v0.8.0

func WithPolled() CollectorOption

WithPolled is an option to mark a collector polled.

func WithoutNamespace added in v0.8.0

func WithoutNamespace() CollectorOption

WithoutNamespace is an option to disable namespace prefixing for a collector.

func WithoutSubsystem added in v0.8.0

func WithoutSubsystem() CollectorOption

WithoutSubsystem is an option to disable group prefixing for a collector.

type Gatherer added in v0.8.0

type Gatherer struct {
	*prometheus.Registry
	// contains filtered or unexported fields
}

Gatherer is a prometheus gatherer for our registry.

func NewGatherer added in v0.8.0

func NewGatherer(opts ...GathererOption) (*Gatherer, error)

NewGatherer creates a new gatherer for the default registry, with the given options.

func (*Gatherer) Block added in v0.8.0

func (g *Gatherer) Block()

Block the gatherer from polling collectors.

func (*Gatherer) Gather added in v0.8.0

func (g *Gatherer) Gather() ([]*model.MetricFamily, error)

Gather implements the prometheus.Gatherer interface.

func (*Gatherer) Poll added in v0.8.0

func (g *Gatherer) Poll()

Poll all enabled collectors in poll mode in the registry.

func (*Gatherer) Stop added in v0.8.0

func (g *Gatherer) Stop()

func (*Gatherer) Unblock added in v0.8.0

func (g *Gatherer) Unblock()

Allow the gatherer to poll collectors.

type GathererOption added in v0.8.0

type GathererOption func(*Gatherer)

GathererOption is an option for the gatherer.

func WithMetrics added in v0.8.0

func WithMetrics(enabled, polled []string) GathererOption

WithMetrics defines which groups or collectors will be enabled, and and polled if any.

func WithNamespace added in v0.8.0

func WithNamespace(namespace string) GathererOption

WithNamespace defines the common namespace prefix for gathered collectors.

func WithPollInterval added in v0.8.0

func WithPollInterval(interval time.Duration) GathererOption

WithPollInterval defines the polling interval for the gatherer.

func WithoutPolling added in v0.8.0

func WithoutPolling() GathererOption

WithoutPolling disables internally triggered polling for the gatherer.

type Group added in v0.8.0

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

Group is a collection of collectors.

func (*Group) Collect added in v0.8.0

func (g *Group) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface.

func (*Group) Describe added in v0.8.0

func (g *Group) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface.

type RegisterOption added in v0.8.0

type RegisterOption func(*RegisterOptions)

RegisterOption is an option for registering collectors.

func WithCollectorOptions added in v0.8.0

func WithCollectorOptions(opts ...CollectorOption) RegisterOption

WithCollectorOptions is an option to register a collector with options.

func WithGroup added in v0.8.0

func WithGroup(name string) RegisterOption

WithGroup is an option to register a collector in a specific group.

type RegisterOptions added in v0.8.0

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

RegisterOptions are options for registering collectors.

type Registry added in v0.8.0

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

Registry is a collection of groups.

func Default added in v0.8.0

func Default() *Registry

Default returns the default registry.

func NewRegistry added in v0.8.0

func NewRegistry() *Registry

NewRegistry creates a new registry.

func (*Registry) Configure added in v0.8.0

func (r *Registry) Configure(enabled []string, polled []string) (State, error)

Configure enables the collectors matching any of the given globs. Any collector matching any glob in polled is forced to polled mode.

func (*Registry) Gatherer added in v0.8.0

func (r *Registry) Gatherer(opts ...GathererOption) (*Gatherer, error)

Getherer returns a gatherer for the registry, configured with the given options.

func (*Registry) NewGatherer added in v0.8.0

func (r *Registry) NewGatherer(opts ...GathererOption) (*Gatherer, error)

NewGatherer creates a new gatherer for the registry, with the given options.

func (*Registry) Poll added in v0.8.0

func (r *Registry) Poll()

Poll all collectors with are enabled and in polled mode.

func (*Registry) Register added in v0.8.0

func (r *Registry) Register(name string, collector prometheus.Collector, opts ...RegisterOption) error

Register registers a collector with the registry.

func (*Registry) State added in v0.8.0

func (r *Registry) State() State

State returns the collective state of all collectors in the registry.

type State added in v0.8.0

type State int

State represents the configuration of a collector or a group of collectors.

const (
	// Enabled marks a collector as enabled.
	Enabled State = (1 << iota)
	// Polled marks a collector as polled. Polled collectors return cached metrics
	// collected during the last polling cycle. This is useful for computationally
	// expensive metrics that should not be collected during normal collection.
	Polled
	// NamespacePrefix causes a collector's metrics to be prefixed with a common
	// namespace.
	NamespacePrefix
	// SubsystemPrefix causes a collecor's metrics to be prefixed with the name
	// of the group the collector belongs to.
	SubsystemPrefix

	// DefaultName is the name of the default group. An alias for "".
	DefaultName = "default"
)

func (State) IsEnabled added in v0.8.0

func (s State) IsEnabled() bool

IsEnabled returns true if the collector is enabled.

func (State) IsPolled added in v0.8.0

func (s State) IsPolled() bool

IsPolled returns true if the collector is polled.

func (State) NeedsNamespace added in v0.8.0

func (s State) NeedsNamespace() bool

NeedsNamespace returns true if the collector needs a namespace prefix.

func (State) NeedsSubsystem added in v0.8.0

func (s State) NeedsSubsystem() bool

NeedsSubsystem returns true if the collector needs a group prefix.

func (State) String added in v0.8.0

func (s State) String() string

String returns a string representation of the collector state.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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