Skip to content

Commit

Permalink
Add NumRules to health info
Browse files Browse the repository at this point in the history
  • Loading branch information
hit9 committed Mar 3, 2016
1 parent 9eae394 commit 0363265
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions health/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Info struct {
AggregationInterval int `json:"aggregationInterval"`
NumIndexTotal int `json:"numIndexTotal"`
NumClients int64 `json:"numClients"`
NumRules int `json:"numRules"`
// Aggregation
DetectionCost float64 `json:"detectionCost"` // ms
FilterCost float64 `json:"filterCost"` // ms
Expand All @@ -42,6 +43,7 @@ func (info *Info) copy() *Info {
AggregationInterval: AggregationInterval,
NumIndexTotal: info.NumIndexTotal,
NumClients: info.NumClients,
NumRules: info.NumRules,
DetectionCost: info.DetectionCost,
FilterCost: info.FilterCost,
NumMetricIncomed: info.NumMetricIncomed,
Expand Down Expand Up @@ -138,6 +140,13 @@ func refreshNumClients() {
h.info.NumClients = atomic.LoadInt64(&h.numClients)
}

// Refresh NumRules.
func refreshNumRules() {
h.info.lock.Lock()
defer h.info.lock.Unlock()
h.info.NumRules = h.db.Admin.RulesCache.Len()
}

// Aggregate DetectionCost.
func aggregateDetectionCost() {
h.info.lock.Lock()
Expand Down Expand Up @@ -190,6 +199,7 @@ func Start() {
<-ticker.C
refreshNumIndexTotal()
refreshNumClients()
refreshNumRules()
aggregateDetectionCost()
aggregateNumMetricIncomed()
aggregateNumMetricDetected()
Expand Down

0 comments on commit 0363265

Please sign in to comment.