monitoring

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeMetricsURL

func MakeMetricsURL(address string) (string, error)

MakeMetricsURL construct the Prometheus metrics URL.

func RequireConnectionMetrics

func RequireConnectionMetrics(
	t *testing.T,
	label string,
	connMetrics *ConnectionMetrics,
	expected ExpectedConn,
)

RequireConnectionMetrics waits for a connection status and a specified number of failures.

func WaitForConnections

func WaitForConnections(t *testing.T, p *Provider, name string, requiredCount int)

WaitForConnections waits for a connection metric to have the required number of connected labels.

Types

type Config

type Config struct {
	Server *connection.ServerConfig `mapstructure:"server"`
}

Config represents the monitoring configuration.

type ConnectionMetrics

type ConnectionMetrics struct {
	Status       *prometheus.GaugeVec
	FailureTotal *prometheus.CounterVec
	// contains filtered or unexported fields
}

ConnectionMetrics supports common connection metrics.

func (*ConnectionMetrics) Connected

func (m *ConnectionMetrics) Connected(grpcTarget string)

Connected observed connected.

func (*ConnectionMetrics) Disconnected

func (m *ConnectionMetrics) Disconnected(grpcTarget string)

Disconnected observe disconnected. The failure count is increased only if the status was connected.

type ConnectionMetricsOpts

type ConnectionMetricsOpts struct {
	Namespace       string
	RemoteNamespace string
}

ConnectionMetricsOpts describes connection metrics parameters.

type ExpectedConn

type ExpectedConn struct {
	Status       int
	FailureTotal int
}

ExpectedConn is used to describe the expected connection state.

type Provider

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

Provider is a prometheus metrics provider.

func NewProvider

func NewProvider() *Provider

NewProvider creates a new prometheus metrics provider.

func (*Provider) NewConnectionMetrics

func (p *Provider) NewConnectionMetrics(opts ConnectionMetricsOpts) *ConnectionMetrics

NewConnectionMetrics supports common connection metrics.

func (*Provider) NewCounter

func (p *Provider) NewCounter(opts prometheus.CounterOpts) prometheus.Counter

NewCounter creates a new prometheus counter.

func (*Provider) NewCounterVec

func (p *Provider) NewCounterVec(opts prometheus.CounterOpts, labels []string) *prometheus.CounterVec

NewCounterVec creates a new prometheus counter vector.

func (*Provider) NewGauge

func (p *Provider) NewGauge(opts prometheus.GaugeOpts) prometheus.Gauge

NewGauge creates a new prometheus gauge.

func (*Provider) NewGaugeVec

func (p *Provider) NewGaugeVec(opts prometheus.GaugeOpts, labels []string) *prometheus.GaugeVec

NewGaugeVec creates a new prometheus gauge vector.

func (*Provider) NewHistogram

func (p *Provider) NewHistogram(opts prometheus.HistogramOpts) prometheus.Histogram

NewHistogram creates a new prometheus histogram.

func (*Provider) NewHistogramVec

func (p *Provider) NewHistogramVec(opts prometheus.HistogramOpts, labels []string) *prometheus.HistogramVec

NewHistogramVec creates a new prometheus histogram vector.

func (*Provider) NewThroughputCounter

func (p *Provider) NewThroughputCounter(
	component, subComponent string,
	direction ThroughputDirection,
) prometheus.Counter

NewThroughputCounter creates a new prometheus throughput counter.

func (*Provider) Registry

func (p *Provider) Registry() *prometheus.Registry

Registry returns the prometheus registry.

func (*Provider) StartPrometheusServer

func (p *Provider) StartPrometheusServer(
	ctx context.Context, serverConfig *connection.ServerConfig, monitor ...func(context.Context),
) error

StartPrometheusServer starts a prometheus server. It also starts the given monitoring methods. Their context will cancel once the server is cancelled. This method returns once the server is shutdown and all monitoring methods returns.

func (*Provider) URL

func (p *Provider) URL() string

URL returns the prometheus server URL.

type ThroughputDirection

type ThroughputDirection = string

ThroughputDirection can in or out.

const (
	In  ThroughputDirection = "in"
	Out ThroughputDirection = "out"
)

Direction constants.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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