Back to godoc.org
github.com/alfred-zhong/prome

Package prome

v0.0.11
Latest Go to latest

The latest major version is .

Published: Apr 27, 2020 | License: MIT | Module: github.com/alfred-zhong/prome

Index

Variables

var DefaultRequestDurationSummaryObjectives = map[float64]float64{
	0.5:  0.05,
	0.9:  0.01,
	0.95: 0.005,
	0.99: 0.001,
}

DefaultRequestDurationSummaryObjectives represents objectives of request duration middleware summary.

type Client

type Client struct {
	ServiceName string
	Path        string

	// Enable metrics of runtime. Default enabled.
	EnableRuntime bool

	// Labels which will always be attached to metrics.
	ConstLabels prometheus.Labels
	// contains filtered or unexported fields
}

Client represents the client for prometheus server to pull data from.

func NewClient

func NewClient(serviceName string, path string) *Client

NewClient creates and returns a new Client instance.

func (*Client) AddCounter

func (c *Client) AddCounter(opts prometheus.CounterOpts) prometheus.Counter

AddCounter creates a new Counter based on the provided CounterOpts which will be registered automatically when client serves.

func (*Client) AddCounterVec

func (c *Client) AddCounterVec(
	opts prometheus.CounterOpts, labelNames []string,
) *prometheus.CounterVec

AddCounterVec creates a new CounterVec based on the provided CounterOpts and partitioned by the given label names which will be registered automatically when client serves.

func (*Client) AddGauge

func (c *Client) AddGauge(opts prometheus.GaugeOpts) prometheus.Gauge

AddGauge creates a new Gauge based on the provided GaugeOpts which will be registered automatically when client serves.

func (*Client) AddGaugeVec

func (c *Client) AddGaugeVec(
	opts prometheus.GaugeOpts, labelNames []string,
) *prometheus.GaugeVec

AddGaugeVec creates a new GaugeVec based on the provided GaugeOpts and partitioned by the given label names which will be registered automatically when client serves.

func (*Client) AddHistogram

func (c *Client) AddHistogram(opts prometheus.HistogramOpts) prometheus.Histogram

AddHistogram creates a new Histogram based on the provided HistogramOpts which will be registered automatically when client serves.

func (*Client) AddHistogramVec

func (c *Client) AddHistogramVec(
	opts prometheus.HistogramOpts, labelNames []string,
) *prometheus.HistogramVec

AddHistogramVec creates a new HistogramVec based on the provided HistogramOpts and partitioned by the given label names which will be registered automatically when client serves.

func (*Client) AddSummary

func (c *Client) AddSummary(opts prometheus.SummaryOpts) prometheus.Summary

AddSummary creates a new Summary based on the provided SummaryOpts which will be registered automatically when client serves.

func (*Client) AddSummaryVec

func (c *Client) AddSummaryVec(
	opts prometheus.SummaryOpts, labelNames []string,
) *prometheus.SummaryVec

AddSummaryVec creates a new SummaryVec based on the provided SummaryOpts and partitioned by the given label names which will be registered automatically when client serves.

func (*Client) Close

func (c *Client) Close() error

Close shutdown of listening.

func (*Client) Handler

func (c *Client) Handler() http.Handler

Handler returns the http handler which can be used for fetch metrics data.

func (*Client) ListenAndServe

func (c *Client) ListenAndServe(addr string) error

ListenAndServe listen on the addr and provide access for prometheus server to pull data.

func (*Client) MiddlewareRequestCount

func (c *Client) MiddlewareRequestCount(metricsName string) gin.HandlerFunc

MiddlewareRequestCount returns a gin HandlerFunc which can be used as middleware to capture request count.

func (*Client) MiddlewareRequestDuration

func (c *Client) MiddlewareRequestDuration(
	metricsName string, objectives map[float64]float64,
) gin.HandlerFunc

MiddlewareRequestDuration returns a gin handler which can be used as middleware to capture request duration summary.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier