Documentation ¶
Index ¶
- type Prometheus
- func (p *Prometheus) Auth(accounts gin.Accounts) PrometheusMiddlerwareBuilder
- func (p *Prometheus) Counter(counter *prometheus.CounterVec) PrometheusMiddlerwareBuilder
- func (p *Prometheus) Duration(observer prometheus.ObserverVec) PrometheusMiddlerwareBuilder
- func (p *Prometheus) Job(j string)
- func (p *Prometheus) ListenAddress(address string)
- func (p *Prometheus) PushGateway(pushGatewayURL, metricsURL string, pushIntervalSeconds time.Duration) PrometheusPushGatewayMiddlewareBuilder
- func (p *Prometheus) RequestSize(observer prometheus.ObserverVec) PrometheusMiddlerwareBuilder
- func (p *Prometheus) ResponseSize(observer prometheus.ObserverVec) PrometheusMiddlerwareBuilder
- func (p *Prometheus) UrlMapping(function URLLabelMappingFn) PrometheusMiddlerwareBuilder
- func (p *Prometheus) Use(e *gin.Engine)
- type PrometheusMiddlerwareBuilder
- type PrometheusPushGateway
- type PrometheusPushGatewayMiddlewareBuilder
- type URLLabelMappingFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Prometheus ¶
type Prometheus struct { MetricsPath string // contains filtered or unexported fields }
Prometheus contains the metrics gathered by the instance and its path
func NewBuilder ¶
func NewBuilder() *Prometheus
func (*Prometheus) Auth ¶
func (p *Prometheus) Auth(accounts gin.Accounts) PrometheusMiddlerwareBuilder
func (*Prometheus) Counter ¶
func (p *Prometheus) Counter(counter *prometheus.CounterVec) PrometheusMiddlerwareBuilder
func (*Prometheus) Duration ¶
func (p *Prometheus) Duration(observer prometheus.ObserverVec) PrometheusMiddlerwareBuilder
func (*Prometheus) ListenAddress ¶
func (p *Prometheus) ListenAddress(address string)
ListenAddress for exposing metrics on address. If not set, it will be exposed at the same address of the gin engine that is being used
func (*Prometheus) PushGateway ¶
func (p *Prometheus) PushGateway(pushGatewayURL, metricsURL string, pushIntervalSeconds time.Duration) PrometheusPushGatewayMiddlewareBuilder
PushGateway sends metrics to a remote pushgateway exposed on pushGatewayURL every pushIntervalSeconds. Metrics are fetched from metricsURL
func (*Prometheus) RequestSize ¶
func (p *Prometheus) RequestSize(observer prometheus.ObserverVec) PrometheusMiddlerwareBuilder
func (*Prometheus) ResponseSize ¶
func (p *Prometheus) ResponseSize(observer prometheus.ObserverVec) PrometheusMiddlerwareBuilder
func (*Prometheus) UrlMapping ¶
func (p *Prometheus) UrlMapping(function URLLabelMappingFn) PrometheusMiddlerwareBuilder
func (*Prometheus) Use ¶
func (p *Prometheus) Use(e *gin.Engine)
Use adds the middleware to a gin engine.
type PrometheusMiddlerwareBuilder ¶
type PrometheusMiddlerwareBuilder interface { Auth(accounts gin.Accounts) PrometheusMiddlerwareBuilder UrlMapping(function URLLabelMappingFn) PrometheusMiddlerwareBuilder Counter(counter *prometheus.CounterVec) PrometheusMiddlerwareBuilder Duration(observer prometheus.ObserverVec) PrometheusMiddlerwareBuilder RequestSize(observer prometheus.ObserverVec) PrometheusMiddlerwareBuilder ResponseSize(observer prometheus.ObserverVec) PrometheusMiddlerwareBuilder PushGateway(pushGatewayURL, metricsURL string, pushIntervalSeconds time.Duration) PrometheusPushGatewayMiddlewareBuilder Use(e *gin.Engine) }
type PrometheusPushGateway ¶
type PrometheusPushGateway struct {
// contains filtered or unexported fields
}
PrometheusPushGateway contains the configuration for pushing to a Prometheus pushgateway (optional)
type URLLabelMappingFn ¶
URLLabelMappingFn 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:
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".