Search in sources :

Example 26 with TracedMetricData

use of com.newrelic.agent.introspec.TracedMetricData in project newrelic-java-agent by newrelic.

the class IntrospectorStatsService method convertToTracedMetric.

private Map<String, TracedMetricData> convertToTracedMetric(SimpleStatsEngine currentEngine) {
    Map<String, TracedMetricData> output = Maps.newHashMapWithExpectedSize(currentEngine.getSize());
    for (Entry<String, StatsBase> current : currentEngine.getStatsMap().entrySet()) {
        if (current.getValue() instanceof CountStats) {
            TracedMetricData data = TracedMetricImpl.getTracedMetricFromStatsBase(current.getKey(), (CountStats) current.getValue());
            output.put(current.getKey(), data);
        }
    }
    return output;
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) CountStats(com.newrelic.agent.stats.CountStats) StatsBase(com.newrelic.agent.stats.StatsBase)

Example 27 with TracedMetricData

use of com.newrelic.agent.introspec.TracedMetricData in project newrelic-java-agent by newrelic.

the class IntrospectorStatsService method getUnscopedMetrics.

public Map<String, TracedMetricData> getUnscopedMetrics() {
    SimpleStatsEngine unscoped = engine.getUnscopedStatsForTesting();
    Map<String, TracedMetricData> unscopedMetricMap = convertToTracedMetric(unscoped);
    // copies of scoped metrics -> unscoped
    List<MetricData> allScopedMetricData = new ArrayList<>();
    for (Entry<String, SimpleStatsEngine> entry : engine.getScopedStatsForTesting().entrySet()) {
        allScopedMetricData.addAll(entry.getValue().getMetricData(metricNormalizer, entry.getKey()));
    }
    List<MetricData> unscopedCopies = StatsEngineImpl.createUnscopedCopies(metricNormalizer, allScopedMetricData);
    for (MetricData unscopedCopy : unscopedCopies) {
        if (unscopedCopy.getStats() instanceof CountStats) {
            String metricName = unscopedCopy.getMetricName().getName();
            TracedMetricData data = TracedMetricImpl.getTracedMetricFromStatsBase(metricName, (CountStats) unscopedCopy.getStats());
            unscopedMetricMap.put(metricName, data);
        }
    }
    return unscopedMetricMap;
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) CountStats(com.newrelic.agent.stats.CountStats) ArrayList(java.util.ArrayList) SimpleStatsEngine(com.newrelic.agent.stats.SimpleStatsEngine) MetricData(com.newrelic.agent.MetricData) TracedMetricData(com.newrelic.agent.introspec.TracedMetricData)

Example 28 with TracedMetricData

use of com.newrelic.agent.introspec.TracedMetricData in project newrelic-java-agent by newrelic.

the class JaxRsTests method testUserService.

@Test
public void testUserService() {
    assertEquals("User Features!", App.callUserServiceImpl());
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    String expectedTransactionName = "OtherTransaction/RestWebService/v1/user/{id}/features (GET)";
    Map<String, TracedMetricData> metricsForTransaction = introspector.getMetricsForTransaction(expectedTransactionName);
    assertEquals(1, metricsForTransaction.get("Java/com.nr.instrumentation.javax.ws.rs.api.UserServiceImpl/getUserFeatures").getCallCount());
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) Introspector(com.newrelic.agent.introspec.Introspector) Java7IncompatibleTest(com.newrelic.test.marker.Java7IncompatibleTest) Test(org.junit.Test)

Example 29 with TracedMetricData

use of com.newrelic.agent.introspec.TracedMetricData in project newrelic-java-agent by newrelic.

the class JaxRsTests method testTransactionNameInterfaceException.

@Test
public void testTransactionNameInterfaceException() {
    assertEquals("Got it from the interface!", App.callExceptionInterfaceResourceInTransaction());
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    String expectedTransactionName = "OtherTransaction/RestWebService/interface (GET)";
    Map<String, TracedMetricData> metricsForTransaction = introspector.getMetricsForTransaction(expectedTransactionName);
    assertEquals(1, metricsForTransaction.get("Java/com.nr.instrumentation.javax.ws.rs.api.InterfaceResourceImpl/exceptionTest").getCallCount());
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) Introspector(com.newrelic.agent.introspec.Introspector) Java7IncompatibleTest(com.newrelic.test.marker.Java7IncompatibleTest) Test(org.junit.Test)

Example 30 with TracedMetricData

use of com.newrelic.agent.introspec.TracedMetricData in project newrelic-java-agent by newrelic.

the class JaxRsTests method testTransactionNameClassLargeParameters.

@Test
public void testTransactionNameClassLargeParameters() {
    assertEquals("Got it!", App.callLargeParametersClassResourceInTransaction());
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    String expectedTransactionName = "OtherTransaction/RestWebService/class (GET)";
    Map<String, TracedMetricData> metricsForTransaction = introspector.getMetricsForTransaction(expectedTransactionName);
    assertEquals(1, metricsForTransaction.get("Java/com.nr.instrumentation.javax.ws.rs.api.ClassResource/largeNumberOfParametersTest").getCallCount());
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) Introspector(com.newrelic.agent.introspec.Introspector) Java7IncompatibleTest(com.newrelic.test.marker.Java7IncompatibleTest) Test(org.junit.Test)

Aggregations

TracedMetricData (com.newrelic.agent.introspec.TracedMetricData)65 Test (org.junit.Test)58 Introspector (com.newrelic.agent.introspec.Introspector)51 Java7IncompatibleTest (com.newrelic.test.marker.Java7IncompatibleTest)15 URI (java.net.URI)12 TransactionEvent (com.newrelic.agent.introspec.TransactionEvent)10 ExternalRequest (com.newrelic.agent.introspec.ExternalRequest)7 Tracer (com.newrelic.agent.tracers.Tracer)7 TransactionTrace (com.newrelic.agent.introspec.TransactionTrace)6 AMQP (com.rabbitmq.client.AMQP)6 DefaultConsumer (com.rabbitmq.client.DefaultConsumer)6 Envelope (com.rabbitmq.client.Envelope)6 IOException (java.io.IOException)6 ActorSystem (akka.actor.ActorSystem)5 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)4 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)4 Vertx (io.vertx.core.Vertx)4 HttpServer (io.vertx.core.http.HttpServer)4 TraceSegment (com.newrelic.agent.introspec.TraceSegment)3 Trace (com.newrelic.api.agent.Trace)3