metrics

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeHandler

func MakeHandler(serviceRequests []gkBoot.ServiceRequest, option ...config.MetricsOption) (
	http.Handler,
	*config.MetricsConfig,
)

func NewServiceBuilder

func NewServiceBuilder(srv service.Service, option ...config.MetricsOption) *serviceBuilder

NewServiceBuilder

This will wire up a service-only object that can re-use logging and metrics wrappers established elsewhere while maintaining the REST Request-Service established pattern. The associated Mixin chains must be called to identify which functionality is wired in.

Unavailable config options (using the following will not do anything):

config.WithServiceDecorator
config.WithHttpServerOpts
config.WithOpenMetrics
config.WithMetricsPath
config.WithHttpPort
config.WithRootPath
config.WithStrictAPI

func Start

func Start(serviceRequests []gkBoot.ServiceRequest, option ...config.MetricsOption) (*http.Server, <-chan struct{})

Start

Starts the http server for GkBoot. Returns the running http.Server and a blocking function that waits until a signal (syscall.SIGINT, syscall.SIGTERM, syscall.SIGALRM) is sent.

func StartServer

func StartServer(serviceRequests []gkBoot.ServiceRequest, option ...config.MetricsOption)

StartServer

Convenience method.

If the service and blocker of Start are unnecessary, this conveniently does all of that for us.

func StartServerWithHandler

func StartServerWithHandler(serviceRequests []gkBoot.ServiceRequest, option ...config.MetricsOption)

func StartWithHandler

func StartWithHandler(serviceRequests []gkBoot.ServiceRequest, option ...config.MetricsOption) (
	*http.Server,
	<-chan struct{},
)

func WrapServiceMetrics

func WrapServiceMetrics(service service.Service) service.Service

Types

type MappedMetrics

type MappedMetrics struct {
	Counters   map[string]prometheus.Counter
	Histograms map[string]prometheus.Histogram
	Gauges     map[string]prometheus.Gauge
}

MappedMetrics

Contains the concrete metrics defined by the service. This is passed to the configuration

type Metered

type Metered interface {
	// Metrics
	//
	// Returns a set of definitions for the MappedMetrics. This will provide the metrics
	// wrapper with definitions that will be used for your service. This object will be
	// re-used and passed along to the UpdateMetrics function after every request.
	Metrics() *MappedMetrics
	// UpdateMetrics
	//
	// Called after every response sent from the wrapped service. This gathers the necessary
	// data points so that metrics may be derived from the service call. The MappedMetrics
	// contain all metrics mapped for only the implementing service.
	UpdateMetrics(ctx context.Context, request interface{}, response interface{}, startTime time.Time,
		mappedMetrics *MappedMetrics)
	service.Service
}

Metered

This interface indicates that the service will maintain its ability to serve but also enable the processing of metrics after each request. The ProcessRequestMetrics function will be called on the deferred stack as a result of the automatic wiring.

Directories

Path Synopsis
test

Jump to

Keyboard shortcuts

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