Search in sources :

Example 6 with Introspector

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

the class JerseyTests method syncEndpointWithIOExceptionTest.

@Test
public void syncEndpointWithIOExceptionTest() {
    Response response = getRequest("/api/async/syncEndpointWithIOException", server.getURI().getPort());
    assertNotNull(response);
    assertEquals(500, response.statusCode());
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    int finishedTransactionCount = introspector.getFinishedTransactionCount(TIMEOUT);
    assertEquals(1, finishedTransactionCount);
    String transactionName = introspector.getTransactionNames().toArray()[0].toString();
    assertNotNull(transactionName);
    assertEquals("WebTransaction/AsyncResource/syncEndpointWithIOException", transactionName);
}
Also used : Response(com.jayway.restassured.response.Response) Introspector(com.newrelic.agent.introspec.Introspector) Test(org.junit.Test)

Example 7 with Introspector

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

the class JerseyTests method asyncTimeoutTestThrowable.

@Test
public void asyncTimeoutTestThrowable() {
    Response response = getRequest("/api/async/timeoutThrowable", server.getURI().getPort());
    assertNotNull(response);
    assertEquals(500, response.statusCode());
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    int finishedTransactionCount = introspector.getFinishedTransactionCount(TIMEOUT);
    assertEquals(1, finishedTransactionCount);
    String transactionName = introspector.getTransactionNames().toArray()[0].toString();
    assertNotNull(transactionName);
    assertEquals("WebTransaction/AsyncResource/timeoutThrowable", transactionName);
}
Also used : Response(com.jayway.restassured.response.Response) Introspector(com.newrelic.agent.introspec.Introspector) Test(org.junit.Test)

Example 8 with Introspector

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

the class JerseyClientTest method testHttpMethods.

@Test
public void testHttpMethods() throws Exception {
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    URI endpoint = server.getEndPoint();
    requestHttpMethods(endpoint.toURL().toString());
    // transaction
    String txName = "OtherTransaction/Custom/com.nr.agent.instrumentation.jerseyclient.JerseyClientTest/requestHttpMethods";
    assertEquals(1, introspector.getFinishedTransactionCount(3000));
    Collection<String> names = introspector.getTransactionNames();
    assertTrue(names.contains(txName));
    // external request test should go here
    Collection<ExternalRequest> externalRequests = InstrumentationTestRunner.getIntrospector().getExternalRequests(txName);
    assertEquals(4, externalRequests.size());
    assertEquals(4, MetricsHelper.getUnscopedMetricCount("External/localhost/all"));
    assertEquals(4, MetricsHelper.getUnscopedMetricCount("External/allOther"));
    assertEquals(4, MetricsHelper.getUnscopedMetricCount("External/all"));
}
Also used : Introspector(com.newrelic.agent.introspec.Introspector) URI(java.net.URI) ExternalRequest(com.newrelic.agent.introspec.ExternalRequest) Test(org.junit.Test)

Example 9 with Introspector

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

the class MariaDbTest method testPreparedStatementQuery.

@Test
@Ignore
public void testPreparedStatementQuery() throws Exception {
    mariaDbPreparedStatementQuery();
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    Assert.assertEquals(1, introspector.getFinishedTransactionCount());
    DatastoreHelper helper = new DatastoreHelper("MySQL");
    helper.assertAggregateMetrics();
    helper.assertUnscopedOperationMetricCount("select", 1);
}
Also used : Introspector(com.newrelic.agent.introspec.Introspector) DatastoreHelper(com.newrelic.agent.introspec.DatastoreHelper) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 10 with Introspector

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

the class Jersey2ClientTest method testHttpMethods.

@Test
public void testHttpMethods() throws Exception {
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    URI endpoint = server.getEndPoint();
    requestHttpMethods(endpoint.toURL().toString());
    // transaction
    String txName = "OtherTransaction/Custom/com.nr.agent.instrumentation.jerseyclient2.Jersey2ClientTest/requestHttpMethods";
    assertEquals(1, introspector.getFinishedTransactionCount(3000));
    assertTrue(introspector.getTransactionNames().contains(txName));
    // external request test should go here
    Collection<ExternalRequest> externalRequests = introspector.getExternalRequests(txName);
    assertEquals(4, externalRequests.size());
    assertEquals(4, MetricsHelper.getUnscopedMetricCount("External/localhost/all"));
    assertEquals(4, MetricsHelper.getUnscopedMetricCount("External/allOther"));
    assertEquals(4, MetricsHelper.getUnscopedMetricCount("External/all"));
}
Also used : Introspector(com.newrelic.agent.introspec.Introspector) URI(java.net.URI) ExternalRequest(com.newrelic.agent.introspec.ExternalRequest) Test(org.junit.Test)

Aggregations

Introspector (com.newrelic.agent.introspec.Introspector)452 Test (org.junit.Test)432 TransactionEvent (com.newrelic.agent.introspec.TransactionEvent)150 Java16IncompatibleTest (com.newrelic.test.marker.Java16IncompatibleTest)88 Java17IncompatibleTest (com.newrelic.test.marker.Java17IncompatibleTest)88 Java11IncompatibleTest (com.newrelic.test.marker.Java11IncompatibleTest)86 Java12IncompatibleTest (com.newrelic.test.marker.Java12IncompatibleTest)86 Java13IncompatibleTest (com.newrelic.test.marker.Java13IncompatibleTest)86 Java14IncompatibleTest (com.newrelic.test.marker.Java14IncompatibleTest)86 Java15IncompatibleTest (com.newrelic.test.marker.Java15IncompatibleTest)86 DatastoreHelper (com.newrelic.agent.introspec.DatastoreHelper)69 ExternalRequest (com.newrelic.agent.introspec.ExternalRequest)51 TracedMetricData (com.newrelic.agent.introspec.TracedMetricData)51 URI (java.net.URI)41 Java7IncompatibleTest (com.newrelic.test.marker.Java7IncompatibleTest)32 TransactionTrace (com.newrelic.agent.introspec.TransactionTrace)25 TraceSegment (com.newrelic.agent.introspec.TraceSegment)19 Matchers.containsString (org.hamcrest.Matchers.containsString)16 Java10IncompatibleTest (com.newrelic.test.marker.Java10IncompatibleTest)13 Java9IncompatibleTest (com.newrelic.test.marker.Java9IncompatibleTest)13