use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class RequestUriConfigTests method startSqlTracer.
private SqlTracer startSqlTracer(final String sql, final long duration) throws SQLException {
DummyConnection conn = new DummyConnection();
Statement statement = conn.createStatement();
Transaction tx = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature("com.foo.Statement", "executeQuery", "(Ljava/lang/String;)Ljava/sql/ResultSet;");
SqlTracer sqlTracer = new OtherRootSqlTracer(tx, sig, statement, new SimpleMetricNameFormat(null)) {
@Override
public long getDuration() {
return duration;
}
@Override
public Object getSql() {
return sql;
}
};
sqlTracer.setConnectionFactory(new ConnectionFactory() {
@Override
public Connection getConnection() {
return null;
}
@Override
public DatabaseVendor getDatabaseVendor() {
return UnknownDatabaseVendor.INSTANCE;
}
});
sqlTracer.setRawSql(sql);
tx.getTransactionActivity().tracerStarted(sqlTracer);
return sqlTracer;
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class RequestUriConfigTests method startTracer.
private DefaultTracer startTracer() throws SQLException {
DummyConnection conn = new DummyConnection();
Statement statement = conn.createStatement();
Transaction tx = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature("com.foo.Statement", "executeQuery", "(Ljava/lang/String;)Ljava/sql/ResultSet;");
DefaultTracer tracer = new OtherRootTracer(tx, sig, statement, new SimpleMetricNameFormat("metric", "segment", "some uri")) {
@Override
public long getDuration() {
return 100000;
}
};
tx.getTransactionActivity().tracerStarted(tracer);
return tracer;
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class ProfiledMethodFactoryTest method tracers.
@Test
public void tracers() throws IOException {
IProfile profile = Mockito.mock(IProfile.class);
Mockito.when(profile.getStringMap()).thenReturn(StringMap.NO_OP_STRING_MAP);
ProfiledMethodFactory factory = new ProfiledMethodFactory(profile);
factory.getProfiledMethod(getTracer(new ClassMethodSignature("Foo", "bar", "(Ljava/lang/String;)V")));
ByteArrayOutputStream out = new ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(out);
JSONObject.writeJSONString(factory.getMethods(), writer);
writer.close();
Assert.assertEquals("{\"0\":[\"Foo\",\"bar\",-1,[{\"args\":[\"java.lang.String\"]}]]}", out.toString());
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class MessagingUtilTest method createDispatcherTracer.
// Create a Tracer for tests that require one.
private BasicRequestRootTracer createDispatcherTracer() {
Transaction tx = Transaction.getTransaction();
tx.setApplicationName(ApplicationNamePriority.REQUEST_ATTRIBUTE, APP_NAME);
MockHttpRequest httpRequest = new MockHttpRequest();
MockHttpResponse httpResponse = new MockHttpResponse();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
return new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class JsonTracer method generateRootBackgroundTracer.
private DefaultTracer generateRootBackgroundTracer(Long initTime) {
long time = getStartTime(initTime);
ClassMethodSignature sig = new ClassMethodSignature("clazz", tracerName, "()");
Object reference = new Object();
int flags = TracerFlags.DISPATCHER;
if (startTimeNs != 0) {
flags = TracerFlags.ASYNC;
}
DefaultTracer tracer = new OtherRootTracer(Transaction.getTransaction().getTransactionActivity(), sig, reference, new ClassMethodMetricNameFormat(sig, reference), flags, time);
Transaction.getTransaction().getTransactionActivity().tracerStarted(tracer);
return tracer;
}
Aggregations