metrics

package
v0.0.0-...-3388463 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegistGin

func RegistGin(subsystem string, e *gin.Engine) error

RegistGin adds the middleware to a gin engine.(without use engine as a metrics server)

func RegistGinWithRouter

func RegistGinWithRouter(subsystem string, e *gin.Engine, metricsPath string) error

RegistGinWithRouter adds the middleware and metrics path to a gin engine.

func RegistGinWithRouterAuth

func RegistGinWithRouterAuth(subsystem string, e *gin.Engine, metricspath string, accounts gin.Accounts) error

RegistGinWithRouterAuth adds the middleware and metrics path to a gin engine with BasicAuth.

Types

type ProbeInfo

type ProbeInfo struct {
	ServiceName string
	Host        string
	Version     string
	ProbePath   string
	VersionPath string
	Uptime      time.Time
}

ProbeInfo store the info expored in probe url

func NewProbeInfo

func NewProbeInfo(servicename string, version string) *ProbeInfo

NewProbeInfo generates a new set of ProbeInfo with a certain subsystem name

func (*ProbeInfo) RegistPath

func (p *ProbeInfo) RegistPath(e *gin.Engine)

RegistPath regist Probe/Version paths to gin

func (*ProbeInfo) SetProbePath

func (p *ProbeInfo) SetProbePath(path string)

SetProbePath set Probe path

func (*ProbeInfo) SetVersionPath

func (p *ProbeInfo) SetVersionPath(path string)

SetVersionPath set Probe path

func (*ProbeInfo) Use

func (p *ProbeInfo) Use(e *gin.Engine)

Use adds the middleware to a gin engine.

type RequestCounterURLLabelMappingFn

type RequestCounterURLLabelMappingFn func(c *gin.Context) string

RequestCounterURLLabelMappingFn is a function which can be supplied to the middleware to control the cardinality of the request counter's "url" label, which might be required in some contexts. For instance, if for a "/customer/:name" route you don't want to generate a time series for every possible customer name, you could use this function:

func(c *gin.Context) string {
	url := c.Request.URL.Path
	for _, p := range c.Params {
		if p.Key == "name" {
			url = strings.Replace(url, p.Value, ":name", 1)
			break
		}
	}
	return url
}

which would map "/customer/alice" and "/customer/bob" to their template "/customer/:name".

Jump to

Keyboard shortcuts

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