Documentation
¶
Overview ¶
Package storemetrics defines the store metrics entry model used for centralized metrics collection.
Index ¶
Constants ¶
const NATSSubjectPrefix = "sys.metrics"
NATSSubjectPrefix is the base subject for metrics publishing. Full subject: sys.metrics.{service}
const NATSSubjectWildcard = "sys.metrics.>"
NATSSubjectWildcard matches all service metrics subjects.
Variables ¶
This section is empty.
Functions ¶
func NATSSubject ¶
NATSSubject returns the NATS subject for a given service name.
Types ¶
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
Publisher periodically collects metrics from stores and publishes them via NATS.
func NewPublisher ¶
func NewPublisher(service string, stores []StoreInfo, interval time.Duration, client *messenger.Client, l *logger.Logger) *Publisher
NewPublisher creates a new metrics publisher.
type StoreInfo ¶
type StoreInfo struct {
Name string // e.g. "admin.db"
Store *store.Store // underlying BadgerDB store
}
StoreInfo identifies a store to collect metrics from.
type StoreMetricsEntry ¶
type StoreMetricsEntry struct {
ID string `json:"id"` // ULID for time-ordered keys
Timestamp int64 `json:"timestamp"` // Unix millis
Hostname string `json:"hostname"` // OS hostname of the publishing node
Service string `json:"service"` // e.g. "admin_server"
StoreName string `json:"store_name"` // e.g. "admin.db"
Metrics store.Metrics `json:"metrics"`
}
StoreMetricsEntry represents a single metrics snapshot published by a service.
func NewStoreMetricsEntry ¶
func NewStoreMetricsEntry(service, storeName string, metrics *store.Metrics) *StoreMetricsEntry
NewStoreMetricsEntry creates a new StoreMetricsEntry with a ULID and current timestamp.