collector

package
v0.0.0-...-f0fa1af Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 31 Imported by: 8 modules, 6 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCacheTag

func BuildCacheTag(prefix string, val ...interface{}) *string

BuildCacheTag builds a cache tag based on prefix string and various interfaces, returns a tag value (string)

func GetList

func GetList() map[string]*Collector

func HttpWaitForRlock

func HttpWaitForRlock(handler http.Handler) http.Handler

func Lock

func Lock() *sync.RWMutex

Types

type Collector

type Collector struct {
	Name string
	// contains filtered or unexported fields
}

func New

func New(name string, processor ProcessorInterface, logger *slog.Logger) *Collector

New creates new collector

func (*Collector) DisableCache

func (c *Collector) DisableCache()

DisableCache disables all caching

func (*Collector) EnableCache

func (c *Collector) EnableCache(cache string, cacheTag *string) error

EnableCache alias of SetCache

func (*Collector) GetConcurrency

func (c *Collector) GetConcurrency() int

GetConcurrency returns global collector concurrency

func (*Collector) GetContext

func (c *Collector) GetContext() context.Context

GetContext returns collector context

func (*Collector) GetCronSpec

func (c *Collector) GetCronSpec() *string

GetCronSpec return cronspec (if set)

func (*Collector) GetData

func (c *Collector) GetData(name string) interface{}

GetData returns additional data which also is stored/restored in cache

func (*Collector) GetLastScapeTime

func (c *Collector) GetLastScapeTime() *time.Time

GetLastScapeTime returns last scrape time

func (*Collector) GetLastScrapeDuration

func (c *Collector) GetLastScrapeDuration() *time.Duration

GetLastScrapeDuration returns last scrape duration

func (*Collector) GetMetricList

func (c *Collector) GetMetricList(name string) *MetricList

GetMetricList returns managed metric vec

func (*Collector) GetNextScrapeTime

func (c *Collector) GetNextScrapeTime() *time.Time

GetNextScrapeTime returns next scrape time

func (*Collector) GetPanicBackoff

func (c *Collector) GetPanicBackoff() []time.Duration

GetPanicBackoff returns panic backoff durations

func (*Collector) GetPanicThreshold

func (c *Collector) GetPanicThreshold() int64

GetPanicThreshold returns panic threshold count

func (*Collector) GetPrometheusRegistry

func (c *Collector) GetPrometheusRegistry() *prometheus.Registry

GetPrometheusRegistry returns prometheus metric registry

func (*Collector) GetScapeTime

func (c *Collector) GetScapeTime() *time.Duration

GetScapeTime return scrape time

func (*Collector) IsEnabled

func (c *Collector) IsEnabled() (status bool)

IsEnabled returns if all requirements are fulfilled to start collector

func (*Collector) RegisterMetricList

func (c *Collector) RegisterMetricList(name string, vec interface{}, reset bool) *MetricList

RegisterMetricList register new managed prometheus metric vec

func (*Collector) SetCache

func (c *Collector) SetCache(cache *string, cacheTag *string) error

SetCache enables caching of collector with local file and azblob support

  cache can be specified as local file or storageaccount blob:
    path or file://path/to/file will store cached metrics in file
	   azblob://storageaccount.blob.core.windows.net/container/blob will store cached metrics in storageaccount
	 cacheTag is used to force restore, if nil cacheTag is ignored and otherwise enforced

func (*Collector) SetConcurrency

func (c *Collector) SetConcurrency(concurrency int)

SetConcurrency set global concurrency for collector

func (*Collector) SetContext

func (c *Collector) SetContext(ctx context.Context)

SetContext set context of collector

func (*Collector) SetCronSpec

func (c *Collector) SetCronSpec(cron *cron.Cron, cronSpec string)

SetCronSpec sets cronspec for collector (using cron for schedule)

func (*Collector) SetData

func (c *Collector) SetData(name string, val interface{})

SetData stores additional data which also is stored/restored in cache

func (*Collector) SetNextSleepDuration

func (c *Collector) SetNextSleepDuration(sleepDuration time.Duration)

SetNextSleepDuration set next sleep duration for next run

func (*Collector) SetPanicBackoff

func (c *Collector) SetPanicBackoff(val ...time.Duration)

SetPanicBackoff set backoff duration for panics

func (*Collector) SetPanicThreshold

func (c *Collector) SetPanicThreshold(threshold int64)

SetPanicThreshold set threshold of panics in a row until panics are thrown

func (*Collector) SetPrometheusRegistry

func (c *Collector) SetPrometheusRegistry(registry *prometheus.Registry)

SetPrometheusRegistry set prometheus metric registry

func (*Collector) SetScapeTime

func (c *Collector) SetScapeTime(scrapeTime time.Duration)

SetScapeTime set fixed scrape time in time.Duration

func (*Collector) Start

func (c *Collector) Start() error

Start starts the collector run in background func

type CollectorData

type CollectorData struct {
	// metric lists
	Metrics map[string]*MetricList `json:"metrics"`

	// custom data
	Data map[string]interface{} `json:"data"`

	// only used for debugging purposes
	Created *time.Time `json:"created"`

	// used for cache expiry
	Expiry *time.Time `json:"expiry"`

	// used for reload enforcement if tag mismatches
	Tag *string `json:"tag"`
}

func NewCollectorData

func NewCollectorData() *CollectorData

NewCollectorData creates new collector data struct

type MetricList

type MetricList struct {
	*prometheusCommon.MetricList
	// contains filtered or unexported fields
}

type Processor

type Processor struct {
	Collector *Collector
}

func (*Processor) Context

func (p *Processor) Context() context.Context

func (*Processor) GetLastScapeTime

func (p *Processor) GetLastScapeTime() *time.Time

func (*Processor) Logger

func (p *Processor) Logger() *slog.Logger

func (*Processor) Setup

func (p *Processor) Setup(collector *Collector)

func (*Processor) WaitGroup

func (p *Processor) WaitGroup() *sizedwaitgroup.SizedWaitGroup

type ProcessorInterface

type ProcessorInterface interface {
	Setup(collector *Collector)
	Reset()
	Collect(callback chan<- func())
}

Jump to

Keyboard shortcuts

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