metrics

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package metrics provides helpers for working with the library metrics.

Index

Constants

View Source
const (
	PrometheusLibInstanceLabel = "lib_instance"
	PrometheusLibSourceLabel   = "lib_source"
)
View Source
const (
	HTTPClientRequestLabelMethod     = "method"
	HTTPClientRequestLabelURL        = "url"
	HTTPClientRequestLabelStatusCode = "status_code"
	HTTPClientRequestLabelError      = "error"

	GRPCClientRequestLabelMethod = "grpc_method"
	GRPCClientRequestLabelCode   = "grpc_code"

	TokenIntrospectionLabelStatus = "status"
)
View Source
const (
	HTTPRequestErrorDo                   = "do_request_error"
	HTTPRequestErrorDecodeBody           = "decode_body_error"
	HTTPRequestErrorUnexpectedStatusCode = "unexpected_status_code"

	TokenIntrospectionStatusActive            = "active"
	TokenIntrospectionStatusNotActive         = "not_active"
	TokenIntrospectionStatusNotNeeded         = "not_needed"
	TokenIntrospectionStatusNotIntrospectable = "not_introspectable"
	TokenIntrospectionStatusInvalidClaims     = "invalid_claims"
	TokenIntrospectionStatusError             = "error"
)
View Source
const DefaultPrometheusLibInstanceLabel = "default"
View Source
const PrometheusNamespace = "go_authkit"

Variables

This section is empty.

Functions

func PrometheusLabels

func PrometheusLabels() prometheus.Labels

Types

type PrometheusMetrics

type PrometheusMetrics struct {
	HTTPClientRequestDuration *prometheus.HistogramVec
	GRPCClientRequestDuration *prometheus.HistogramVec
	TokenIntrospectionsTotal  *prometheus.CounterVec
	TokenClaimsCache          *lrucache.PrometheusMetrics
	TokenNegativeCache        *lrucache.PrometheusMetrics
	EndpointDiscoveryCache    *lrucache.PrometheusMetrics
}

PrometheusMetrics represents the collector of metrics.

func GetPrometheusMetrics

func GetPrometheusMetrics(instance string, source Source) *PrometheusMetrics

func (*PrometheusMetrics) IncTokenIntrospectionsTotal added in v0.12.0

func (pm *PrometheusMetrics) IncTokenIntrospectionsTotal(status string)

func (*PrometheusMetrics) MustCurryWith

func (pm *PrometheusMetrics) MustCurryWith(labels prometheus.Labels) *PrometheusMetrics

MustCurryWith curries the metrics collector with the provided labels.

func (*PrometheusMetrics) MustRegister

func (pm *PrometheusMetrics) MustRegister()

MustRegister does registration of metrics collector in Prometheus and panics if any error occurs.

func (*PrometheusMetrics) ObserveGRPCClientRequest

func (pm *PrometheusMetrics) ObserveGRPCClientRequest(
	method string, code grpccodes.Code, elapsed time.Duration,
)

func (*PrometheusMetrics) ObserveHTTPClientRequest

func (pm *PrometheusMetrics) ObserveHTTPClientRequest(
	method string, targetURL string, statusCode int, elapsed time.Duration, errorType string,
)

func (*PrometheusMetrics) Unregister

func (pm *PrometheusMetrics) Unregister()

Unregister cancels registration of metrics collector in Prometheus.

type Source added in v0.12.0

type Source string
const (
	SourceJWKSClient        Source = "jwks_client"
	SourceJWTParser         Source = "jwt_parser"
	SourceGRPCClient        Source = "grpc_client"
	SourceTokenIntrospector Source = "token_introspector"
	SourceTokenProvider     Source = "token_provider"
	SourceHTTPMiddleware    Source = "http_middleware"
)

Jump to

Keyboard shortcuts

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