use of com.newrelic.agent.stats.StatsEngine in project newrelic-java-agent by newrelic.
the class JmxMetricTest method jmxMetricRecordStatsChangeNameMono.
@Test
public void jmxMetricRecordStatsChangeNameMono() {
StatsEngine stats = new StatsEngineImpl();
JmxMetric metric = JmxMetric.create("hello", "theHello", JmxType.MONOTONICALLY_INCREASING);
Map<String, Float> values = new HashMap<>();
values.put("hello", 5f);
metric.recordSingleMBeanStats(stats, "Jmx/Sample/", values);
Assert.assertEquals(1, stats.getStats("Jmx/Sample/theHello").getCallCount());
Assert.assertEquals(5f, stats.getStats("Jmx/Sample/theHello").getTotal(), 0);
values.clear();
values.put("hello", 7f);
metric.recordSingleMBeanStats(stats, "Jmx/Sample/", values);
Assert.assertEquals(2, stats.getStats("Jmx/Sample/theHello").getCallCount());
Assert.assertEquals(7f, stats.getStats("Jmx/Sample/theHello").getTotal(), .001);
}
use of com.newrelic.agent.stats.StatsEngine in project newrelic-java-agent by newrelic.
the class JmxMetricTest method jmxMetricRecordStatsSubTypeMonoMultiAdd.
@Test
public void jmxMetricRecordStatsSubTypeMonoMultiAdd() {
StatsEngine stats = new StatsEngineImpl();
JmxMetric metric = JmxMetric.create(new String[] { "first", "second" }, "theDiffe", JmxAction.SUBTRACT_ALL_FROM_FIRST, JmxType.MONOTONICALLY_INCREASING);
Map<String, Float> values = new HashMap<>();
values.put("first", 10f);
values.put("second", 7f);
Map<String, Float> actual = new HashMap<>();
metric.applySingleMBean("Jmx/Sample/", values, actual);
Assert.assertEquals(0, stats.getStats("Jmx/Sample/theDiffe").getCallCount());
values.clear();
values.put("first", 12f);
values.put("second", 5f);
metric.applySingleMBean("Jmx/Sample/", values, actual);
metric.recordMultMBeanStats(stats, actual);
Assert.assertEquals(1, stats.getStats("Jmx/Sample/theDiffe").getCallCount());
Assert.assertEquals(10f, stats.getStats("Jmx/Sample/theDiffe").getTotal(), .001);
}
use of com.newrelic.agent.stats.StatsEngine in project newrelic-java-agent by newrelic.
the class JmxMetricTest method jmxMetricRecordStatsChangeNameSimple.
@Test
public void jmxMetricRecordStatsChangeNameSimple() {
StatsEngine stats = new StatsEngineImpl();
JmxMetric metric = JmxMetric.create("hello", "theHello", JmxType.SIMPLE);
Map<String, Float> values = new HashMap<>();
values.put("hello", 5f);
metric.recordSingleMBeanStats(stats, "Jmx/Sample/", values);
Assert.assertEquals(1, stats.getStats("Jmx/Sample/theHello").getCallCount());
Assert.assertEquals(5f, stats.getStats("Jmx/Sample/theHello").getTotal(), 0);
values.clear();
values.put("hello", 7f);
metric.recordSingleMBeanStats(stats, "Jmx/Sample/", values);
Assert.assertEquals(2, stats.getStats("Jmx/Sample/theHello").getCallCount());
Assert.assertEquals(12f, stats.getStats("Jmx/Sample/theHello").getTotal(), .001);
}
use of com.newrelic.agent.stats.StatsEngine in project newrelic-java-agent by newrelic.
the class JmxMetricTest method jmxMetricRecordStatsSubTypeMono.
@Test
public void jmxMetricRecordStatsSubTypeMono() {
StatsEngine stats = new StatsEngineImpl();
JmxMetric metric = JmxMetric.create(new String[] { "first", "second" }, "theDiff", JmxAction.SUBTRACT_ALL_FROM_FIRST, JmxType.MONOTONICALLY_INCREASING);
Map<String, Float> values = new HashMap<>();
values.put("first", 10f);
values.put("second", 7f);
metric.recordSingleMBeanStats(stats, "Jmx/Sample/", values);
Assert.assertEquals(1, stats.getStats("Jmx/Sample/theDiff").getCallCount());
Assert.assertEquals(3f, stats.getStats("Jmx/Sample/theDiff").getTotal(), .001);
values.clear();
values.put("first", 12f);
values.put("second", 5f);
metric.recordSingleMBeanStats(stats, "Jmx/Sample/", values);
Assert.assertEquals(2, stats.getStats("Jmx/Sample/theDiff").getCallCount());
Assert.assertEquals(7f, stats.getStats("Jmx/Sample/theDiff").getTotal(), .001);
}
use of com.newrelic.agent.stats.StatsEngine in project newrelic-java-agent by newrelic.
the class JmxMetricTest method jmxMetricRecordStatsSubTypeSimpleMulti.
@Test
public void jmxMetricRecordStatsSubTypeSimpleMulti() {
StatsEngine stats = new StatsEngineImpl();
JmxMetric metric = JmxMetric.create(new String[] { "first", "second" }, "theDiff", JmxAction.SUBTRACT_ALL_FROM_FIRST, JmxType.SIMPLE);
Map<String, Float> values = new HashMap<>();
values.put("first", 10f);
values.put("second", 7f);
Map<String, Float> actual = new HashMap<>();
metric.applySingleMBean("Jmx/Sample/", values, actual);
metric.recordMultMBeanStats(stats, actual);
Assert.assertEquals(1, stats.getStats("Jmx/Sample/theDiff").getCallCount());
Assert.assertEquals(3f, stats.getStats("Jmx/Sample/theDiff").getTotal(), .001);
values.clear();
actual.clear();
values.put("first", 12f);
values.put("second", 6f);
metric.applySingleMBean("Jmx/Sample/", values, actual);
metric.recordMultMBeanStats(stats, actual);
Assert.assertEquals(2, stats.getStats("Jmx/Sample/theDiff").getCallCount());
Assert.assertEquals(9f, stats.getStats("Jmx/Sample/theDiff").getTotal(), .001);
}
Aggregations