public virtual void TestTagOverflow() { MetricsTag t0 = Interns.Tag("t0", "t desc", "t value"); for (int i = 0; i < MaxTagNames + 1; ++i) { Interns.Tag("t" + i, "t desc", "t value"); if (i < MaxTagNames) { NUnit.Framework.Assert.AreSame("t0 still there", t0, Interns.Tag("t0", "t desc", "t value")); } } NUnit.Framework.Assert.AreNotSame("t0 is gone", t0, Interns.Tag("t0", "t desc", "t value" )); MetricsTag t1 = Interns.Tag("t1", "t desc", "t value"); for (int i_1 = 0; i_1 < MaxTagValues; ++i_1) { Interns.Tag("t1", "t desc", "t value" + i_1); if (i_1 < MaxTagValues - 1) { NUnit.Framework.Assert.AreSame("t1 is still there", t1, Interns.Tag("t1", "t desc" , "t value")); } } NUnit.Framework.Assert.AreNotSame("t1 is gone", t1, Interns.Tag("t1", "t desc", "t value" )); }
public static List <MetricsTag> GetTags(List <Detection> list) { var results = new List <MetricsTag>(); list .Where(x => !string.IsNullOrWhiteSpace(x.Tags)) .ToList().ForEach(y => { var id = y.Id; y.Tags.Split(";") .ToList().ForEach(z => { var tag = results.Where(t => t.Tag == z.ToUpper()).FirstOrDefault(); if (tag != null) { tag.Ids.Add(id); } else { var newTag = new MetricsTag() { Tag = z.ToUpper() }; newTag.Ids.Add(id); results.Add(newTag); } }); }); return(results.OrderBy(x => x.Tag).ToList()); }
public virtual void TestTag() { MetricsTag tag = Interns.Tag("t", "t desc", "t value"); NUnit.Framework.Assert.AreSame("same tag", tag, Interns.Tag("t", "t desc", "t value" )); }
public static List <MetricsTag> GetTags(IQueryable <Metadata> queryable) { var results = new List <MetricsTag>(); queryable .Where(x => !string.IsNullOrWhiteSpace(x.tags)) .ToList().ForEach(y => { var id = y.id; y.tags.Split(";") .ToList().ForEach(z => { var tag = results.Where(t => t.Tag == z).FirstOrDefault(); if (tag != null) { tag.Ids.Add(id); } else { var newTag = new MetricsTag() { Tag = z }; newTag.Ids.Add(id); results.Add(newTag); } }); }); return(results); }
public static void AssertTag(MetricsRecord record, string tagName, string expectedValue ) { MetricsTag processIdTag = GetFirstTagByName(record, tagName); NUnit.Framework.Assert.IsNotNull(processIdTag); Assert.Equal(expectedValue, processIdTag.Value()); }
/// <summary> /// Adds a tag to the record builder. This functions removes duplication in /// case tag has already been created by the caller. /// </summary> /// <param name="tag">Tag to add.</param> /// <returns>Self reference.</returns> public IMetricsRecordBuilder Add(MetricsTag tag) { if (_recordBuilderFinalized) { throw new MetricsException("Record builder is already finalized. No more tags can be added."); } _tags.Add(tag); return(this); }
private static void ShouldAcceptImpl(bool expectAcceptList, SubsetConfiguration conf , IList <MetricsTag> tags, bool[] expectedAcceptedSpec) { MetricsFilter globFilter = NewGlobFilter(conf); MetricsFilter regexFilter = NewRegexFilter(conf); // Test acceptance of the tag list: Assert.Equal("accepts " + tags, expectAcceptList, globFilter.Accepts (tags)); Assert.Equal("accepts " + tags, expectAcceptList, regexFilter. Accepts(tags)); // Test results on each of the individual tags: int acceptedCount = 0; for (int i = 0; i < tags.Count; i++) { MetricsTag tag = tags[i]; bool actGlob = globFilter.Accepts(tag); bool actRegex = regexFilter.Accepts(tag); Assert.Equal("accepts " + tag, expectedAcceptedSpec[i], actGlob ); // Both the filters should give the same result: Assert.Equal(actGlob, actRegex); if (actGlob) { acceptedCount++; } } if (expectAcceptList) { // At least one individual tag should be accepted: Assert.True("No tag of the following accepted: " + tags, acceptedCount > 0); } else { // At least one individual tag should be rejected: Assert.True("No tag of the following rejected: " + tags, acceptedCount < tags.Count); } }
public override bool Accepts(MetricsTag tag) { // Accept if whitelisted Pattern ipat = includeTagPatterns[tag.Name()]; if (ipat != null && ipat.Matcher(tag.Value()).Matches()) { return(true); } // Reject if blacklisted Pattern epat = excludeTagPatterns[tag.Name()]; if (epat != null && epat.Matcher(tag.Value()).Matches()) { return(false); } // Reject if no match in whitelist only mode if (!includeTagPatterns.IsEmpty() && excludeTagPatterns.IsEmpty()) { return(false); } return(true); }
public void TestMetricsTagClass() { const string name = "tagtest"; const string otherName = "othertagtest"; const string desc = "tagtestdesc"; const string otherDesc = "othertagtestdesc"; const string tagValue = "tagvalue"; const string otherTagValue = "othertagvalue"; IMetricsFactory factory = TangFactory.GetTang().NewInjector().GetInstance <IMetricsFactory>(); IMetricsInfo info = new MetricsInfoImpl(name, desc); MetricsTag tag = factory.CreateTag(info, tagValue); Assert.Equal(name, tag.Name); Assert.Equal(desc, tag.Description); Assert.Equal(tagValue, tag.Value); MetricsTag sameTag = factory.CreateTag(info, tagValue); Assert.True(tag.Equals(sameTag)); MetricsTag otherTag = factory.CreateTag(info, otherTagValue); Assert.False(tag.Equals(otherTag)); otherTag = factory.CreateTag(new MetricsInfoImpl(otherName, desc), tagValue); Assert.False(tag.Equals(otherTag)); otherTag = factory.CreateTag(new MetricsInfoImpl(name, otherDesc), otherTagValue); Assert.False(tag.Equals(otherTag)); string expectedToString = "Tag Information: " + "Name: " + info.Name + ", Description: " + info.Description + ", Tag Value: " + tagValue; Assert.Equal(expectedToString, tag.ToString()); }
public IMetricsRecordBuilder Add(MetricsTag tag) { throw new System.NotImplementedException(); }
public IMetricsRecordBuilder Add(MetricsTag tag) { _tagVals[tag.Name] = tag.Value; return(this); }
public override MetricsRecordBuilder Add(MetricsTag tag) { tags.AddItem(tag); return(this); }
private void SetAttrCacheTag(MetricsTag tag, int recNo) { string key = TagName(tag.Name(), recNo); attrCache[key] = new Attribute(key, tag.Value()); }
/// <summary>Add an immutable metrics tag object</summary> /// <param name="tag">a pre-made tag object (potentially save an object construction) /// </param> /// <returns>self</returns> public abstract MetricsRecordBuilder Add(MetricsTag tag);