metrics

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 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"
)
View Source
const (
	HTTPRequestErrorDo                   = "do_request_error"
	HTTPRequestErrorDecodeBody           = "decode_body_error"
	HTTPRequestErrorUnexpectedStatusCode = "unexpected_status_code"
)
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
	TokenClaimsCache          *lrucache.PrometheusMetrics
	TokenNegativeCache        *lrucache.PrometheusMetrics
}

PrometheusMetrics represents the collector of metrics.

func GetPrometheusMetrics

func GetPrometheusMetrics(instance string, source string) *PrometheusMetrics

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.

Jump to

Keyboard shortcuts

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