use of com.newrelic.agent.stats.SimpleStatsEngine in project newrelic-java-agent by newrelic.
the class JavaUtilLoggerTest method getLogMetricsCounts.
private Map<String, Integer> getLogMetricsCounts() {
Transaction transaction = Transaction.getTransaction();
TransactionStats transactionStats = transaction.getTransactionActivity().getTransactionStats();
SimpleStatsEngine engine = transactionStats.getUnscopedStats();
final Map<String, Integer> metrics = new HashMap<>();
metrics.put("Logging/lines", engine.getStats("Logging/lines").getCallCount());
metrics.put("Logging/lines/FINEST", engine.getStats("Logging/lines/FINEST").getCallCount());
metrics.put("Logging/lines/FINER", engine.getStats("Logging/lines/FINER").getCallCount());
metrics.put("Logging/lines/FINE", engine.getStats("Logging/lines/FINE").getCallCount());
metrics.put("Logging/lines/CONFIG", engine.getStats("Logging/lines/CONFIG").getCallCount());
metrics.put("Logging/lines/INFO", engine.getStats("Logging/lines/INFO").getCallCount());
metrics.put("Logging/lines/WARNING", engine.getStats("Logging/lines/WARNING").getCallCount());
metrics.put("Logging/lines/SEVERE", engine.getStats("Logging/lines/SEVERE").getCallCount());
return metrics;
}
use of com.newrelic.agent.stats.SimpleStatsEngine in project newrelic-java-agent by newrelic.
the class TransactionActivity method finishFlyweightTracer.
public void finishFlyweightTracer(TracedMethod parent, long startInNanos, long finishInNanos, String className, String methodName, String methodDesc, String metricName, String[] rollupMetricNames) {
try {
if (parent instanceof DefaultTracer) {
DefaultTracer parentTracer = (DefaultTracer) parent;
long duration = finishInNanos - startInNanos;
if (!flyweightInProgress) {
Agent.LOG.log(Level.FINEST, "Error finishing tracer - the last tracer is of the wrong type.");
}
if (duration < 0) {
Agent.LOG.log(Level.FINEST, "A tracer finished with a negative duration.");
return;
}
transactionStats.getScopedStats().getOrCreateResponseTimeStats(metricName).recordResponseTimeInNanos(duration);
if (Agent.isDebugEnabled()) {
Agent.LOG.log(Level.FINEST, "Finished flyweight tracer {0} ({1}.{2}{3})", metricName, className, methodName, methodDesc);
}
if (rollupMetricNames != null) {
SimpleStatsEngine unscopedStats = transactionStats.getUnscopedStats();
for (String name : rollupMetricNames) {
unscopedStats.getOrCreateResponseTimeStats(name).recordResponseTimeInNanos(duration);
}
}
parentTracer.childTracerFinished(duration);
}
} catch (Throwable t) {
Agent.LOG.log(Level.FINEST, t, "Error finishing tracer");
} finally {
flyweightInProgress = false;
}
}
Aggregations