Add prometheus exporter on :9100
This commit is contained in:
@@ -13,6 +13,7 @@ const liveMapCap = 100_000 // hard cap on live map entries
|
||||
// Store holds the live map and both ring buffers.
|
||||
type Store struct {
|
||||
source string
|
||||
prom *PromStore // optional; if non-nil, receives every ingested record
|
||||
|
||||
// live map — written only by the Run goroutine; no locking needed on writes
|
||||
live map[st.Tuple6]int64
|
||||
@@ -41,9 +42,12 @@ func NewStore(source string) *Store {
|
||||
}
|
||||
}
|
||||
|
||||
// ingest records one log record into the live map.
|
||||
// ingest records one log record into the live map and the Prometheus store (if set).
|
||||
// Must only be called from the Run goroutine.
|
||||
func (s *Store) ingest(r LogRecord) {
|
||||
if s.prom != nil {
|
||||
s.prom.Ingest(r)
|
||||
}
|
||||
key := st.Tuple6{Website: r.Website, Prefix: r.ClientPrefix, URI: r.URI, Status: r.Status, IsTor: r.IsTor, ASN: r.ASN}
|
||||
if _, exists := s.live[key]; !exists {
|
||||
if s.liveLen >= liveMapCap {
|
||||
|
||||
Reference in New Issue
Block a user