utils

package
v0.0.0-...-01ed203 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthConfig

func AuthConfig(filterOptions ...AuthConfigOptions) (*promauth.Config, error)

AuthConfig returns promauth.Config based on the given params

func Prefix

func Prefix(path string) string

Prefix returns "/vmalert/" prefix if it is missing in the path.

Types

type AuthConfigOptions

type AuthConfigOptions func(config *promauth.HTTPClientConfig)

AuthConfigOptions options which helps build promauth.Config

func WithBasicAuth

func WithBasicAuth(username, password, passwordFile string) AuthConfigOptions

WithBasicAuth returns AuthConfigOptions and initialized promauth.BasicAuthConfig based on given params

func WithBearer

func WithBearer(token, tokenFile string) AuthConfigOptions

WithBearer returns AuthConfigOptions and set BearerToken or BearerTokenFile based on given params

func WithHeaders

func WithHeaders(headers string) AuthConfigOptions

WithHeaders returns AuthConfigOptions and set Headers based on the given params

func WithOAuth

func WithOAuth(clientID, clientSecret, clientSecretFile, tokenURL, scopes string, endpointParams map[string]string) AuthConfigOptions

WithOAuth returns AuthConfigOptions and set OAuth params based on given params

type Counter

type Counter struct {
	*metrics.Counter
	// contains filtered or unexported fields
}

Counter is a metrics.Counter with Name

func GetOrCreateCounter

func GetOrCreateCounter(name string) *Counter

GetOrCreateCounter creates a new Counter with the given name

func (Counter) Unregister

func (nm Counter) Unregister()

Unregister removes the metric by name from default registry

type ErrGroup

type ErrGroup struct {
	// contains filtered or unexported fields
}

ErrGroup accumulates multiple errors and produces single error message.

func (*ErrGroup) Add

func (eg *ErrGroup) Add(err error)

Add adds a new error to group. Is thread-safe.

func (*ErrGroup) Err

func (eg *ErrGroup) Err() error

Err checks if group contains at least one error.

func (*ErrGroup) Error

func (eg *ErrGroup) Error() string

Error satisfies Error interface

type Gauge

type Gauge struct {
	*metrics.Gauge
	// contains filtered or unexported fields
}

Gauge is a metrics.Gauge with Name

func GetOrCreateGauge

func GetOrCreateGauge(name string, f func() float64) *Gauge

GetOrCreateGauge creates a new Gauge with the given name

func (Gauge) Unregister

func (nm Gauge) Unregister()

Unregister removes the metric by name from default registry

type Summary

type Summary struct {
	*metrics.Summary
	// contains filtered or unexported fields
}

Summary is a metrics.Summary with Name

func GetOrCreateSummary

func GetOrCreateSummary(name string) *Summary

GetOrCreateSummary creates a new Summary with the given name

func (Summary) Unregister

func (nm Summary) Unregister()

Unregister removes the metric by name from default registry

Jump to

Keyboard shortcuts

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