monitor

package
v0.0.0-...-6d2f78d Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package monitor provides implementations for monitoring statistics and exposing them as Prometheus metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GuildsGauge

func GuildsGauge(config *Config) prometheus.Gauge

GuildsGauge returns a Prometheus gauge for the number of guilds the bot belongs to.

func MembersGauge

func MembersGauge(config *Config) prometheus.Gauge

MembersGauge returns a Prometheus gauge for the number of members of the guilds the bot belongs to.

func ReadyCounter

func ReadyCounter(config *Config) prometheus.Counter

ReadyCounter returns a Prometheus counter for Ready events.

func VoiceStateUpdateCounter

func VoiceStateUpdateCounter(config *Config) prometheus.Counter

VoiceStateUpdateCounter returns a Prometheus counter for VoiceStateUpdate events.

Types

type Config

type Config struct {
	Log      logging.Interface
	Session  *discordgo.Session
	Interval time.Duration
}

Config contains fields for configuring Metrics.

type Guilds

type Guilds struct {
	Log             logging.Interface
	Session         *discordgo.Session
	Interval        time.Duration
	PrometheusGauge prometheus.Gauge
	Cache           *GuildsCache
}

Guilds contains fields for monitoring the guilds the bot belongs to.

func (*Guilds) Monitor

func (guilds *Guilds) Monitor(ctx context.Context)

Monitor sets up an infinite loop checking guild changes.

type GuildsCache

type GuildsCache struct {
	Mutex *sync.Mutex
	// contains filtered or unexported fields
}

GuildsCache is an in-memory cache of the guilds the bot belongs to.

type Members

type Members struct {
	Log             logging.Interface
	Session         *discordgo.Session
	Interval        time.Duration
	PrometheusGauge prometheus.Gauge
	Cache           *MembersCache
}

Members contains fields for monitoring the number of members in the guilds the bot belongs to.

func (*Members) Monitor

func (members *Members) Monitor(ctx context.Context)

Monitor sets up an infinite loop checking member changes.

type MembersCache

type MembersCache struct {
	Mutex *sync.Mutex
	// contains filtered or unexported fields
}

MembersCache is an in-memory cache of the number of members in the guilds the bot belongs to.

type Metrics

type Metrics struct {
	*Config
	Guilds                  *Guilds
	Members                 *Members
	ReadyCounter            prometheus.Counter
	VoiceStateUpdateCounter prometheus.Counter
	GuildsGauge             prometheus.Gauge
	MembersGauge            prometheus.Gauge
}

Metrics contains fields for tracking and exposing metrics to Prometheus.

func NewMetrics

func NewMetrics(config *Config) *Metrics

NewMetrics returns a new *Metrics configured using the provided config.

func (*Metrics) Monitor

func (metrics *Metrics) Monitor(ctx context.Context)

Monitor begins the goroutines for monitoring callback metrics.

Jump to

Keyboard shortcuts

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