use of com.newrelic.agent.introspec.Introspector in project newrelic-java-agent by newrelic.
the class MongoDbAsync360Test method testCollectionApi.
@Test
public void testCollectionApi() throws Exception {
runMongoDbAsyncQuickStart();
Introspector introspector = InstrumentationTestRunner.getIntrospector();
assertEquals(1, introspector.getFinishedTransactionCount(1000));
DatastoreHelper helper = new DatastoreHelper(MONGODB_PRODUCT);
helper.assertAggregateMetrics();
Collection<String> transactionNames = InstrumentationTestRunner.getIntrospector().getTransactionNames();
assertEquals(1, transactionNames.size());
String txName = transactionNames.iterator().next();
// Counts based on operations executed in MongoDbAsyncQuickStart
int insertOpExpectedCount = 1;
int insertManyOpExpectedCount = 1;
int updateOpExpectedCount = 1;
int updateManyOpExpectedCount = 1;
int deleteOpExpectedCount = 1;
int deleteManyOpExpectedCount = 1;
int findOpExpectedCount = 14;
int dropOpExpectedCount = 3;
int countOpExpectedCount = 1;
int bulkWriteOpExpectedCount = 2;
helper.assertUnifiedMetricCounts(txName, "insert", "test", insertOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "insertMany", "test", insertManyOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "update", "test", updateOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "updateMany", "test", updateManyOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "delete", "test", deleteOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "deleteMany", "test", deleteManyOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "find", "test", findOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "drop", "test", dropOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "count", "test", countOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "bulkWrite", "test", bulkWriteOpExpectedCount);
int totalOpCount = insertOpExpectedCount + insertManyOpExpectedCount + updateOpExpectedCount + updateManyOpExpectedCount + deleteOpExpectedCount + deleteManyOpExpectedCount + findOpExpectedCount + dropOpExpectedCount + countOpExpectedCount + bulkWriteOpExpectedCount;
// Should be equal to the sum of all above metric counts
assertEquals(totalOpCount, MetricsHelper.getUnscopedMetricCount("Datastore/all"));
assertEquals(totalOpCount, MetricsHelper.getUnscopedMetricCount("Datastore/MongoDB/allOther"));
assertEquals(totalOpCount, introspector.getTransactionEvents(txName).iterator().next().getDatabaseCallCount());
}
use of com.newrelic.agent.introspec.Introspector in project newrelic-java-agent by newrelic.
the class MongoDbAsync3110Test method testCollectionApi.
@Test
public void testCollectionApi() throws Exception {
runMongoDbAsyncQuickStart();
Introspector introspector = InstrumentationTestRunner.getIntrospector();
assertEquals(1, introspector.getFinishedTransactionCount(1000));
DatastoreHelper helper = new DatastoreHelper(MONGODB_PRODUCT);
helper.assertAggregateMetrics();
Collection<String> transactionNames = InstrumentationTestRunner.getIntrospector().getTransactionNames();
assertEquals(1, transactionNames.size());
String txName = transactionNames.iterator().next();
// Counts based on operations executed in MongoDbAsyncQuickStart
int insertOpExpectedCount = 1;
int insertManyOpExpectedCount = 1;
int updateOpExpectedCount = 1;
int updateManyOpExpectedCount = 1;
int deleteOpExpectedCount = 1;
int deleteManyOpExpectedCount = 1;
int findOpExpectedCount = 14;
int dropOpExpectedCount = 3;
int countOpExpectedCount = 1;
int bulkWriteOpExpectedCount = 2;
helper.assertUnifiedMetricCounts(txName, "insert", "test", insertOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "insertMany", "test", insertManyOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "update", "test", updateOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "updateMany", "test", updateManyOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "delete", "test", deleteOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "deleteMany", "test", deleteManyOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "find", "test", findOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "drop", "test", dropOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "count", "test", countOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "bulkWrite", "test", bulkWriteOpExpectedCount);
int totalOpCount = insertOpExpectedCount + insertManyOpExpectedCount + updateOpExpectedCount + updateManyOpExpectedCount + deleteOpExpectedCount + deleteManyOpExpectedCount + findOpExpectedCount + dropOpExpectedCount + countOpExpectedCount + bulkWriteOpExpectedCount;
// Should be equal to the sum of all above metric counts
assertEquals(totalOpCount, MetricsHelper.getUnscopedMetricCount("Datastore/all"));
assertEquals(totalOpCount, MetricsHelper.getUnscopedMetricCount("Datastore/MongoDB/allOther"));
assertEquals(totalOpCount, introspector.getTransactionEvents(txName).iterator().next().getDatabaseCallCount());
}
use of com.newrelic.agent.introspec.Introspector in project newrelic-java-agent by newrelic.
the class MongoDbAsync340Test method testCollectionApi.
@Test
public void testCollectionApi() throws Exception {
runMongoDbAsyncQuickStart();
Introspector introspector = InstrumentationTestRunner.getIntrospector();
assertEquals(1, introspector.getFinishedTransactionCount(1000));
DatastoreHelper helper = new DatastoreHelper(MONGODB_PRODUCT);
helper.assertAggregateMetrics();
Collection<String> transactionNames = InstrumentationTestRunner.getIntrospector().getTransactionNames();
assertEquals(1, transactionNames.size());
String txName = transactionNames.iterator().next();
// Counts based on operations executed in MongoDbAsyncQuickStart
int insertOpExpectedCount = 1;
int insertManyOpExpectedCount = 1;
int updateOpExpectedCount = 1;
int updateManyOpExpectedCount = 1;
int deleteOpExpectedCount = 1;
int deleteManyOpExpectedCount = 1;
int findOpExpectedCount = 10;
int dropOpExpectedCount = 3;
int countOpExpectedCount = 1;
int bulkWriteOpExpectedCount = 2;
helper.assertUnifiedMetricCounts(txName, "insert", "test", insertOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "insertMany", "test", insertManyOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "update", "test", updateOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "updateMany", "test", updateManyOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "delete", "test", deleteOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "deleteMany", "test", deleteManyOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "find", "test", findOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "drop", "test", dropOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "count", "test", countOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "bulkWrite", "test", bulkWriteOpExpectedCount);
int totalOpCount = insertOpExpectedCount + insertManyOpExpectedCount + updateOpExpectedCount + updateManyOpExpectedCount + deleteOpExpectedCount + deleteManyOpExpectedCount + findOpExpectedCount + dropOpExpectedCount + countOpExpectedCount + bulkWriteOpExpectedCount;
// Should be equal to the sum of all above metric counts
assertEquals(totalOpCount, MetricsHelper.getUnscopedMetricCount("Datastore/all"));
assertEquals(totalOpCount, MetricsHelper.getUnscopedMetricCount("Datastore/MongoDB/allOther"));
assertEquals(totalOpCount, introspector.getTransactionEvents(txName).iterator().next().getDatabaseCallCount());
}
use of com.newrelic.agent.introspec.Introspector in project newrelic-java-agent by newrelic.
the class NingAsyncHttpClient10Tests method testCat.
@Test
public void testCat() throws Exception {
Introspector introspector = InstrumentationTestRunner.getIntrospector();
URI endpoint = server.getEndPoint();
String host = endpoint.getHost();
int status = makeAsyncRequest(endpoint.toURL().toString());
assertEquals(200, status);
// transaction
String txName = "OtherTransaction/Custom/com.nr.agent.instrumentation.asynchttpclient.NingAsyncHttpClient10Tests/makeAsyncRequest";
assertEquals(2, introspector.getFinishedTransactionCount(TIMEOUT));
Collection<String> names = introspector.getTransactionNames();
assertEquals(2, names.size());
assertTrue(names.contains(server.getServerTransactionName()));
assertTrue(names.contains(txName));
// scoped metrics
assertEquals(1, MetricsHelper.getScopedMetricCount(txName, "ExternalTransaction/" + host + "/" + server.getCrossProcessId() + "/" + server.getServerTransactionName()));
assertEquals(1, MetricsHelper.getScopedMetricCount(txName, "Java/com.nr.agent.instrumentation.asynchttpclient.NingAsyncHttpClient10Tests/makeAsyncRequest"));
// unscoped metrics
assertEquals(1, MetricsHelper.getUnscopedMetricCount("ExternalTransaction/" + host + "/" + server.getCrossProcessId() + "/" + server.getServerTransactionName()));
assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/" + host + "/all"));
assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/all"));
assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/allOther"));
// events
Collection<TransactionEvent> transactionEvents = introspector.getTransactionEvents(txName);
assertEquals(1, transactionEvents.size());
TransactionEvent transactionEvent = transactionEvents.iterator().next();
assertEquals(1, transactionEvent.getExternalCallCount());
assertTrue(transactionEvent.getExternalDurationInSec() > 0);
CatHelper.verifyOneSuccessfulCat(introspector, txName);
// external request information
Collection<ExternalRequest> externalRequests = introspector.getExternalRequests(txName);
assertEquals(1, externalRequests.size());
ExternalRequest externalRequest = externalRequests.iterator().next();
assertEquals(1, externalRequest.getCount());
assertEquals(host, externalRequest.getHostname());
assertEquals(Integer.valueOf(200), externalRequest.getStatusCode());
assertEquals("OK", externalRequest.getStatusText());
}
use of com.newrelic.agent.introspec.Introspector in project newrelic-java-agent by newrelic.
the class NingAsyncHttpClient10Tests method testSuccess.
@Test
public void testSuccess() throws Exception {
Introspector introspector = InstrumentationTestRunner.getIntrospector();
URI endpoint = server.getEndPoint();
String host = endpoint.getHost();
String url = endpoint.toURL().toExternalForm();
int status = makeAsyncRequest(url + "?no-transaction=true");
assertEquals(200, status);
// transaction
assertEquals(1, introspector.getFinishedTransactionCount(TIMEOUT));
String txName = introspector.getTransactionNames().iterator().next();
// scoped metrics
assertEquals(1, MetricsHelper.getScopedMetricCount(txName, "External/" + host + "/AsyncHttpClient/onCompleted"));
// unscoped metrics
assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/" + host + "/AsyncHttpClient/onCompleted"));
assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/" + host + "/all"));
assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/all"));
assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/allOther"));
// events
Collection<TransactionEvent> transactionEvents = introspector.getTransactionEvents(txName);
assertEquals(1, transactionEvents.size());
TransactionEvent transactionEvent = transactionEvents.iterator().next();
assertEquals(1, transactionEvent.getExternalCallCount());
assertTrue(transactionEvent.getExternalDurationInSec() > 0);
// traces
Collection<TransactionTrace> traces = introspector.getTransactionTracesForTransaction(txName);
assertEquals(1, traces.size());
TransactionTrace trace = traces.iterator().next();
for (TraceSegment segment : trace.getInitialTraceSegment().getChildren()) {
Map<String, Object> attributes = segment.getTracerAttributes();
Object asyncContext = attributes.get("async_context");
if (asyncContext != null && asyncContext.equals("External")) {
assertEquals("", segment.getMethodName());
assertEquals("External Request", segment.getClassName());
assertEquals("External/" + host + "/AsyncHttpClient/onCompleted", segment.getName());
assertEquals(url, segment.getUri());
assertEquals(1, segment.getCallCount());
}
}
// external request information
Collection<ExternalRequest> externalRequests = introspector.getExternalRequests(txName);
assertEquals(1, externalRequests.size());
ExternalRequest externalRequest = externalRequests.iterator().next();
assertEquals(1, externalRequest.getCount());
assertEquals(host, externalRequest.getHostname());
assertEquals("AsyncHttpClient", externalRequest.getLibrary());
assertEquals("onCompleted", externalRequest.getOperation());
assertEquals(Integer.valueOf(200), externalRequest.getStatusCode());
assertEquals("OK", externalRequest.getStatusText());
// netty?
}
Aggregations