metrics

package
v0.0.0-...-9518a5e Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package metrics provides metrics collection functions and structs

Index

Constants

View Source
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

View Source
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.

func (*Config) ValidateWithContext

func (cfg *Config) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates the config struct.

type CounterName

type CounterName string

CounterName is a type alias for dependency injection's sake.

type Handler

type Handler http.Handler

Handler is the Handler that provides metrics data to scraping services.

type HandlerInstrumentationFunc

type HandlerInstrumentationFunc func(http.HandlerFunc) http.HandlerFunc

HandlerInstrumentationFunc blah.

type InstrumentationHandler

type InstrumentationHandler http.Handler

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 Namespace

type Namespace string

Namespace is a types alias for dependency injection's sake.

type SpanFormatter

type SpanFormatter func(*http.Request) string

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.

Directories

Path Synopsis
Package mock provides mockable implementations of every interface defined in the outer metrics package.
Package mock provides mockable implementations of every interface defined in the outer metrics package.

Jump to

Keyboard shortcuts

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