prometheus

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB float64 = 1 << (10 * iota)
	MB
)

Variables

View Source
var WithReqDurBuckets = func(buckets []float64) PrometheusOption {
	return func(p *Prometheus) {
		if len(buckets) > 0 {
			p.ReqDurBuckets = buckets
		}
	}
}
View Source
var WithReqSzBuckets = func(buckets []float64) PrometheusOption {
	return func(p *Prometheus) {
		if len(buckets) > 0 {
			p.ReqSzBuckets = buckets
		}
	}
}
View Source
var WithResSzBuckets = func(buckets []float64) PrometheusOption {
	return func(p *Prometheus) {
		if len(buckets) > 0 {
			p.ResSzBuckets = buckets
		}
	}
}
View Source
var WithSubsystem = func(subsystem string) PrometheusOption {
	return func(p *Prometheus) {
		if subsystem != "" {
			p.Subsystem = subsystem
		}
	}
}

Functions

This section is empty.

Types

type IResponseWriter

type IResponseWriter interface {
	http.ResponseWriter

	StatusCode() int
	Size() int
}

type Prometheus

type Prometheus struct {
	ReqDurBuckets, ReqSzBuckets, ResSzBuckets []float64

	Subsystem string

	Ppg PushGateway
	// contains filtered or unexported fields
}

Prometheus contains the metrics gathered by the instance and its path

func NewPrometheus

func NewPrometheus(options ...PrometheusOption) *Prometheus

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

func (*Prometheus) HandlerFunc

func (p *Prometheus) HandlerFunc(next func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)

HandlerFunc defines handler function for middleware

func (*Prometheus) Push

func (p *Prometheus) Push(pushGatewayURL string, pushIntervalSecs int, job string)

type PrometheusOption

type PrometheusOption func(p *Prometheus)

type PushGateway

type PushGateway struct {
	// Push interval in seconds
	//lint:ignore ST1011 renaming would be breaking change
	PushIntervalSeconds time.Duration

	// Push Gateway URL in format http://domain:port
	// where JOBNAME can be any string of your choice
	PushGatewayURL string

	// pushgateway job name, defaults to "recommend"
	Job string
}

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

type RequestCounterLabelMappingFunc

type RequestCounterLabelMappingFunc func(req *http.Request) string

Jump to

Keyboard shortcuts

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