metrics

package
v2.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPMiddleware

func HTTPMiddleware(next http.Handler, m *Collector) http.Handler

HTTPMiddleware returns an HTTP middleware that records request metrics.

func HandleMetricsJSON

func HandleMetricsJSON() http.HandlerFunc

HandleMetricsJSON returns an http.HandlerFunc that gathers metrics from the default Prometheus registry and returns a JSON summary.

Types

type Collector

type Collector struct {
	// Ingestion.
	EventsReceivedTotal     *prometheus.CounterVec
	EventsIngestionDuration *prometheus.HistogramVec
	EventsIngestionErrors   *prometheus.CounterVec
	EventsPayloadBytes      *prometheus.HistogramVec

	// Storage.
	EventsStoredTotal    *prometheus.GaugeVec
	StorageQueryDuration *prometheus.HistogramVec

	// WebSocket.
	WSConnectionsActive prometheus.Gauge
	WSMessagesSentTotal *prometheus.CounterVec

	// TCP.
	TCPConnectionsActive     *prometheus.GaugeVec
	TCPMessagesReceivedTotal *prometheus.CounterVec

	// HTTP.
	HTTPRequestsTotal   *prometheus.CounterVec
	HTTPRequestDuration *prometheus.HistogramVec

	// Webhooks.
	WebhooksSentTotal *prometheus.CounterVec
}

Collector holds all Prometheus metrics for the application.

func NewCollector

func NewCollector() *Collector

NewCollector creates and registers all Prometheus metrics.

type ConnectionsMetrics

type ConnectionsMetrics struct {
	WebSocket float64            `json:"websocket"`
	TCP       map[string]float64 `json:"tcp"` // by server name
}

ConnectionsMetrics shows active connections.

type EventsMetrics

type EventsMetrics struct {
	Received map[string]float64 `json:"received"` // by type
	Stored   map[string]float64 `json:"stored"`   // by type (current gauge)
	Errors   float64            `json:"errors"`
}

EventsMetrics shows event counters grouped by type.

type HTTPMetrics

type HTTPMetrics struct {
	RequestsTotal float64 `json:"requests_total"`
}

HTTPMetrics shows HTTP request stats.

type InstrumentedStore

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

InstrumentedStore wraps event.Store with Prometheus metrics.

func NewInstrumentedStore

func NewInstrumentedStore(inner event.Store, collector *Collector, db *sql.DB) *InstrumentedStore

NewInstrumentedStore wraps a store with metrics instrumentation. It also seeds the events_stored_total gauge from the database.

func (*InstrumentedStore) Delete

func (s *InstrumentedStore) Delete(ctx context.Context, uuid string) error

func (*InstrumentedStore) DeleteAll

func (s *InstrumentedStore) DeleteAll(ctx context.Context, opts event.DeleteOptions) error

func (*InstrumentedStore) FindAll

func (s *InstrumentedStore) FindAll(ctx context.Context, opts event.FindOptions) ([]event.Event, error)

func (*InstrumentedStore) FindByUUID

func (s *InstrumentedStore) FindByUUID(ctx context.Context, uuid string) (*event.Event, error)

func (*InstrumentedStore) Pin

func (s *InstrumentedStore) Pin(ctx context.Context, uuid string) error

func (*InstrumentedStore) Store

func (s *InstrumentedStore) Store(ctx context.Context, ev event.Event) error

func (*InstrumentedStore) Unpin

func (s *InstrumentedStore) Unpin(ctx context.Context, uuid string) error

func (*InstrumentedStore) UpdatePayload

func (s *InstrumentedStore) UpdatePayload(ctx context.Context, uuid string, payload json.RawMessage) error

type MetricsResponse

type MetricsResponse struct {
	Events      EventsMetrics      `json:"events"`
	Connections ConnectionsMetrics `json:"connections"`
	HTTP        HTTPMetrics        `json:"http"`
	Webhooks    WebhooksMetrics    `json:"webhooks"`
}

MetricsResponse is the JSON response for GET /api/metrics.

type WebhooksMetrics

type WebhooksMetrics struct {
	Sent   float64 `json:"sent"`
	Failed float64 `json:"failed"`
}

WebhooksMetrics shows webhook delivery stats.

Jump to

Keyboard shortcuts

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