private bool match(string attribute, Regex regex, IceMX.MetricsHelper <T> helper, bool reject) { string value; try { value = helper.resolve(attribute); } catch (Exception) { return(!reject); } return(regex.IsMatch(value)); }
internal MetricsMap <S> .Entry getMatching <S>(string mapName, IceMX.MetricsHelper <S> helper) where S : IceMX.Metrics, new() { ISubMap m; lock (_map) { if (_subMaps == null || !_subMaps.TryGetValue(mapName, out m)) { m = _map.createSubMap(mapName); if (m == null) { return(null); } if (_subMaps == null) { _subMaps = new Dictionary <string, ISubMap>(); } _subMaps.Add(mapName, m); } } return(((SubMap <S>)m).getMatching(helper)); }
internal MetricsMap <S> .Entry getMatching(IceMX.MetricsHelper <S> helper) { return(_map.getMatching(helper, null)); }
public Entry getMatching(IceMX.MetricsHelper <T> helper, Entry previous) { // // Check the accept and reject filters. // foreach (KeyValuePair <string, Regex> e in _accept) { if (!match(e.Key, e.Value, helper, false)) { return(null); } } foreach (KeyValuePair <string, Regex> e in _reject) { if (match(e.Key, e.Value, helper, true)) { return(null); } } // // Compute the key from the GroupBy property. // string key; try { if (_groupByAttributes.Count == 1) { key = helper.resolve(_groupByAttributes[0]); } else { StringBuilder os = new StringBuilder(); IEnumerator <string> q = _groupBySeparators.GetEnumerator(); foreach (string p in _groupByAttributes) { os.Append(helper.resolve(p)); if (q.MoveNext()) { os.Append(q.Current); } } key = os.ToString(); } } catch (Exception) { return(null); } // // Lookup the metrics object. // lock (this) { if (previous != null && previous.getId().Equals(key)) { Debug.Assert(_objects[key] == previous); return(previous); } Entry e; if (!_objects.TryGetValue(key, out e)) { try { T t = new T(); t.id = key; e = new Entry(this, t); _objects.Add(key, e); } catch (Exception) { Debug.Assert(false); } } e.attach(helper); return(e); } }
internal void attach(IceMX.MetricsHelper <T> helper) { ++_object.total; ++_object.current; helper.initMetrics(_object); }
internal MetricsMap <S> .Entry?GetMatching(IceMX.MetricsHelper <S> helper) => _map.GetMatching(helper, null);