Search in sources :

Example 11 with SimpleStatsEngine

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;
}
Also used : TransactionStats(com.newrelic.agent.stats.TransactionStats) Transaction(com.newrelic.agent.Transaction) HashMap(java.util.HashMap) SimpleStatsEngine(com.newrelic.agent.stats.SimpleStatsEngine)

Example 12 with SimpleStatsEngine

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;
    }
}
Also used : DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) SimpleStatsEngine(com.newrelic.agent.stats.SimpleStatsEngine)

Aggregations

SimpleStatsEngine (com.newrelic.agent.stats.SimpleStatsEngine)12 TransactionStats (com.newrelic.agent.stats.TransactionStats)5 Test (org.junit.Test)5 HashMap (java.util.HashMap)3 Transaction (com.newrelic.agent.Transaction)2 TransactionData (com.newrelic.agent.TransactionData)2 AgentConfig (com.newrelic.agent.config.AgentConfig)2 ResponseTimeStats (com.newrelic.agent.stats.ResponseTimeStats)2 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)2 PriorityTransactionName (com.newrelic.agent.transaction.PriorityTransactionName)2 DistributedTracePayloadBuilder (com.newrelic.agent.DistributedTracePayloadBuilder)1 MetricData (com.newrelic.agent.MetricData)1 DistributedTracingConfig (com.newrelic.agent.config.DistributedTracingConfig)1 TracedMetricData (com.newrelic.agent.introspec.TracedMetricData)1 CountStats (com.newrelic.agent.stats.CountStats)1 Stats (com.newrelic.agent.stats.Stats)1 StatsBase (com.newrelic.agent.stats.StatsBase)1 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)1 DistributedTracePayloadImpl (com.newrelic.agent.tracing.DistributedTracePayloadImpl)1 TransactionCounts (com.newrelic.agent.transaction.TransactionCounts)1