metrics

package
v0.9.30 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package metrics implements collection of common performance metrics.

It uses the Go implementation of the Coda Hale metrics library:

https://github.com/dropwizard/metrics https://github.com/rcrowley/go-metrics

The collected metrics include detailed information about Skipper's relevant processes while serving requests - looking up routes, filters (aggregate and individual), backend communication and forwarding the response to the client.

Options

To enable metrics, it needs to be initialized with a Listener address. In this case, Skipper will start an additional http listener, where the current metrics values can be downloaded.

You can define a custom Prefix to every reported metrics key. This allows you to avoid conflicts between Skipper's metrics and other systems if you aggregate them later in some monitoring system. The default prefix is "skipper."

You can also enable some Go garbage collector and runtime metrics using EnableDebugGcMetrics and EnableRuntimeMetrics, respectively.

REST API

This listener accepts GET requests on the /metrics endpoint like any other REST api. A request to "/metrics" should return a JSON response including all the collected metrics. Please note that a lot of metrics are created lazily whenever a request triggers them. This means that the API response will depend on the current routes and the filters used. In the case there are no metrics due to inactivity, the API will return 404.

You can also query for specific metrics, individually or by prefix matching. You can either use the metrics key name and you should get back only the values for that particular key or a prefix in which case you should get all the metrics that share the same prefix.

If you request an unknown key or prefix the response will be an HTTP 404.

Index

Constants

View Source
const (
	KeyRouteLookup      = "routelookup"
	KeyRouteFailure     = "routefailure"
	KeyFilterRequest    = "filter.%s.request"
	KeyFiltersRequest   = "allfilters.request.%s"
	KeyProxyBackend     = "backend.%s"
	KeyProxyBackendHost = "backendhost.%s"
	KeyFilterResponse   = "filter.%s.response"
	KeyFiltersResponse  = "allfilters.response.%s"
	KeyResponse         = "response.%d.%s.skipper.%s"
	KeyServeRoute       = "serveroute.%s.%s.%d"
	KeyServeHost        = "servehost.%s.%s.%d"

	KeyErrorsBackend   = "errors.backend.%s"
	KeyErrorsStreaming = "errors.streaming.%s"
)

Variables

This section is empty.

Functions

func Init

func Init(o Options)

Initializes the collection of metrics.

Types

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}
var (
	Default *Metrics
	Void    *Metrics
)

func New

func New(o Options) *Metrics

func NewVoid

func NewVoid() *Metrics

func (*Metrics) IncErrorsBackend

func (m *Metrics) IncErrorsBackend(routeId string)

func (*Metrics) IncErrorsStreaming

func (m *Metrics) IncErrorsStreaming(routeId string)

func (*Metrics) IncRoutingFailures

func (m *Metrics) IncRoutingFailures()

func (*Metrics) MeasureAllFiltersRequest

func (m *Metrics) MeasureAllFiltersRequest(routeId string, start time.Time)

func (*Metrics) MeasureAllFiltersResponse

func (m *Metrics) MeasureAllFiltersResponse(routeId string, start time.Time)

func (*Metrics) MeasureBackend

func (m *Metrics) MeasureBackend(routeId string, start time.Time)

func (*Metrics) MeasureBackendHost

func (m *Metrics) MeasureBackendHost(routeBackendHost string, start time.Time)

func (*Metrics) MeasureFilterRequest

func (m *Metrics) MeasureFilterRequest(filterName string, start time.Time)

func (*Metrics) MeasureFilterResponse

func (m *Metrics) MeasureFilterResponse(filterName string, start time.Time)

func (*Metrics) MeasureResponse

func (m *Metrics) MeasureResponse(code int, method string, routeId string, start time.Time)

func (*Metrics) MeasureRouteLookup

func (m *Metrics) MeasureRouteLookup(start time.Time)

func (*Metrics) MeasureServe

func (m *Metrics) MeasureServe(routeId, host, method string, code int, start time.Time)

type Options

type Options struct {
	// Network address where the current metrics values
	// can be pulled from. If not set, the collection of
	// the metrics is disabled.
	Listener string

	// Common prefix for the keys of the different
	// collected metrics.
	Prefix string

	// If set, garbage collector metrics are collected
	// in addition to the http traffic metrics.
	EnableDebugGcMetrics bool

	// If set, Go runtime metrics are collected in
	// addition to the http traffic metrics.
	EnableRuntimeMetrics bool

	// If set, detailed total response time metrics will be collected
	// for each route, additionally grouped by status and method.
	EnableServeRouteMetrics bool

	// If set, detailed total response time metrics will be collected
	// for each host, additionally grouped by status and method.
	EnableServeHostMetrics bool

	// If set, detailed response time metrics will be collected
	// for each backend host
	EnableBackendHostMetrics bool

	// EnableProfile exposes profiling information on /pprof of the
	// metrics listener.
	EnableProfile bool
}

Options for initializing metrics collection.

Jump to

Keyboard shortcuts

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