public virtual void TestCommon() { MetricsVisitor visitor = Org.Mockito.Mockito.Mock <MetricsVisitor>(); MetricsRegistry registry = new MetricsRegistry("test"); IList <AbstractMetric> metrics = ((MetricsRecordBuilderImpl)((MetricsRecordBuilderImpl )((MetricsRecordBuilderImpl)((MetricsRecordBuilderImpl)((MetricsRecordBuilderImpl )((MetricsRecordBuilderImpl)MetricsLists.Builder("test").AddCounter(Interns.Info ("c1", "int counter"), 1)).AddCounter(Interns.Info("c2", "long counter"), 2L)).AddGauge (Interns.Info("g1", "int gauge"), 5)).AddGauge(Interns.Info("g2", "long gauge"), 6L)).AddGauge(Interns.Info("g3", "float gauge"), 7f)).AddGauge(Interns.Info("g4" , "double gauge"), 8d)).Metrics(); foreach (AbstractMetric metric in metrics) { metric.Visit(visitor); } Org.Mockito.Mockito.Verify(visitor).Counter(c1.Capture(), Eq(1)); Assert.Equal("c1 name", "c1", c1.GetValue().Name()); Assert.Equal("c1 description", "int counter", c1.GetValue().Description ()); Org.Mockito.Mockito.Verify(visitor).Counter(c2.Capture(), Eq(2L)); Assert.Equal("c2 name", "c2", c2.GetValue().Name()); Assert.Equal("c2 description", "long counter", c2.GetValue().Description ()); Org.Mockito.Mockito.Verify(visitor).Gauge(g1.Capture(), Eq(5)); Assert.Equal("g1 name", "g1", g1.GetValue().Name()); Assert.Equal("g1 description", "int gauge", g1.GetValue().Description ()); Org.Mockito.Mockito.Verify(visitor).Gauge(g2.Capture(), Eq(6L)); Assert.Equal("g2 name", "g2", g2.GetValue().Name()); Assert.Equal("g2 description", "long gauge", g2.GetValue().Description ()); Org.Mockito.Mockito.Verify(visitor).Gauge(g3.Capture(), Eq(7f)); Assert.Equal("g3 name", "g3", g3.GetValue().Name()); Assert.Equal("g3 description", "float gauge", g3.GetValue().Description ()); Org.Mockito.Mockito.Verify(visitor).Gauge(g4.Capture(), Eq(8d)); Assert.Equal("g4 name", "g4", g4.GetValue().Name()); Assert.Equal("g4 description", "double gauge", g4.GetValue().Description ()); }
private void CheckMetricsRecords(IList <MetricsRecord> recs) { Log.Debug(recs); MetricsRecord r = recs[0]; Assert.Equal("name", "s1rec", r.Name()); MoreAsserts.AssertEquals("tags", new MetricsTag[] { Interns.Tag(MsInfo.Context, "test" ), Interns.Tag(MsInfo.Hostname, hostname) }, r.Tags()); MoreAsserts.AssertEquals("metrics", ((MetricsRecordBuilderImpl)((MetricsRecordBuilderImpl )((MetricsRecordBuilderImpl)((MetricsRecordBuilderImpl)MetricsLists.Builder(string.Empty ).AddCounter(Interns.Info("C1", "C1 desc"), 1L)).AddGauge(Interns.Info("G1", "G1 desc" ), 2L)).AddCounter(Interns.Info("S1NumOps", "Number of ops for s1"), 1L)).AddGauge (Interns.Info("S1AvgTime", "Average time for s1"), 0.0)).Metrics(), r.Metrics()); r = recs[1]; Assert.True("NumActiveSinks should be 3", Iterables.Contains(r. Metrics(), new MetricGaugeInt(MsInfo.NumActiveSinks, 3))); }