use of com.newrelic.agent.stats.StatsEngineImpl in project newrelic-java-agent by newrelic.
the class JmxServiceTest method process.
@Test
public void process() {
String appName = ServiceFactory.getConfigService().getDefaultAgentConfig().getApplicationName();
StatsEngine statsEngine = new StatsEngineImpl();
JmxService jmxService = ServiceFactory.getJmxService();
jmxService.beforeHarvest(appName, statsEngine);
}
use of com.newrelic.agent.stats.StatsEngineImpl in project newrelic-java-agent by newrelic.
the class JmxServiceTest method testAddingToConfig.
@Test
public void testAddingToConfig() {
JmxService jmxService = ServiceFactory.getJmxService();
List<JmxGet> configurations = jmxService.getConfigurations();
int startupsize = configurations.size();
TomcatJmxValues tomcat = new TomcatJmxValues();
ResinJmxValues resin = new ResinJmxValues();
jmxService.addJmxFrameworkValues(tomcat);
jmxService.addJmxFrameworkValues(resin);
String appName = ServiceFactory.getConfigService().getDefaultAgentConfig().getApplicationName();
StatsEngine statsEngine = new StatsEngineImpl();
jmxService.beforeHarvest(appName, statsEngine);
int expectedSize = startupsize + tomcat.getFrameworkMetrics().size() + resin.getFrameworkMetrics().size();
Assert.assertEquals("Failed on initial check: " + configurations.toString(), expectedSize, configurations.size());
GlassfishJmxValues glassfish = new GlassfishJmxValues();
jmxService.addJmxFrameworkValues(glassfish);
jmxService.beforeHarvest(appName, statsEngine);
int newExpectedSize = expectedSize + glassfish.getFrameworkMetrics().size();
Assert.assertEquals("Failed on second check: " + configurations.toString(), newExpectedSize, configurations.size());
JettyJmxMetrics jetty = new JettyJmxMetrics();
jmxService.addJmxFrameworkValues(jetty);
jmxService.beforeHarvest(appName, statsEngine);
int thirdExpectedSize = newExpectedSize + jetty.getFrameworkMetrics().size();
Assert.assertEquals("Failed on third check: " + configurations.toString(), thirdExpectedSize, configurations.size());
}
use of com.newrelic.agent.stats.StatsEngineImpl in project newrelic-java-agent by newrelic.
the class J2EEStatsAttributeTest method processStatisticCountTest.
@Test
public void processStatisticCountTest() {
CountStatistic count = new CountStatistic() {
@Override
public String getUnit() {
return null;
}
@Override
public long getStartTime() {
return 0;
}
@Override
public String getName() {
return "LiveCount";
}
@Override
public long getLastSampleTime() {
return 0;
}
@Override
public String getDescription() {
return null;
}
@Override
public long getCount() {
return 55;
}
};
Attribute att = new Attribute("stats.LiveCount", count);
StatsEngine statsEngine = new StatsEngineImpl();
J2EEStatsAttributeProcessor.processStatistic(statsEngine, "Jmx/Test", att, count);
Assert.assertEquals(55, statsEngine.getStats("Jmx/Test/LiveCount").getTotal(), .001);
}
use of com.newrelic.agent.stats.StatsEngineImpl 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.StatsEngineImpl 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);
}
Aggregations