Beispiel #1
0
        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"
                                                                            ));
        }
Beispiel #2
0
        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 virtual void TestClasses()
        {
            MetricsRecordBuilder rb = MetricsAsserts.GetMetrics(MetricsAnnotations.MakeSource
                                                                    (new TestMetricsAnnotations.MyMetrics3()));
            MetricsCollector collector = rb.Parent();

            Org.Mockito.Mockito.Verify(collector).AddRecord(Interns.Info("MyMetrics3", "My metrics"
                                                                         ));
            Org.Mockito.Mockito.Verify(rb).Add(Interns.Tag(MsInfo.Context, "foo"));
        }
Beispiel #4
0
 /// <summary>Add a tag to the metrics</summary>
 /// <param name="info">metadata of the tag</param>
 /// <param name="value">of the tag</param>
 /// <param name="override">existing tag if true</param>
 /// <returns>the registry (for keep adding tags etc.)</returns>
 public virtual Org.Apache.Hadoop.Metrics2.Lib.MetricsRegistry Tag(MetricsInfo info
                                                                   , string value, bool @override)
 {
     lock (this)
     {
         if (!@override)
         {
             CheckTagName(info.Name());
         }
         tagsMap[info.Name()] = Interns.Tag(info, value);
         return(this);
     }
 }
        public virtual void TestHybrid()
        {
            TestMetricsAnnotations.HybridMetrics metrics = new TestMetricsAnnotations.HybridMetrics
                                                               ();
            MetricsSource source = MetricsAnnotations.MakeSource(metrics);

            NUnit.Framework.Assert.AreSame(metrics, source);
            metrics.C0.Incr();
            MetricsRecordBuilder rb        = MetricsAsserts.GetMetrics(source);
            MetricsCollector     collector = rb.Parent();

            Org.Mockito.Mockito.Verify(collector).AddRecord("foo");
            Org.Mockito.Mockito.Verify(collector).AddRecord("bar");
            Org.Mockito.Mockito.Verify(collector).AddRecord(Interns.Info("HybridMetrics", "HybridMetrics"
                                                                         ));
            Org.Mockito.Mockito.Verify(rb).SetContext("foocontext");
            Org.Mockito.Mockito.Verify(rb).AddCounter(Interns.Info("C1", "C1 desc"), 1);
            Org.Mockito.Mockito.Verify(rb).SetContext("barcontext");
            Org.Mockito.Mockito.Verify(rb).AddGauge(Interns.Info("G1", "G1 desc"), 1);
            Org.Mockito.Mockito.Verify(rb).Add(Interns.Tag(MsInfo.Context, "hybrid"));
            Org.Mockito.Mockito.Verify(rb).AddCounter(Interns.Info("C0", "C0 desc"), 1);
            Org.Mockito.Mockito.Verify(rb).AddGauge(Interns.Info("G0", "G0"), 0);
        }