Search in sources :

Example 21 with DefaultTracer

use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.

the class CXFInvokerPointCut method doGetTracer.

@Override
public Tracer doGetTracer(Transaction transaction, ClassMethodSignature sig, Object invoker, Object[] args) {
    Object service = args[1];
    Method method = (Method) args[2];
    String address = (String) transaction.getInternalParameters().remove(CXFPointCut.CXF_ENDPOINT_ADDRESS_PARAMETER_NAME);
    if (address != null) {
        StringBuilder path = new StringBuilder(address);
        if (!address.endsWith("/")) {
            path.append('/');
        }
        path.append(method.getName());
        setTransactionName(transaction, getCXFRequestUri(address, method));
    } else {
        Agent.LOG.log(Level.FINEST, "The CXF endpoint address is null.");
        String txnName = buildCXFTransactionName(service.getClass().getName(), method.getName());
        setTransactionName(transaction, txnName);
    }
    return new DefaultTracer(transaction, sig, invoker, new SimpleMetricNameFormat(Strings.join('/', MetricNames.JAVA, service.getClass().getName(), method.getName())));
}
Also used : DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) Method(java.lang.reflect.Method) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)

Example 22 with DefaultTracer

use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.

the class CXFPointCut method doGetTracer.

@Override
public Tracer doGetTracer(Transaction transaction, ClassMethodSignature sig, final Object servletDest, Object[] args) {
    try {
        Object endpointInfo = servletDest.getClass().getMethod("getEndpointInfo").invoke(servletDest);
        Object address = endpointInfo.getClass().getMethod("getAddress").invoke(endpointInfo);
        transaction.getInternalParameters().put(CXF_ENDPOINT_ADDRESS_PARAMETER_NAME, address);
    } catch (Throwable t) {
        Agent.LOG.log(Level.FINER, "Error parsing CXF transaction", t);
    }
    return new DefaultTracer(transaction, sig, servletDest, new ClassMethodMetricNameFormat(sig, servletDest));
}
Also used : ClassMethodMetricNameFormat(com.newrelic.agent.tracers.metricname.ClassMethodMetricNameFormat) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer)

Example 23 with DefaultTracer

use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.

the class TransactionTimesTest method createDefaultTraer.

private DefaultTracer createDefaultTraer(String methodName) {
    Transaction tx = Transaction.getTransaction();
    ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), methodName, "()V");
    return new DefaultTracer(tx, sig, this);
}
Also used : Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer)

Example 24 with DefaultTracer

use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.

the class TransactionTimesTest method testTransactionTimes.

@Test
public void testTransactionTimes() throws InterruptedException {
    Transaction tx = Transaction.getTransaction();
    OtherRootTracer root = createDispatcherTracer();
    tx.getTransactionActivity().tracerStarted(root);
    DefaultTracer tracer1 = createDefaultTraer("hello1");
    tx.getTransactionActivity().tracerStarted(tracer1);
    DefaultTracer tracer2 = createDefaultTraer("hello2");
    tx.getTransactionActivity().tracerStarted(tracer2);
    Thread.sleep(10);
    tracer2.finish(0, null);
    tracer1.finish(0, null);
    root.finish(0, null);
    Assert.assertNotNull(stats);
    SimpleStatsEngine unscoped = stats.getUnscopedStats();
    Assert.assertNotNull(unscoped.getOrCreateResponseTimeStats("OtherTransaction/all"));
    Assert.assertNotNull(unscoped.getOrCreateResponseTimeStats("OtherTransactionTotalTime/all"));
    Assert.assertNotNull(unscoped.getOrCreateResponseTimeStats("OtherTransaction/myMetricName"));
    Assert.assertNotNull(unscoped.getOrCreateResponseTimeStats("OtherTransactionTotalTime/myMetricName"));
    Assert.assertEquals(1, unscoped.getOrCreateResponseTimeStats("OtherTransaction/all").getCallCount());
    Assert.assertEquals(1, unscoped.getOrCreateResponseTimeStats("OtherTransactionTotalTime").getCallCount());
    Assert.assertEquals(1, unscoped.getOrCreateResponseTimeStats("OtherTransaction/myMetricName").getCallCount());
    Assert.assertEquals(1, unscoped.getOrCreateResponseTimeStats("OtherTransactionTotalTime/myMetricName").getCallCount());
    SimpleStatsEngine scoped = stats.getScopedStats();
    Assert.assertNotNull(scoped.getOrCreateResponseTimeStats("Java/com.newrelic.agent.transaction.TransactionTimesTest/dude"));
    Assert.assertEquals(1, scoped.getOrCreateResponseTimeStats("Java/com.newrelic.agent.transaction.TransactionTimesTest/dude").getCallCount());
    Assert.assertEquals(root.getDuration(), tx.getTransactionTimer().getTotalSumTimeInNanos());
    Assert.assertEquals(root.getDuration(), tx.getTransactionTimer().getResponseTimeInNanos());
    Assert.assertEquals(1, tx.getFinishedChildren().size());
}
Also used : Transaction(com.newrelic.agent.Transaction) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) SimpleStatsEngine(com.newrelic.agent.stats.SimpleStatsEngine) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) Test(org.junit.Test)

Example 25 with DefaultTracer

use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.

the class IntrospectorImplTest method createDefaultTracer.

// Create a Tracer for tests that require one.
public static DefaultTracer createDefaultTracer(String methodName) {
    Transaction tx = Transaction.getTransaction();
    ClassMethodSignature sig = new ClassMethodSignature("MyClass", methodName, "()V");
    DefaultTracer brrt = new DefaultTracer(tx, sig, new Object(), new SimpleMetricNameFormat("Custom/" + methodName));
    return brrt;
}
Also used : Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)

Aggregations

DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)46 ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)24 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)20 SimpleMetricNameFormat (com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)19 Transaction (com.newrelic.agent.Transaction)17 Tracer (com.newrelic.agent.tracers.Tracer)16 Test (org.junit.Test)14 TransactionData (com.newrelic.agent.TransactionData)6 ClassMethodMetricNameFormat (com.newrelic.agent.tracers.metricname.ClassMethodMetricNameFormat)6 MetricNameFormat (com.newrelic.agent.tracers.metricname.MetricNameFormat)6 SqlTraceConfig (com.newrelic.agent.config.SqlTraceConfig)5 OtherRootSqlTracer (com.newrelic.agent.tracers.OtherRootSqlTracer)5 JSONObject (org.json.simple.JSONObject)5 MockDispatcher (com.newrelic.agent.MockDispatcher)4 DefaultSqlTracer (com.newrelic.agent.tracers.DefaultSqlTracer)4 UltraLightTracer (com.newrelic.agent.tracers.UltraLightTracer)4 HashMap (java.util.HashMap)4 TransactionActivity (com.newrelic.agent.TransactionActivity)3 ExitTracer (com.newrelic.agent.bridge.ExitTracer)3 ServerProp (com.newrelic.agent.config.ServerProp)3