collector

package
v0.0.0-...-14edc53 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoData = errors.New("collector returned no data")

ErrNoData indicates the collector found no data to collect, but had no other error.

Functions

func BoolToBinary

func BoolToBinary(b bool) string

BoolToBinary converts booleans to "0" or "1"

func DisableDefaultCollectors

func DisableDefaultCollectors()

DisableDefaultCollectors sets the collector state to false for all collectors which have not been explicitly enabled on the command line.

func FetchHTTP

func FetchHTTP(token string, sslVerify bool, timeout time.Duration, logger log.Logger) func(uri url.URL, subPath string, params url.Values) (io.ReadCloser, error)

FetchHTTP is a generic fetch method for Wakatime API endpoints

func ReadAndUnmarshal

func ReadAndUnmarshal(body io.ReadCloser, object interface{}) error

ReadAndUnmarshal reads the JSON response body and unmarshals the response

Types

type Collector

type Collector interface {
	// Get new metrics and expose them via prometheus registry.
	Update(ch chan<- prometheus.Metric) error
}

Collector is the interface a collector has to implement.

func NewAllTimeCollector

func NewAllTimeCollector(in CommonInputs, logger log.Logger) (Collector, error)

NewAllTimeCollector returns a new Collector exposing all-time stats.

func NewGoalCollector

func NewGoalCollector(in CommonInputs, logger log.Logger) (Collector, error)

NewGoalCollector returns a new Collector exposing all-time stats.

func NewLeaderCollector

func NewLeaderCollector(in CommonInputs, logger log.Logger) (Collector, error)

NewLeaderCollector returns a new Collector exposing all-time stats.

func NewSummaryCollector

func NewSummaryCollector(in CommonInputs, logger log.Logger) (Collector, error)

NewSummaryCollector returns a new Collector exposing all-time stats.

type CommonInputs

type CommonInputs struct {
	BaseURI   url.URL
	URI       url.URL
	Token     string
	SSLVerify bool
	Timeout   time.Duration
}

CommonInputs are the inputs needed to implement any Collector

type WakaCollector

type WakaCollector struct {
	Collectors map[string]Collector
	// contains filtered or unexported fields
}

WakaCollector implements the prometheus.Collector interface.

func NewWakaCollector

func NewWakaCollector(in CommonInputs, logger log.Logger, filters ...string) (*WakaCollector, error)

NewWakaCollector creates a new Collector.

func (WakaCollector) Collect

func (n WakaCollector) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface.

func (WakaCollector) Describe

func (n WakaCollector) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface.

Jump to

Keyboard shortcuts

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