Documentation ¶
Overview ¶
Package metrics provides metrics collection functions and structs
Index ¶
Constants ¶
const ( // DefaultMetricsCollectionInterval is the default amount of time we wait between runtime metrics queries. DefaultMetricsCollectionInterval = 2 * time.Second // Prometheus represents the popular time series database. Prometheus = "prometheus" )
Variables ¶
var ( // Providers represents what this library offers to external users in the form of dependencies. Providers = wire.NewSet( ProvideUnitCounterProvider, ProvideMetricsInstrumentationHandlerForServer, ) )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Provider indicates where our metrics should go. Provider string `json:"provider" mapstructure:"provider" toml:"provider,omitempty"` // RouteToken indicates how the metrics route should be authenticated. RouteToken string `json:"route_token" mapstructure:"route_token" toml:"route_token,omitempty"` // RuntimeMetricsCollectionInterval is the interval we collect runtime statistics at. RuntimeMetricsCollectionInterval time.Duration `` /* 146-byte string literal not displayed */ // contains filtered or unexported fields }
Config contains settings related to .
func (*Config) ProvideInstrumentationHandler ¶
func (cfg *Config) ProvideInstrumentationHandler(logger logging.Logger) (InstrumentationHandler, error)
ProvideInstrumentationHandler provides an instrumentation handler.
func (*Config) ProvideUnitCounterProvider ¶
func (cfg *Config) ProvideUnitCounterProvider(logger logging.Logger) (UnitCounterProvider, error)
ProvideUnitCounterProvider provides an instrumentation handler.
type CounterName ¶
type CounterName string
CounterName is a type alias for dependency injection's sake.
type HandlerInstrumentationFunc ¶
type HandlerInstrumentationFunc func(http.HandlerFunc) http.HandlerFunc
HandlerInstrumentationFunc blah.
type InstrumentationHandler ¶
InstrumentationHandler is an obligatory alias.
func ProvideMetricsInstrumentationHandlerForServer ¶
func ProvideMetricsInstrumentationHandlerForServer(cfg *Config, logger logging.Logger) (InstrumentationHandler, error)
ProvideMetricsInstrumentationHandlerForServer provides a metrics.InstrumentationHandler from a config for our server.
type SpanFormatter ¶
SpanFormatter formats the name of a span given a request.
type UnitCounter ¶
type UnitCounter interface { Increment(ctx context.Context) IncrementBy(ctx context.Context, val int64) Decrement(ctx context.Context) }
UnitCounter describes a counting interface for things like total user counts. Meant to handle integers exclusively.
func EnsureUnitCounter ¶
func EnsureUnitCounter(ucp UnitCounterProvider, logger logging.Logger, counterName CounterName, description string) UnitCounter
EnsureUnitCounter always provides a valid UnitCounter.
type UnitCounterProvider ¶
type UnitCounterProvider func(name, description string) UnitCounter
UnitCounterProvider is a function that provides a UnitCounter and an error.
func ProvideUnitCounterProvider ¶
func ProvideUnitCounterProvider(cfg *Config, logger logging.Logger) (UnitCounterProvider, error)
ProvideUnitCounterProvider provides a metrics.InstrumentationHandler from a config for our server.