use of com.newrelic.agent.stats.Stats in project newrelic-java-agent by newrelic.
the class RPMServiceTest method createMetricData.
private List<MetricData> createMetricData(StatsEngine statsEngine, int size) {
ArrayList<MetricData> data = new ArrayList<>();
for (float i = 0; i < size; i++) {
String metric = "Metric " + i;
Stats stats = StatsTest.createStats(statsEngine);
stats.recordDataPoint(i / (System.currentTimeMillis() % 10000));
data.add(MetricData.create(MetricName.create(metric), stats));
}
return data;
}
use of com.newrelic.agent.stats.Stats in project newrelic-java-agent by newrelic.
the class DefaultTracerTest method checkUnknownDatastoreSupportabilityMetrics.
private void checkUnknownDatastoreSupportabilityMetrics(String product, int expectedUnkownHost, int expectedUnknownPort, int expectedUnknownDatabaseName) {
StatsService statsService = ServiceFactory.getStatsService();
StatsEngine statsEngine = statsService.getStatsEngineForHarvest("Unit Test");
String unknownHostMetricName = new StringBuilder(MetricNames.SUPPORTABILITY_DATASTORE_PREFIX).append(product).append(MetricNames.SUPPORTABILITY_DATASTORE_UNKNOWN_HOST).toString();
Stats unknownHostMetric = statsEngine.getStats(unknownHostMetricName);
assertEquals(expectedUnkownHost, unknownHostMetric.getCallCount());
String unknownPortMetricName = new StringBuilder(MetricNames.SUPPORTABILITY_DATASTORE_PREFIX).append(product).append(MetricNames.SUPPORTABILITY_DATASTORE_UNKNOWN_PORT).toString();
Stats unknownPortMetric = statsEngine.getStats(unknownPortMetricName);
assertEquals(expectedUnknownPort, unknownPortMetric.getCallCount());
String unknownDatabaseMetricName = new StringBuilder(MetricNames.SUPPORTABILITY_DATASTORE_PREFIX).append(product).append(MetricNames.SUPPORTABILITY_DATASTORE_UNKNOWN_DATABASE_NAME).toString();
Stats unknownDatabaseNameMetric = statsEngine.getStats(unknownDatabaseMetricName);
assertEquals(expectedUnknownDatabaseName, unknownDatabaseNameMetric.getCallCount());
}
use of com.newrelic.agent.stats.Stats in project newrelic-java-agent by newrelic.
the class HibernateStatsTest method flushes.
@Trace(dispatcher = true)
@Test
public void flushes() {
float count = 10;
for (int i = 0; i < count; i++) {
Player dude = new Player();
dude.setId(nextId++);
session.save(null, dude);
session.flush();
}
runSamplers();
Stats stats = getTransactionStats().getStats("HibernateStatistics/flushes");
assertEquals(count, stats.getTotal(), 0);
}
use of com.newrelic.agent.stats.Stats in project newrelic-java-agent by newrelic.
the class HibernateStatsTest method insertsAndLoads.
@Trace(dispatcher = true)
@Test
public void insertsAndLoads() {
runSamplers();
getTransactionStats().clear();
Transaction transaction = session.beginTransaction();
Player dude = new Player();
dude.setId(nextId++);
session.save(null, dude);
Game game = new Game();
game.setId(nextId++);
session.save(null, game);
session.load(Player.class, dude.getId());
transaction.commit();
Session session2 = sessionFactory.openSession();
Criteria criteria = session2.createCriteria(Player.class);
assertEquals(1, criteria.list().size());
// getTransactionStats().clear();
runSamplers();
SimpleStatsEngine statsEngine = getTransactionStats();
Stats stats = statsEngine.getStats("HibernateStatistics/Entity/test.newrelic.test.agent.hibernate.Player/loads");
assertEquals(1f, stats.getTotal(), 0);
statsEngine.getStats("HibernateStatistics/entityLoads");
assertEquals(1f, stats.getTotal(), 0);
stats = statsEngine.getStats("HibernateStatistics/Entity/test.newrelic.test.agent.hibernate.Player/inserts");
assertEquals(1f, stats.getTotal(), 0);
stats = statsEngine.getStats("HibernateStatistics/entityInserts");
assertEquals(2f, stats.getTotal(), 0);
stats = statsEngine.getStats("HibernateStatistics/Entity/test.newrelic.test.agent.hibernate.Player/deletes");
assertEquals(1, stats.getCallCount());
assertEquals(0f, stats.getTotal(), 0);
statsEngine = getTransactionStats();
statsEngine.clear();
runSamplers();
stats = statsEngine.getStats("HibernateStatistics/Entity/test.newrelic.test.agent.hibernate.Player/inserts");
assertEquals(1, stats.getCallCount());
assertEquals(0f, stats.getTotal(), 0);
}
use of com.newrelic.agent.stats.Stats in project newrelic-java-agent by newrelic.
the class HibernateStatsTest method sessionStats.
@Trace(dispatcher = true)
@Test
public void sessionStats() {
runSamplers();
getTransactionStats().clear();
float count = 10;
for (int i = 0; i < count; i++) {
Session openSession = sessionFactory.openSession();
openSession.close();
}
Session openSession = sessionFactory.openSession();
runSamplers();
Stats stats = getTransactionStats().getStats("HibernateStatistics/sessionOpens");
assertEquals(count + 1, stats.getTotal(), 0);
stats = getTransactionStats().getStats("HibernateStatistics/sessionCloses");
assertEquals(count, stats.getTotal(), 0);
openSession.close();
}
Aggregations