0.3.0: rethinkdb

This commit is contained in:
Cameron Sparr 2015-12-15 15:41:01 -06:00
parent c1e1f2ace4
commit 60b6693ae3
1 changed files with 20 additions and 15 deletions

View File

@ -86,25 +86,30 @@ var engineStats = map[string]string{
"total_writes": "TotalWrites", "total_writes": "TotalWrites",
} }
func (e *Engine) AddEngineStats(keys []string, acc plugins.Accumulator, tags map[string]string) { func (e *Engine) AddEngineStats(
keys []string,
acc plugins.Accumulator,
tags map[string]string,
) {
engine := reflect.ValueOf(e).Elem() engine := reflect.ValueOf(e).Elem()
fields := make(map[string]interface{})
for _, key := range keys { for _, key := range keys {
acc.Add( fields[key] = engine.FieldByName(engineStats[key]).Interface()
key,
engine.FieldByName(engineStats[key]).Interface(),
tags,
)
} }
acc.AddFields("rethinkdb_engine", fields, tags)
} }
func (s *Storage) AddStats(acc plugins.Accumulator, tags map[string]string) { func (s *Storage) AddStats(acc plugins.Accumulator, tags map[string]string) {
acc.Add("cache_bytes_in_use", s.Cache.BytesInUse, tags) fields := map[string]interface{}{
acc.Add("disk_read_bytes_per_sec", s.Disk.ReadBytesPerSec, tags) "cache_bytes_in_use": s.Cache.BytesInUse,
acc.Add("disk_read_bytes_total", s.Disk.ReadBytesTotal, tags) "disk_read_bytes_per_sec": s.Disk.ReadBytesPerSec,
acc.Add("disk_written_bytes_per_sec", s.Disk.WriteBytesPerSec, tags) "disk_read_bytes_total": s.Disk.ReadBytesTotal,
acc.Add("disk_written_bytes_total", s.Disk.WriteBytesTotal, tags) "disk_written_bytes_per_sec": s.Disk.WriteBytesPerSec,
acc.Add("disk_usage_data_bytes", s.Disk.SpaceUsage.Data, tags) "disk_written_bytes_total": s.Disk.WriteBytesTotal,
acc.Add("disk_usage_garbage_bytes", s.Disk.SpaceUsage.Garbage, tags) "disk_usage_data_bytes": s.Disk.SpaceUsage.Data,
acc.Add("disk_usage_metadata_bytes", s.Disk.SpaceUsage.Metadata, tags) "disk_usage_garbage_bytes": s.Disk.SpaceUsage.Garbage,
acc.Add("disk_usage_preallocated_bytes", s.Disk.SpaceUsage.Prealloc, tags) "disk_usage_metadata_bytes": s.Disk.SpaceUsage.Metadata,
"disk_usage_preallocated_bytes": s.Disk.SpaceUsage.Prealloc,
}
acc.AddFields("rethinkdb", fields, tags)
} }