exporter

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package exporter provides all the building blocks of the prometheus-nats-exporter application.

The main components are

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeHTTPHandler

func MakeHTTPHandler(metricsPath string) http.Handler

Types

type EventHandler

type EventHandler interface {
	HandleEvent(msg *redis.Message) error
}

An EventHandler is responsible to handle all the messages received from a EventListener

func NewEventHandler

func NewEventHandler(metrics *Metrics, logger *slog.Logger) EventHandler

NewEventHandler creates and EventHandler that will handle the message updating the metrics

type EventListener

type EventListener interface {
	Run(ctx context.Context) error
}

EventListener interface exposes a single method Run() that shall run until the input context does not get canceled

func NewEventListener

func NewEventListener(rdb *redis.Client, channel string, logger *slog.Logger, handler EventHandler) EventListener

NewEventListener creates and returns a new EventListener. The created listeners uses the rdb connection to subscribe to the channel and forwards all the received messages to the handler

type Metrics

type Metrics struct {
	Executions   *prometheus.CounterVec
	Completed    *prometheus.CounterVec
	Locked       *prometheus.CounterVec
	Duration     *prometheus.HistogramVec
	LastDuration *prometheus.GaugeVec
}

Metrics stores all the metrics exposed by the exporter

func SetupMetrics

func SetupMetrics(prefix string) *Metrics

SetupMetrics takes care of initializing all the metrics (the names are prefixed with prefix) and register them to the default Registerer

Jump to

Keyboard shortcuts

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