middleware

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MetrAttrErr is the metric attribute for error
	MetrAttrErr           = "error"
	MetrAttrMethod        = "method"
	MetrAttrUrl           = "url"
	MetrAttrStatus        = "status"
	MetrAttrPathPattern   = "path_pattern"
	MetrAttrPath          = "path"
	MetrAttrHost          = "host"
	MetrAttrService       = "service"
	MetrAttrTargetService = "target_service"

	MetrHttpOut      = "http_out"
	MetrHttpOutDescr = "HTTP out response"
)

Variables

This section is empty.

Functions

func FirstErr

func FirstErr(err error) string

FirstErr returns the first part of error text before ':'

func Float64CounterGetInstrument

func Float64CounterGetInstrument(name string, options ...metric_api.Float64CounterOption) (metric_api.Float64Counter, error)

func FullErr

func FullErr(err error) string

FullErr returns the full error text. Be careful about the cardinality, if the error text has dynamic part(s) (see: Prometheus label)

func GetHost

func GetHost(r *http.Request) string

func GetMeter

func GetMeter(buildinfo model.BuildInfo, log *slog.Logger) metric_api.Meter

GetMeter returns the default meter. Inits meter and InstrumentRegs (if needed)

func Int64CounterGetInstrument

func Int64CounterGetInstrument(name string, options ...metric_api.Int64CounterOption) (metric_api.Int64Counter, error)

func NoErr

func NoErr(error) string

NoErr always returns "". Can be used to skip any error stats in the metrics

Types

type ErrFormatter

type ErrFormatter func(error) string

ErrFormatter is a func type to format metric error attribute

type InstrumentReg

type InstrumentReg[T any, O any] struct {
	// contains filtered or unexported fields
}

InstrumentReg stores the already registered instruments

func (*InstrumentReg[T, O]) GetInstrument

func (r *InstrumentReg[T, O]) GetInstrument(name string, options ...O) (T, error)

GetInstrument registers a new instrument, otherwise returns the already created.

Directories

Path Synopsis
Goroutine middlewares
Goroutine middlewares

Jump to

Keyboard shortcuts

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