metrics

package
v0.0.0-...-475c006 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidToken is returned when the request token is invalid.
	ErrInvalidToken = errors.New("invalid or missing token")
)

Functions

This section is empty.

Types

type Logger

type Logger struct{}

Logger implements the required logging interface for the http handler.

func (Logger) Println

func (Logger) Println(v ...interface{})

Println is used by the prometheus http handler to serve the registry.

type Metrics

type Metrics struct {
	Namespace string
	Token     string
	Registry  *prometheus.Registry
}

Metrics simply defines the basic metrics including the registry.

func New

func New(opts ...Option) *Metrics

New simply initializes the metrics handling including the go metrics.

func (*Metrics) Handler

func (m *Metrics) Handler() http.HandlerFunc

Handler initializes the prometheus middleware.

func (*Metrics) RegisterCounter

func (m *Metrics) RegisterCounter(counter *prometheus.CounterVec) *prometheus.CounterVec

RegisterCounter is used to transparently register a new counter.

func (*Metrics) RegisterHistogram

func (m *Metrics) RegisterHistogram(histogram *prometheus.HistogramVec) *prometheus.HistogramVec

RegisterHistogram is used to transparently register a new histogram.

type Option

type Option func(o *Options)

Option defines a single option function.

func WithNamespace

func WithNamespace(v string) Option

WithNamespace provides a function to set the namespace option.

func WithToken

func WithToken(v string) Option

WithToken provides a function to set the token option.

type Options

type Options struct {
	Namespace string
	Token     string
}

Options defines the available options for this package.

Jump to

Keyboard shortcuts

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