telemetry

package
v0.0.0-...-8018142 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: MPL-2.0 Imports: 17 Imported by: 6

README

telemetry

GoDoc

Documentation

Overview

Package telemetry provides a Prometheus client and the configuration for metrics collectors

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Port       int           `mapstructure:"port"`
	Interfaces []interface{} `mapstructure:"interfaces"` // optional override
	Tags       []string      `mapstructure:"tags"`
	Metrics    []interface{} `mapstructure:"metrics"`

	// derived in Validate
	MetricConfigs []*MetricConfig
	JobConfig     *jobs.Config
	// contains filtered or unexported fields
}

Config represents the service to advertise for finding the metrics endpoint, and the collection of Metrics.

func NewConfig

func NewConfig(raw interface{}, disc discovery.Backend) (*Config, error)

NewConfig parses json config into a validated Config including a validated Config and validated MetricConfigs

func (*Config) ToJobConfig

func (cfg *Config) ToJobConfig() *jobs.Config

ToJobConfig ...

func (*Config) Validate

func (cfg *Config) Validate(disc discovery.Backend) error

Validate ...

type Metric

type Metric struct {
	Name string
	Type MetricType

	events.Subscriber
	// contains filtered or unexported fields
}

Metric manages state of periodic metrics.

func NewMetric

func NewMetric(cfg *MetricConfig) *Metric

NewMetric creates a Metric from a validated MetricConfig

func (*Metric) Run

func (metric *Metric) Run(pctx context.Context, bus *events.EventBus)

Run executes the event loop for the Metric

type MetricConfig

type MetricConfig struct {
	Namespace string `mapstructure:"namespace"`
	Subsystem string `mapstructure:"subsystem"`
	Name      string `mapstructure:"name"`
	Help      string `mapstructure:"help"` // help string returned by API
	Type      string `mapstructure:"type"`
	// contains filtered or unexported fields
}

A MetricConfig is a single measurement of the application.

func NewMetricConfigs

func NewMetricConfigs(raw []interface{}) ([]*MetricConfig, error)

NewMetricConfigs creates new metrics from a raw config

func (*MetricConfig) Validate

func (cfg *MetricConfig) Validate() error

Validate ensures Metric meets all requirements

type MetricType

type MetricType int

MetricType is an enum for Prometheus metric types

const (
	Counter MetricType = iota
	Gauge
	Histogram
	Summary
)

MetricType enum

type Status

type Status struct {
	Version string

	Jobs     []*jobStatusResponse
	Services []*serviceStatusResponse
	Watches  []string
	// contains filtered or unexported fields
}

Status persists all the data the telemetry server needs to serve the '/status' endpoint

type StatusHandler

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

StatusHandler implements http.Handler

func NewStatusHandler

func NewStatusHandler(t *Telemetry) StatusHandler

NewStatusHandler constructs a StatusHandler with a pointer to the Telemetry server

func (StatusHandler) ServeHTTP

func (sh StatusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler for StatusHandler

type Telemetry

type Telemetry struct {
	Metrics []*Metric // supports '/metrics' endpoint fields
	Status  *Status   // supports '/status' endpoint fields

	http.Server
	// contains filtered or unexported fields
}

Telemetry represents the service to advertise for finding the metrics endpoint, and the collection of Metrics.

func NewTelemetry

func NewTelemetry(cfg *Config) *Telemetry

NewTelemetry configures a new prometheus Telemetry server

func (*Telemetry) MonitorJobs

func (t *Telemetry) MonitorJobs(jobs []*jobs.Job)

MonitorJobs adds a list of Jobs for the /status handler to monitor

func (*Telemetry) MonitorWatches

func (t *Telemetry) MonitorWatches(watches []*watches.Watch)

MonitorWatches adds a list of Watches for the /status handler to monitor

func (*Telemetry) Run

func (t *Telemetry) Run(ctx context.Context)

Run executes the event loop for the telemetry server

func (*Telemetry) Start

func (t *Telemetry) Start()

Start starts serving the telemetry service

func (*Telemetry) Stop

func (t *Telemetry) Stop(pctx context.Context)

Stop shuts down the telemetry service

Jump to

Keyboard shortcuts

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