Refactor procstat input (#2540)

fixes #1636 
fixes #2315
This commit is contained in:
Daniel Nelson
2017-03-17 16:49:11 -07:00
committed by GitHub
parent 8514acdc3c
commit a962e958eb
6 changed files with 608 additions and 287 deletions

View File

@@ -161,6 +161,29 @@ func (a *Accumulator) Get(measurement string) (*Metric, bool) {
return nil, false
}
func (a *Accumulator) HasTag(measurement string, key string) bool {
for _, p := range a.Metrics {
if p.Measurement == measurement {
_, ok := p.Tags[key]
return ok
}
}
return false
}
func (a *Accumulator) TagValue(measurement string, key string) string {
for _, p := range a.Metrics {
if p.Measurement == measurement {
v, ok := p.Tags[key]
if !ok {
return ""
}
return v
}
}
return ""
}
// NFields returns the total number of fields in the accumulator, across all
// measurements
func (a *Accumulator) NFields() int {