use of com.newrelic.agent.tracers.TracerFactory in project newrelic-java-agent by newrelic.
the class AgentWrapper method invoke.
/**
* @see ReflectionStyleClassMethodAdapter
*/
public static ExitTracer invoke(PointCutInvocationHandler invocationHandler, String className, String methodName, String methodDesc, Object invocationTarget, Object[] args) {
ClassMethodSignature classMethodSig = new ClassMethodSignature(className, methodName, methodDesc);
if (invocationHandler instanceof EntryInvocationHandler) {
EntryInvocationHandler handler = (EntryInvocationHandler) invocationHandler;
handler.handleInvocation(classMethodSig, invocationTarget, args);
return null;
} else if (invocationHandler instanceof TracerFactory) {
return ServiceFactory.getTracerService().getTracer((TracerFactory) invocationHandler, classMethodSig, invocationTarget, args);
}
return null;
}
use of com.newrelic.agent.tracers.TracerFactory in project newrelic-java-agent by newrelic.
the class TransactionStateImplTest method tracerGeneration_segmentClampInPlace_afterRoot.
@Test
public void tracerGeneration_segmentClampInPlace_afterRoot() throws Exception {
Tracer rootTracer = createRootTracer();
Transaction tx = Transaction.getTransaction();
TransactionCounts transactionCounts = tx.getTransactionCounts();
TracerFactory tracerFactory = Mockito.mock(TracerFactory.class, new Returns(rootTracer));
tx.getTransactionState().getTracer(tx, tracerFactory, null, null, (Object[]) null);
assertEquals(rootTracer, tx.getTransactionActivity().getRootTracer());
transactionCounts.addTracers(3001);
ClassMethodSignature sig = new ClassMethodSignature("com.test.Dude", "dude1", "()V");
Tracer tracer = tx.getTransactionState().getTracer(tx, null, sig, null, simpleFlags);
assertNotEquals(UltraLightTracer.class, tracer.getClass());
assertEquals("Java/com.test.Dude/dude1", tracer.getTransactionSegmentName());
Tracer sqlTracer = tx.getTransactionState().getSqlTracer(tx, null, sig, null, simpleFlags);
assertEquals(UltraLightTracer.class, sqlTracer.getClass());
assertEquals("Clamped/com.test.Dude/dude1", sqlTracer.getTransactionSegmentName());
}
use of com.newrelic.agent.tracers.TracerFactory in project newrelic-java-agent by newrelic.
the class TransactionStateImplTest method tracerMetricName_Null.
@Test
public void tracerMetricName_Null() throws Exception {
Tracer rootTracer = createRootTracer();
Transaction tx = Transaction.getTransaction();
TracerFactory tracerFactory = Mockito.mock(TracerFactory.class, new Returns(rootTracer));
tx.getTransactionState().getTracer(tx, tracerFactory, null, null, (Object[]) null);
assertEquals(rootTracer, tx.getTransactionActivity().getRootTracer());
ClassMethodSignature sig = new ClassMethodSignature("com.test.Dude", "dude1", "()V");
Tracer tracer = tx.getTransactionState().getTracer(tx, null, sig, null, simpleFlags);
assertEquals(tracer, tx.getTransactionActivity().getLastTracer());
assertEquals("Java/com.test.Dude/dude1", tracer.getMetricName());
}
use of com.newrelic.agent.tracers.TracerFactory in project newrelic-java-agent by newrelic.
the class TransactionStateImplTest method tracerMetricName.
@Test
public void tracerMetricName() throws Exception {
Tracer rootTracer = createRootTracer();
Transaction tx = Transaction.getTransaction();
TracerFactory tracerFactory = Mockito.mock(TracerFactory.class, new Returns(rootTracer));
tx.getTransactionState().getTracer(tx, tracerFactory, null, null, (Object[]) null);
assertEquals(rootTracer, tx.getTransactionActivity().getRootTracer());
ClassMethodSignature sig = new ClassMethodSignature("com.test.Dude", "dude4", "()V");
Tracer tracer = tx.getTransactionState().getTracer(tx, new Object(), sig, "Test/${className}/dude4", TracerFlags.CUSTOM);
assertEquals(tracer, tx.getTransactionActivity().getLastTracer());
assertEquals("Test/java.lang.Object/dude4", tracer.getMetricName());
}
use of com.newrelic.agent.tracers.TracerFactory in project newrelic-java-agent by newrelic.
the class TransactionStateImplTest method tracerMetricName_NullInvocationTarget.
@Test
public void tracerMetricName_NullInvocationTarget() throws Exception {
Tracer rootTracer = createRootTracer();
Transaction tx = Transaction.getTransaction();
TracerFactory tracerFactory = Mockito.mock(TracerFactory.class, new Returns(rootTracer));
tx.getTransactionState().getTracer(tx, tracerFactory, null, null, (Object[]) null);
assertEquals(rootTracer, tx.getTransactionActivity().getRootTracer());
ClassMethodSignature sig = new ClassMethodSignature("com.test.Dude", "dude3", "()V");
Tracer tracer = tx.getTransactionState().getTracer(tx, null, sig, "Test/${className}/dude3", getTracerFlags(false, false, true));
assertEquals(tracer, tx.getTransactionActivity().getLastTracer());
assertEquals("Test/com.test.Dude/dude3", tracer.getMetricName());
}
Aggregations