Documentation
¶
Overview ¶
Package prometheus provides a Prometheus wshub.MetricsCollector for wshub.
Usage:
reg := prometheus.NewRegistry()
collector := wshubprom.New(wshubprom.WithRegistry(reg))
hub := wshub.NewHub(wshub.WithMetrics(collector))
go hub.Run()
http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{}))
Index ¶
- type Collector
- func (c *Collector) DecrementConnections()
- func (c *Collector) DecrementRooms()
- func (c *Collector) IncrementConnections()
- func (c *Collector) IncrementErrors(errorType string)
- func (c *Collector) IncrementMessagesDropped()
- func (c *Collector) IncrementMessagesReceived()
- func (c *Collector) IncrementMessagesSent(count int)
- func (c *Collector) IncrementRoomJoins()
- func (c *Collector) IncrementRoomLeaves()
- func (c *Collector) IncrementRooms()
- func (c *Collector) RecordBroadcastDuration(duration time.Duration)
- func (c *Collector) RecordLatency(duration time.Duration)
- func (c *Collector) RecordMessageSize(size int)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector implements wshub.MetricsCollector using Prometheus metrics. It is safe for concurrent use.
func New ¶
New creates a new Prometheus Collector and registers all metrics. It panics if any metric fails to register (e.g. duplicate names).
func (*Collector) DecrementConnections ¶
func (c *Collector) DecrementConnections()
DecrementConnections decrements the active connections gauge.
func (*Collector) DecrementRooms ¶
func (c *Collector) DecrementRooms()
DecrementRooms decrements the active rooms gauge.
func (*Collector) IncrementConnections ¶
func (c *Collector) IncrementConnections()
IncrementConnections increments both active and total connection counters.
func (*Collector) IncrementErrors ¶
IncrementErrors increments the error counter for the given error type.
func (*Collector) IncrementMessagesDropped ¶
func (c *Collector) IncrementMessagesDropped()
IncrementMessagesDropped increments the counter for messages dropped due to full send buffers.
func (*Collector) IncrementMessagesReceived ¶
func (c *Collector) IncrementMessagesReceived()
IncrementMessagesReceived increments the counter for messages received from clients.
func (*Collector) IncrementMessagesSent ¶
IncrementMessagesSent increments the counter for messages sent to clients by the given count.
func (*Collector) IncrementRoomJoins ¶
func (c *Collector) IncrementRoomJoins()
IncrementRoomJoins increments the counter for room join operations.
func (*Collector) IncrementRoomLeaves ¶
func (c *Collector) IncrementRoomLeaves()
IncrementRoomLeaves increments the counter for room leave operations.
func (*Collector) IncrementRooms ¶
func (c *Collector) IncrementRooms()
IncrementRooms increments the active rooms gauge.
func (*Collector) RecordBroadcastDuration ¶
RecordBroadcastDuration observes a broadcast fanout duration in the histogram.
func (*Collector) RecordLatency ¶
RecordLatency observes a message handler processing latency in the histogram.
func (*Collector) RecordMessageSize ¶
RecordMessageSize adds the given message size to the total bytes received counter.
type Option ¶
type Option func(*Collector)
Option configures a Collector.
func WithBroadcastBuckets ¶
WithBroadcastBuckets sets custom histogram buckets for broadcast duration. Default: {.0001, .0005, .001, .005, .01, .05, .1, .5, 1}.
func WithLatencyBuckets ¶
WithLatencyBuckets sets custom histogram buckets for message latency. Default: prometheus.DefBuckets.
func WithNamespace ¶
WithNamespace sets the metric namespace (prefix). Default: "wshub".
func WithRegistry ¶
func WithRegistry(reg prometheus.Registerer) Option
WithRegistry sets a custom Prometheus registerer. Default: prometheus.DefaultRegisterer.