metrics

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TelegramMessageEventType     = "message"
	TelegramInlineQueryEventType = "inline"
)

Variables

This section is empty.

Functions

func HandlerFor

func HandlerFor(m Metrics, o Options) http.Handler

HandlerFor returns a collection of metrics handlers.

func NewDefaultHandler

func NewDefaultHandler(o Options) http.Handler

NewDefaultHandler returns a default metrics handler.

Types

type Metrics

type Metrics interface {
	IncTelegramCommands(cmd string)
	IncTelegramEventsIncoming(eventType string)
	IncTelegramEventsOutgoing(eventType string)
	RegisterHandler(path string, handler *http.ServeMux)
}

Metrics is the generic interface that all the required backends should implement to be a fabtcg bot metrics compatible backend.

type Options

type Options struct {
	// Enable metrics
	Enabled bool

	// Common prefix for the keys of the different
	// collected metrics.
	Prefix string

	// EnableProfile exposes profiling information on /pprof of the
	// metrics listener.
	EnableProfile bool

	// enables go runtime metrics
	EnableRuntimeMetrics bool

	// A new registry is created if this option is nil.
	PrometheusRegistry *prometheus.Registry
}

Options for initializing metrics collection.

func DefaultOptions

func DefaultOptions() Options

type Prometheus

type Prometheus struct {
	// contains filtered or unexported fields
}

Prometheus implements the prometheus metrics backend.

func NewDefaultPrometheus

func NewDefaultPrometheus() *Prometheus

func NewPrometheus

func NewPrometheus(opts Options) *Prometheus

NewPrometheus returns a new Prometheus metric backend.

func (*Prometheus) CreateHandler

func (p *Prometheus) CreateHandler() http.Handler

func (*Prometheus) IncTelegramCommands

func (p *Prometheus) IncTelegramCommands(cmd string)

func (*Prometheus) IncTelegramEventsIncoming

func (p *Prometheus) IncTelegramEventsIncoming(eventType string)

func (*Prometheus) IncTelegramEventsOutgoing

func (p *Prometheus) IncTelegramEventsOutgoing(eventType string)

func (*Prometheus) RegisterHandler

func (p *Prometheus) RegisterHandler(path string, mux *http.ServeMux)

RegisterHandler satisfies Metrics interface.

Jump to

Keyboard shortcuts

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