Search in sources :

Example 81 with ClassMethodSignature

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;
}
Also used : ConnectionFactory(com.newrelic.agent.bridge.datastore.ConnectionFactory) DatabaseVendor(com.newrelic.agent.bridge.datastore.DatabaseVendor) UnknownDatabaseVendor(com.newrelic.agent.bridge.datastore.UnknownDatabaseVendor) Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) Statement(java.sql.Statement) DummyConnection(sql.DummyConnection) Connection(java.sql.Connection) DummyConnection(sql.DummyConnection) SqlTracer(com.newrelic.agent.tracers.SqlTracer) OtherRootSqlTracer(com.newrelic.agent.tracers.OtherRootSqlTracer) OtherRootSqlTracer(com.newrelic.agent.tracers.OtherRootSqlTracer) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)

Example 82 with ClassMethodSignature

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;
}
Also used : Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) Statement(java.sql.Statement) DummyConnection(sql.DummyConnection) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer)

Example 83 with ClassMethodSignature

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());
}
Also used : ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 84 with ClassMethodSignature

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);
}
Also used : MockHttpRequest(com.newrelic.agent.tracers.servlet.MockHttpRequest) Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) MockHttpResponse(com.newrelic.agent.tracers.servlet.MockHttpResponse)

Example 85 with ClassMethodSignature

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;
}
Also used : ClassMethodMetricNameFormat(com.newrelic.agent.tracers.metricname.ClassMethodMetricNameFormat) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) JSONObject(org.json.simple.JSONObject) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer)

Aggregations

ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)112 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)69 Transaction (com.newrelic.agent.Transaction)60 Test (org.junit.Test)55 SimpleMetricNameFormat (com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)46 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)44 Tracer (com.newrelic.agent.tracers.Tracer)41 MockHttpResponse (com.newrelic.agent.tracers.servlet.MockHttpResponse)26 MockHttpRequest (com.newrelic.agent.tracers.servlet.MockHttpRequest)23 BasicRequestRootTracer (com.newrelic.agent.tracers.servlet.BasicRequestRootTracer)20 BrowserConfigTest (com.newrelic.agent.browser.BrowserConfigTest)17 HashMap (java.util.HashMap)17 TransactionData (com.newrelic.agent.TransactionData)16 JSONObject (org.json.simple.JSONObject)15 MetricNameFormat (com.newrelic.agent.tracers.metricname.MetricNameFormat)13 UltraLightTracer (com.newrelic.agent.tracers.UltraLightTracer)12 JSONArray (org.json.simple.JSONArray)11 MethodExitTracer (com.newrelic.agent.tracers.MethodExitTracer)10 Response (com.newrelic.api.agent.Response)10 TransactionDataTestBuilder (com.newrelic.agent.TransactionDataTestBuilder)9