metrics

package
v0.0.0-...-d931726 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DiscordEventTriggers = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: "discord_eventtriggers_total",
		Help: "Total number of Discord events triggered.",
	}, []string{"event"})

	DiscordCommandsProcessed = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: "discord_commands_processed_total",
		Help: "Total number of chat commands processed.",
	}, []string{"command"})

	DiscordGatewayPing = promauto.NewGauge(prometheus.GaugeOpts{
		Name: "discord_gatewayping",
		Help: "The ping time in milliseconds to the discord API gateay.",
	})

	RestapiRequests = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: "restapi_requests_total",
		Help: "Total number of HTTP requests processed.",
	}, []string{"method", "status"})

	RestapiRequestTimes = promauto.NewHistogramVec(prometheus.HistogramOpts{
		Name: "restapi_requests_duration_seconds",
		Help: "Duration of all HTTP requests by method and status.",
		Buckets: []float64{
			0.001,
			0.01,
			0.05,
			0.1,
			0.2,
			0.4,
			0.6,
			0.8,
			1,
			2,
			3,
			4,
			5,
			10,
			30,
		},
	}, []string{"method", "status"})

	RedisKeyCount = promauto.NewGaugeFunc(prometheus.GaugeOpts{
		Name: "redis_key_count",
		Help: "Number of Redis keys.",
	}, func() float64 {
		return redisW.Get("key_count")
	})

	RedisMemoryUsed = promauto.NewGaugeFunc(prometheus.GaugeOpts{
		Name: "redis_memory_used_bytes",
		Help: "Redis memory usage in bytes.",
	}, func() float64 {
		return redisW.Get("used_memory")
	})

	RedisCommandsProcessed = promauto.NewCounterFunc(prometheus.CounterOpts{
		Name: "redis_commands_executed_total",
		Help: "Total count of redis commands executed",
	}, func() float64 {
		return redisW.Get("total_commands_processed")
	})
)

Functions

This section is empty.

Types

type MetricsServer

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

MetricsServer wraps a simple HTTP server serving a prometheus metrics endpoint.

func NewMetricsServer

func NewMetricsServer(addr string, redis redis.Cmdable) (ms *MetricsServer, err error)

NewMetricsServer initializes a new MectricsServer instance with the given addr and registers all instruments.

func (*MetricsServer) ListenAndServeBlocking

func (ms *MetricsServer) ListenAndServeBlocking() error

ListenAndServeBlocking starts the listening loop of the web server which blocks the current goroutine.

Jump to

Keyboard shortcuts

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