provision: github.com/digitalrebar/provision/utils Index | Files

package utils

import "github.com/digitalrebar/provision/utils"

Index

Package Files

event_handler.go prom.go prom_gateway.go prom_gin.go prom_metrics.go

func NewMetric Uses

func NewMetric(l logger.Logger, m *Metric, subsystem string) prometheus.Collector

NewMetric associates prometheus.Collector based on Metric.Type

type Metric Uses

type Metric struct {
    MetricCollector prometheus.Collector
    ID              string
    Name            string
    Description     string
    Type            string
    Args            []string
}

Metric is a definition for the name, description, type, ID, and prometheus.Collector type (i.e. CounterVec, Summary, etc) of each metric

type PromGin Uses

type PromGin struct {
    *Prometheus
    ReqCntURLLabelMappingFn RequestCounterURLLabelMappingFn
}

Prometheus contains the metrics gathered by the instance and its path

func NewPromGin Uses

func NewPromGin(l logger.Logger, subsystem string, rculmf RequestCounterURLLabelMappingFn, customMetricsList ...[]*Metric) *PromGin

NewPromGin generates a new set of metrics with a certain subsystem name

func (*PromGin) Handler Uses

func (p *PromGin) Handler(responder http.Handler) http.Handler

func (*PromGin) HandlerGinFunc Uses

func (p *PromGin) HandlerGinFunc() gin.HandlerFunc

type PromResponder Uses

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

func (*PromResponder) ServeHTTP Uses

func (pr *PromResponder) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Prometheus Uses

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

Prometheus contains the metrics gathered by the instance and its path

func NewPrometheus Uses

func NewPrometheus(l logger.Logger, subsystem string, metricsList []*Metric) *Prometheus

NewPrometheus generates a new set of metrics with a certain subsystem name

func (*Prometheus) CounterWithLabelValues Uses

func (p *Prometheus) CounterWithLabelValues(id string, args ...string) prometheus.Counter

func (*Prometheus) Observe Uses

func (p *Prometheus) Observe(id string, d float64)

type PrometheusPushGateway Uses

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

PrometheusPushGateway contains the configuration for pushing to a Prometheus pushgateway (optional)

func NewPrometheusPushGateway Uses

func NewPrometheusPushGateway(l logger.Logger, pushGatewayURL, metricsURL string, pushIntervalSeconds time.Duration) *PrometheusPushGateway

SetPushGateway sends metrics to a remote pushgateway exposed on pushGatewayURL every pushIntervalSeconds. Metrics are fetched from metricsURL

func (*PrometheusPushGateway) Shutdown Uses

func (ppg *PrometheusPushGateway) Shutdown(ctx context.Context) error

type PubFunc Uses

type PubFunc func(start, end time.Time, reqSz, resSz int64, status, adddres, url string)

type PubGin Uses

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

func NewPubGin Uses

func NewPubGin(l logger.Logger, subsystem string, pub PubFunc) *PubGin

PubGin - publish stats

func (*PubGin) Handler Uses

func (p *PubGin) Handler(responder http.Handler) http.Handler

func (*PubGin) HandlerGinFunc Uses

func (p *PubGin) HandlerGinFunc() gin.HandlerFunc

type PubGinResponder Uses

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

func (*PubGinResponder) ServeHTTP Uses

func (pr *PubGinResponder) ServeHTTP(w http.ResponseWriter, r *http.Request)

type RequestCounterURLLabelMappingFn Uses

type RequestCounterURLLabelMappingFn func(c *gin.Context) string

RequestCounterURLLabelMappingFn is a function which can be supplied to the middleware to control the cardinality of the request counter's "url" label, which might be required in some contexts. For instance, if for a "/customer/:name" route you don't want to generate a time series for every possible customer name, you could use this function:

This can only use the request and params fields.

func(c *gin.Context) string {

url := c.Request.URL.String()
for _, p := range c.Params {
	if p.Key == "name" {
		url = strings.Replace(url, p.Value, ":name", 1)
		break
	}
}
return url

}

which would map "/customer/alice" and "/customer/bob" to their template "/customer/:name".

Package utils imports 13 packages (graph) and is imported by 3 packages. Updated 2018-08-15. Refresh now. Tools for package owners.