metrics

package
v0.38.5-beta.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package contains the collection of prometheus meters/counters and related update methods

Index

Constants

This section is empty.

Variables

View Source
var (
	// RequestTotal provides the total number of requests
	RequestTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "ory_oathkeeper_requests_total",
			Help: "Total number of requests",
		},
		[]string{"service", "method", "request", "status_code"},
	)
	// HistogramRequestDuration provides the duration of requests
	HistogramRequestDuration = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name:    "ory_oathkeeper_request_duration_seconds",
			Help:    "Time spent serving requests.",
			Buckets: prometheus.DefBuckets,
		},
		[]string{"service", "method", "request", "status_code"},
	)
)

Functions

This section is empty.

Types

type Middleware

type Middleware struct {
	// Name is the name of the application as recorded in latency metrics
	Name string
	// Prometheus repository
	Prometheus *PrometheusRepository
	// contains filtered or unexported fields
}

Middleware is a middleware handler that logs the request as it goes in and the response as it goes out.

func NewMiddleware

func NewMiddleware(prom *PrometheusRepository, name string) *Middleware

NewMiddleware returns a new *Middleware, yay!

func (*Middleware) CollapsePaths

func (m *Middleware) CollapsePaths(flag bool) *Middleware

CollapsePaths if set to true, forces the value of the "request" label of the prometheus request metrics to be collapsed to the first context path segment only. eg. (when set to true):

  • /decisions/service/my-service -> /decisions
  • /decisions -> /decisions

func (*Middleware) ExcludePaths

func (m *Middleware) ExcludePaths(paths ...string) *Middleware

ExcludePaths adds new URL paths to be ignored during logging. The URL u is parsed, hence the returned error

func (*Middleware) ServeHTTP

func (m *Middleware) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type PrometheusRepository

type PrometheusRepository struct {
	Registry *prometheus.Registry
	// contains filtered or unexported fields
}

PrometheusRepository provides methods to manage prometheus metrics

func NewPrometheusRepository

func NewPrometheusRepository(logger *logrusx.Logger) *PrometheusRepository

NewPrometheusRepository creates a new prometheus repository with the given settings

func (*PrometheusRepository) RequestDurationObserve

func (r *PrometheusRepository) RequestDurationObserve(service, request, method string, statusCode int) func(float64)

RequestDurationObserve tracks request durations

func (*PrometheusRepository) UpdateRequest

func (r *PrometheusRepository) UpdateRequest(service, request, method string, statusCode int)

UpdateRequest tracks total requests done

type RequestDurationObserve

type RequestDurationObserve func(histogram *prometheus.HistogramVec, service, request, method string, statusCode int) func(float64)

RequestDurationObserve tracks request durations

type UpdateRequest

type UpdateRequest func(counter *prometheus.CounterVec, service, request, method string, statusCode int)

UpdateRequest tracks total requests done

Jump to

Keyboard shortcuts

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