Exemplo n.º 1
0
func (self *MemoryMetricStorage) GetMetricByName(name string) (Metric, error) {
	self.RLock()
	defer self.RUnlock()
	ring, found := self.rings[name]
	if !found {
		return nil, errors.New("Cannot find metric")
	}
	ring.RLock()
	defer ring.RUnlock()
	return ring.m, nil
}
Exemplo n.º 2
0
func (self *MemoryMetricStorage) GetMetricsByHost(host_name string) ([]Metric, error) {
	self.RLock()
	defer self.RUnlock()
	host_map, found := self.host_rings[host_name]
	if !found {
		return []Metric{}, nil
	}
	metrics := make([]Metric, len(host_map))
	i := 0
	for key := range host_map {
		ring, _ := host_map[key]
		ring.RLock()
		metrics[i] = ring.m
		ring.RUnlock()
		i++
	}
	return metrics, nil
}