prometheus

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 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

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

Variables

This section is empty.

Functions

func NewMetric

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

NewMetric associates prometheus.Collector based on Metric.Type

Types

type ContextHandlerFunc

type ContextHandlerFunc func(c *contextHttp.HttpContext) error

type FavContextKeyType

type FavContextKeyType string

type Metric

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

type Prometheus

type Prometheus struct {
	Ppg PushGateway

	MetricsList []*Metric
	MetricsPath string
	Subsystem   string

	RequestCounterURLLabelMappingFunc  RequestCounterLabelMappingFunc
	RequestCounterHostLabelMappingFunc RequestCounterLabelMappingFunc

	URLLabelFromContext string
	Datacontext         context.Context
	// contains filtered or unexported fields
}

func NewPrometheus

func NewPrometheus() *Prometheus

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

func (*Prometheus) HandlerFunc

func (p *Prometheus) HandlerFunc() ContextHandlerFunc

HandlerFunc defines handler function for middleware

func (*Prometheus) RecordDynamicMetric

func (p *Prometheus) RecordDynamicMetric(name string, metricType string, value float64, labels map[string]string) error

RecordDynamicMetric records a dynamic metric based on type (counter, gauge, histogram)

func (*Prometheus) SetPushGateway

func (p *Prometheus) SetPushGateway()

func (*Prometheus) SetPushGatewayJob

func (p *Prometheus) SetPushGatewayJob(j string)

func (*Prometheus) SetPushGatewayUrl

func (p *Prometheus) SetPushGatewayUrl(pushGatewayURL, metricspath string)

func (*Prometheus) SetPushIntervalThreshold

func (p *Prometheus) SetPushIntervalThreshold(isTurn bool, pushIntervalThreshold int)

type PushGateway

type PushGateway struct {
	CounterPush           bool
	PushInterval          time.Duration
	PushIntervalThreshold int
	PushGatewayURL        string
	Job                   string
	// contains filtered or unexported fields
}

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

type RequestCounterLabelMappingFunc

type RequestCounterLabelMappingFunc func(c *contextHttp.HttpContext) string

Jump to

Keyboard shortcuts

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