Search in sources :

Example 56 with TracedMetricData

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

the class RabbitMQTest method testMessageListener.

@Test
public void testMessageListener() throws IOException, InterruptedException {
    final String queueName = UUID.randomUUID().toString();
    final String messageForListener = "Hello message listener!";
    channel.queueDeclare(queueName, false, false, true, Collections.<String, Object>emptyMap());
    channel.basicPublish(DEFAULT_EXCHANGE, queueName, new AMQP.BasicProperties(), messageForListener.getBytes());
    channel.basicConsume(queueName, new DefaultConsumer(channel) {

        @Override
        public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
            assertEquals(messageForListener, new String(body));
        }
    });
    // Let handleDelivery Transaction to finish.
    Thread.sleep(1000);
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    String expectedTransactionName = "OtherTransaction/Message/RabbitMQ/Exchange/Named/Default";
    final Collection<String> transactionNames = introspector.getTransactionNames();
    assertTrue(transactionNames.contains(expectedTransactionName));
    Map<String, TracedMetricData> metrics = introspector.getMetricsForTransaction(expectedTransactionName);
    // Do not record consume metric, message has already been delivered
    assertFalse(metrics.containsKey("MessageBroker/RabbitMQ/Exchange/Consume/Named/Default"));
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) DefaultConsumer(com.rabbitmq.client.DefaultConsumer) AMQP(com.rabbitmq.client.AMQP) Introspector(com.newrelic.agent.introspec.Introspector) IOException(java.io.IOException) Envelope(com.rabbitmq.client.Envelope) Test(org.junit.Test)

Example 57 with TracedMetricData

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

the class RabbitMQTest_Integration method testProduceConsume.

@Test
public void testProduceConsume() throws IOException {
    final String queueName = UUID.randomUUID().toString();
    putAndGetInTransaction(queueName);
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    String expectedTransactionName = String.format("OtherTransaction/Message/RabbitMQ/Queue/Named/%s", queueName);
    final Collection<String> transactionNames = introspector.getTransactionNames();
    assertTrue(transactionNames.contains(expectedTransactionName));
    Map<String, TracedMetricData> metrics = introspector.getMetricsForTransaction(expectedTransactionName);
    assertTrue(metrics.containsKey(String.format("MessageBroker/RabbitMQ/Queue/Consume/Named/%s", queueName)));
    assertTrue(metrics.containsKey(String.format("MessageBroker/RabbitMQ/Queue/Produce/Named/%s", queueName)));
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) Introspector(com.newrelic.agent.introspec.Introspector) Test(org.junit.Test)

Example 58 with TracedMetricData

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

the class SpringControllerTests method testPathClass.

@Test
public void testPathClass() {
    assertEquals("PathClass", App.pathClass());
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    String expectedTransactionName = "OtherTransaction/SpringController/pathClass/methodTestPath (GET)";
    Map<String, TracedMetricData> metrics = introspector.getMetricsForTransaction(expectedTransactionName);
    assertEquals(1, metrics.get("Java/com.nr.agent.instrumentation.PathClass/testPath").getCallCount());
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) Introspector(com.newrelic.agent.introspec.Introspector) Test(org.junit.Test)

Example 59 with TracedMetricData

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

the class SpringControllerTests method testMethodPath.

@Test
public void testMethodPath() {
    assertEquals("methodPath", App.methodPath());
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    String expectedTransactionName = "OtherTransaction/SpringController/pathTest (GET)";
    Map<String, TracedMetricData> metrics = introspector.getMetricsForTransaction(expectedTransactionName);
    assertEquals(1, metrics.get("Java/com.nr.agent.instrumentation.TestPathAnnotationForMethod/testPathAnnotation").getCallCount());
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) Introspector(com.newrelic.agent.introspec.Introspector) Test(org.junit.Test)

Example 60 with TracedMetricData

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

the class SpringControllerTests method testNestedValuePath.

@Test
public void testNestedValuePath() {
    assertEquals("nestedValuePath", App.nestedValuePath());
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    String expectedTransactionName = "OtherTransaction/SpringController/valuePath/innerPath (GET)";
    Map<String, TracedMetricData> metrics = introspector.getMetricsForTransaction(expectedTransactionName);
    assertEquals(1, metrics.get("Java/com.nr.agent.instrumentation.NestedValuePath/nestedValuePath").getCallCount());
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) Introspector(com.newrelic.agent.introspec.Introspector) 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