use of com.newrelic.agent.tracers.TracerFactory in project newrelic-java-agent by newrelic.
the class TransactionStateImplTest method tracerMetricName_NullCustom.
@Test
public void tracerMetricName_NullCustom() throws Exception {
Tracer rootTracer = createRootTracer();
Transaction tx = Transaction.getTransaction();
TracerFactory tracerFactory = Mockito.mock(TracerFactory.class, new Returns(rootTracer));
tx.getTransactionState().getTracer(tx, tracerFactory, new ClassMethodSignature("com.newrelic.test.Foo", "makeItSo", "()"), null, (Object[]) null);
assertEquals(rootTracer, tx.getTransactionActivity().getRootTracer());
ClassMethodSignature sig = new ClassMethodSignature("com.test.Dude", "dude2", "()V");
Tracer tracer = tx.getTransactionState().getTracer(tx, null, sig, null, getTracerFlags(false, false, true));
assertEquals(tracer, tx.getTransactionActivity().getLastTracer());
assertEquals("Custom/com.test.Dude/dude2", tracer.getMetricName());
}
use of com.newrelic.agent.tracers.TracerFactory in project newrelic-java-agent by newrelic.
the class TransactionStateImplTest method finish.
@Test
public void finish() 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);
Assert.assertTrue(tx.getTransactionState().finish(tx, rootTracer));
}
use of com.newrelic.agent.tracers.TracerFactory in project newrelic-java-agent by newrelic.
the class TransactionStateImplTest method getTracer.
@Test
public void getTracer() 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());
Tracer tracer = createTracer();
tracerFactory = Mockito.mock(TracerFactory.class, new Returns(tracer));
tx.getTransactionState().getTracer(tx, tracerFactory, null, null, (Object[]) null);
assertEquals(tracer, tx.getTransactionActivity().getLastTracer());
}
use of com.newrelic.agent.tracers.TracerFactory in project newrelic-java-agent by newrelic.
the class TransactionStateImplTest method tracerGeneration_segmentClampInPlace.
@Test
public void tracerGeneration_segmentClampInPlace() throws Exception {
Tracer rootTracer = createRootTracer();
Transaction tx = Transaction.getTransaction();
TransactionCounts transactionCounts = tx.getTransactionCounts();
transactionCounts.addTracers(3001);
TracerFactory tracerFactory = Mockito.mock(TracerFactory.class, new Returns(rootTracer));
ClassMethodSignature sig = new ClassMethodSignature("com.test.Dude", "dude1", "()V");
tx.getTransactionState().getTracer(tx, tracerFactory, sig, null, (Object[]) null);
Assert.assertNotNull(tx.getTransactionActivity().getRootTracer());
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 YmlExtensionPointCutConverter method getTracerFactoryName.
private static String getTracerFactoryName(Map attrs, String prefix, boolean dispatcher, Object metricNameFormat, ClassLoader loader) {
String tracerFactoryNameString = null;
Object tracerFactoryName = attrs.get(TRACER_FACTOR_KEY);
if (tracerFactoryName != null) {
try {
TracerFactory factory = getTracerFactory(tracerFactoryName.toString(), loader, new TracerFactoryConfiguration(prefix, dispatcher, metricNameFormat, attrs));
tracerFactoryNameString = tracerFactoryName.toString();
ServiceFactory.getTracerService().registerTracerFactory(tracerFactoryNameString, factory);
} catch (TracerFactoryException ex) {
throw new RuntimeException("Unable to create tracer factory " + tracerFactoryName, ex);
}
}
return tracerFactoryNameString;
}
Aggregations