Search in sources :

Example 11 with MetricName

use of com.newrelic.agent.metric.MetricName in project newrelic-java-agent by newrelic.

the class ApiTest method testNoExceptionRecordMetricNoTransaction.

@Test
public void testNoExceptionRecordMetricNoTransaction() throws Exception {
    final MetricName name = MetricName.create("roger");
    StatsWork statsWork = new StatsWork() {

        @Override
        public void doWork(StatsEngine statsEngine) {
            statsEngine.getApdexStats(name);
            try {
                statsEngine.getStats(name);
                Assert.fail("expected java.lang.RuntimeException");
            } catch (RuntimeException e) {
            // expected
            }
        }

        @Override
        public String getAppName() {
            return null;
        }
    };
    ServiceFactory.getStatsService().doStatsWork(statsWork, "statsWorkName");
    NewRelic.recordMetric(name.getName(), 1.0f);
}
Also used : MetricName(com.newrelic.agent.metric.MetricName) StatsWork(com.newrelic.agent.stats.StatsWork) StatsEngine(com.newrelic.agent.stats.StatsEngine) BrowserConfigTest(com.newrelic.agent.browser.BrowserConfigTest) Test(org.junit.Test)

Example 12 with MetricName

use of com.newrelic.agent.metric.MetricName in project newrelic-java-agent by newrelic.

the class QueueTimeTracker method recordMetrics.

public void recordMetrics(TransactionStats statsEngine) {
    if (queueTime > 0L) {
        MetricName name = MetricName.QUEUE_TIME;
        statsEngine.getUnscopedStats().getOrCreateResponseTimeStats(name.getName()).recordResponseTimeInNanos(queueTime);
    }
}
Also used : MetricName(com.newrelic.agent.metric.MetricName)

Example 13 with MetricName

use of com.newrelic.agent.metric.MetricName in project newrelic-java-agent by newrelic.

the class TransactionDataList method getMetricCounts.

public Map<String, Integer> getMetricCounts(Set<MetricName> responseTimeMetricNames) {
    Map<String, Integer> metricNameToCounts = new HashMap<>();
    synchronized (statsEngine) {
        for (MetricName responseTimeMetricName : responseTimeMetricNames) {
            ResponseTimeStats responseTimeStats = statsEngine.getResponseTimeStats(responseTimeMetricName);
            metricNameToCounts.put(responseTimeMetricName.getName(), responseTimeStats.getCallCount());
        }
    }
    return metricNameToCounts;
}
Also used : ResponseTimeStats(com.newrelic.agent.stats.ResponseTimeStats) MetricName(com.newrelic.agent.metric.MetricName) HashMap(java.util.HashMap)

Example 14 with MetricName

use of com.newrelic.agent.metric.MetricName in project newrelic-java-agent by newrelic.

the class AgentHelper method getMetricNames.

public static Set<MetricName> getMetricNames(Collection<MetricData> dataList) {
    Set<MetricName> metrics = new HashSet<>();
    for (MetricData data : dataList) {
        MetricName metricName = data.getMetricName();
        metrics.add(metricName);
    }
    return metrics;
}
Also used : MetricName(com.newrelic.agent.metric.MetricName) HashSet(java.util.HashSet)

Aggregations

MetricName (com.newrelic.agent.metric.MetricName)14 Test (org.junit.Test)6 StatsEngine (com.newrelic.agent.stats.StatsEngine)5 ArrayList (java.util.ArrayList)3 ResponseTimeStats (com.newrelic.agent.stats.ResponseTimeStats)2 StatsTest (com.newrelic.agent.stats.StatsTest)2 StatsWork (com.newrelic.agent.stats.StatsWork)2 Tracer (com.newrelic.agent.tracers.Tracer)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 MetricData (com.newrelic.agent.MetricData)1 TransactionActivity (com.newrelic.agent.TransactionActivity)1 TransactionData (com.newrelic.agent.TransactionData)1 TransactionDataList (com.newrelic.agent.TransactionDataList)1 BrowserConfigTest (com.newrelic.agent.browser.BrowserConfigTest)1 CountStats (com.newrelic.agent.stats.CountStats)1 StatsEngineImpl (com.newrelic.agent.stats.StatsEngineImpl)1 BasicThreadInfo (com.newrelic.agent.threads.BasicThreadInfo)1 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1