collector

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package collector manages a metric collection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(
	cfg *server.Config,
	store store.Store,
	conn database.Connection,
	registry *prometheus.Registry,
	scheduler *gocron.Scheduler,
) (server.Server, error)

New creates a new server to collect the metrics defined in the collections.

Types

type Collector

type Collector interface {
	fmt.Stringer
	// AddCounter adds a counter to the list of metrics to return.
	AddCounter(name string, help string) error
	// AddGauge adds a gauge to the list of metrics to return.
	AddGauge(name string, help string) error
	// Collect retrieves the values for all the metrics defined.
	Collect(ctx context.Context, conn database.Connection) error
	// GetFrequency returns how often the collector is called, in seconds.
	GetFrequency() int
	// GetLastModified retrieve the last time the job was modified.
	GetLastModified() time.Time
	// Unregister all the prometheus collectors.
	Unregister()
	// WithFrequency sets the frequency
	WithFrequency(frequency int) Collector
	// WithMaxResults sets the maximum number of results to collect each time Collect is called.
	WithMaxResults(max int) Collector
}

A Collector retrieves all the metric values for all the gauges and counters configured.

func FromCollection

func FromCollection(coll *store.Collection, registerer prometheus.Registerer) (Collector, error)

FromCollection creates a collector from a collection configuration stored in the database.

type MetricKind

type MetricKind int

MetricKind specify the type of the metric: counter or gauge.

const (
	// Undefined is for metrics not currently supported.
	Undefined MetricKind = iota
	// Counter is a cumulative metric that represents a single monotonically increasing value.
	Counter
	// Gauge is a metric that represents a single numerical value that can arbitrarily go up and down.
	Gauge
)

func (MetricKind) String added in v0.0.1

func (i MetricKind) String() string

Jump to

Keyboard shortcuts

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