metrics

package
v0.0.0-...-c6f47ca Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//MetricTypeFeed defines type for feed metric
	MetricTypeFeed = "feed"
	//MetricTypeTotal defines type for total metric
	MetricTypeTotal = "total"
	//MetricTypeFailed defines type for failed metric
	MetricTypeFailed = "failed"
	//MetricTypeSucceeded defines type for succeeded metric
	MetricTypeSucceeded = "succeeded"
)
View Source
const (
	//MetricsAddressCtxKey defines key for context value of the addres for server
	MetricsAddressCtxKey = "metricsServerAddress"
)

Variables

This section is empty.

Functions

func RunServer

func RunServer(ctx context.Context) (<-chan error, <-chan struct{})

RunServer - run server on the provided address and expose /metrics endpoint return 2 channels: first for getting error messages and second channel idenifies status of the server if second channel will be closed - server exited Context should contain under key "serverAddressMetrics" string with local address to which it will be binded If context cancelled - server also exits

Types

type Adder

type Adder interface {
	Add(float64)
}

Adder add value from param to internal value Gauge and Counter both support method Add the only difference is that val could not be negative for Counter those metrics are thread safe and use package atomic no need to add another atomic operations

type Container

type Container map[string]map[string]Adder

Container holds all metrics

func NewMetrics

func NewMetrics(listURL []*url.URL) Container

NewMetrics creates container with all metrics per feed

func (Container) GetMetric

func (c Container) GetMetric(key, typeMetric string) (Adder, error)

GetMetric returns metric configured. If metric could not be found returns error.

func (Container) IncrementMetric

func (c Container) IncrementMetric(key, metricType string) error

IncrementMetric increments metric

Jump to

Keyboard shortcuts

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