Documentation
¶
Index ¶
- func HTTPMiddleware(next http.Handler, m *Collector) http.Handler
- func HandleMetricsJSON() http.HandlerFunc
- type Collector
- type ConnectionsMetrics
- type EventsMetrics
- type HTTPMetrics
- type InstrumentedStore
- func (s *InstrumentedStore) Delete(ctx context.Context, uuid string) error
- func (s *InstrumentedStore) DeleteAll(ctx context.Context, opts event.DeleteOptions) error
- func (s *InstrumentedStore) FindAll(ctx context.Context, opts event.FindOptions) ([]event.Event, error)
- func (s *InstrumentedStore) FindByUUID(ctx context.Context, uuid string) (*event.Event, error)
- func (s *InstrumentedStore) Pin(ctx context.Context, uuid string) error
- func (s *InstrumentedStore) Store(ctx context.Context, ev event.Event) error
- func (s *InstrumentedStore) Unpin(ctx context.Context, uuid string) error
- func (s *InstrumentedStore) UpdatePayload(ctx context.Context, uuid string, payload json.RawMessage) error
- type MetricsResponse
- type WebhooksMetrics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPMiddleware ¶
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 ¶
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 (*InstrumentedStore) Pin ¶
func (s *InstrumentedStore) Pin(ctx context.Context, uuid string) 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 ¶
WebhooksMetrics shows webhook delivery stats.