示例#1
0
文件: metrics.go 项目: yxzoro/snap
// GetQueriedNamespaces returns all matched metrics namespaces for query 'ns' which can contain
// an asterisk or tuple (refer to query support)
func (mc *metricCatalog) GetQueriedNamespaces(ns core.Namespace) ([]core.Namespace, error) {
	mc.mutex.Lock()
	defer mc.mutex.Unlock()

	// get metric key (might contain wildcard(s))
	wkey := ns.Key()

	return mc.matchedNamespaces(wkey)
}
示例#2
0
文件: metrics.go 项目: yxzoro/snap
// Remove removes a metricType from the catalog and from matching map
func (mc *metricCatalog) Remove(ns core.Namespace) {
	mc.mutex.Lock()
	defer mc.mutex.Unlock()

	mc.tree.Remove(ns.Strings())

	// remove all items from map mKey mapped for this 'ns'
	key := ns.Key()
	mc.removeMatchedKey(key)
}
示例#3
0
文件: metrics.go 项目: yxzoro/snap
// MatchQuery matches given 'ns' which could contain an asterisk or a tuple and add them to matching map under key 'ns'
// The matched metrics namespaces are also returned (as a []core.Namespace)
func (mc *metricCatalog) MatchQuery(ns core.Namespace) ([]core.Namespace, error) {
	mc.mutex.Lock()
	defer mc.mutex.Unlock()

	// get metric key (might contain wildcard(s))
	wkey := ns.Key()

	// adding matched namespaces to map
	mc.addItemToMatchingMap(wkey)

	return mc.matchedNamespaces(wkey)
}