Documentation ¶
Overview ¶
Package prometheus implements the metrics interface with Prometheus.
Index ¶
- Constants
- type Client
- func (c *Client) Close() error
- func (c *Client) IncErrorCounter(task, operation, code string)
- func (c *Client) IncLogLevelCounter(level string)
- func (c *Client) InstrumentDB(dbName string, db *sql.DB) error
- func (c *Client) InstrumentHandler(path string, handler http.HandlerFunc) http.Handler
- func (c *Client) InstrumentRoundTripper(next http.RoundTripper) http.RoundTripper
- func (c *Client) MetricsHandlerFunc() http.HandlerFunc
- type Option
- func WithCollector(m prometheus.Collector) Option
- func WithHandlerOpts(opts promhttp.HandlerOpts) Option
- func WithInboundRequestDurationBuckets(buckets []float64) Option
- func WithInboundRequestSizeBuckets(buckets []float64) Option
- func WithInboundResponseSizeBuckets(buckets []float64) Option
- func WithOutboundRequestDurationBuckets(buckets []float64) Option
Constants ¶
const ( // NameAPIRequests is the name of the collector that counts the total inbound http requests. NameAPIRequests = "api_requests_total" // NameInFlightRequests is the name of the collector that counts in-flight inbound http requests. NameInFlightRequests = "in_flight_requests" // NameRequestDuration is the name of the collector that measures the inbound http request duration in seconds. NameRequestDuration = "request_duration_seconds" // NameRequestSize is the name of the collector that measures the http request size in bytes. NameRequestSize = "request_size_bytes" // NameResponseSize is the name of the collector that measures the http response size in bytes. NameResponseSize = "response_size_bytes" // NameOutboundRequests is the name of the collector that measures the number of outbound requests. NameOutboundRequests = "outbound_requests_total" // NameOutboundRequestsDuration is the name of the collector that measures the outbound requests duration in seconds. NameOutboundRequestsDuration = "outbound_request_duration_seconds" // NameOutboundInFlightRequests is the name of the collector that counts in-flight outbound http requests. NameOutboundInFlightRequests = "outbound_in_flight_requests" // NameErrorLevel is the name of the collector that counts the number of errors for each log severity level. NameErrorLevel = "error_level_total" // NameErrorCode is the name of the collector that counts the number of errors by task, operation and error code. NameErrorCode = "error_code_total" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents the state type of this client.
func (*Client) IncErrorCounter ¶
IncErrorCounter increments the number of errors by task, operation and error code.
func (*Client) IncLogLevelCounter ¶
IncLogLevelCounter counts the number of errors for each log severity level.
func (*Client) InstrumentDB ¶
InstrumentDB wraps a sql.DB to collect metrics.
func (*Client) InstrumentHandler ¶
InstrumentHandler wraps an http.Handler to collect Prometheus metrics.
func (*Client) InstrumentRoundTripper ¶
func (c *Client) InstrumentRoundTripper(next http.RoundTripper) http.RoundTripper
InstrumentRoundTripper is a middleware that wraps the provided http.RoundTripper to observe the request result with default metrics.
func (*Client) MetricsHandlerFunc ¶
func (c *Client) MetricsHandlerFunc() http.HandlerFunc
MetricsHandlerFunc returns an http handler function to serve the metrics endpoint.
type Option ¶
Option is the interface that allows to set client options.
func WithCollector ¶
func WithCollector(m prometheus.Collector) Option
WithCollector register a new generic collector.
func WithHandlerOpts ¶
func WithHandlerOpts(opts promhttp.HandlerOpts) Option
WithHandlerOpts sets the options how to serve metrics via an http.Handler. The zero value of HandlerOpts is a reasonable default.
func WithInboundRequestDurationBuckets ¶
WithInboundRequestDurationBuckets set the buckets size in seconds for the inbound requests duration.
func WithInboundRequestSizeBuckets ¶
WithInboundRequestSizeBuckets set the buckets size in bytes for the inbound requests.
func WithInboundResponseSizeBuckets ¶
WithInboundResponseSizeBuckets set the buckets size in bytes for the inbound response.
func WithOutboundRequestDurationBuckets ¶
WithOutboundRequestDurationBuckets set the buckets size in seconds for the outbound requests duration.