use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.
the class TransactionStateImpl method getTracer.
/**
* Get tracer for weaved code and XML instrumentation (no tracer factory)
*/
@Override
public Tracer getTracer(Transaction tx, final Object invocationTarget, final ClassMethodSignature sig, final String metricName, final int flags) {
TransactionActivity activity = tx.getTransactionActivity();
if (tx.isIgnore() || activity.isTracerStartLocked()) {
return null;
}
Tracer tracer;
final MetricNameFormat mnf = MetricNameFormats.getFormatter(invocationTarget, sig, metricName, flags);
if (TracerFlags.isDispatcher(flags)) {
tracer = new OtherRootTracer(tx, sig, invocationTarget, mnf);
} else {
tracer = new DefaultTracer(tx, sig, invocationTarget, mnf, flags);
}
return tracerStarted(tx, sig, tracer);
}
use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.
the class InstrumentationImpl method startTracer.
// Preconditions are met: start a new tracer on this thread. There may not be a Transaction on this thread. Code
// in this path MUST NOT attempt to touch the Transaction or do anything that might bring one into existence. This
// inconvenience is absolutely critical to the performance of our async instrumentation.
private Tracer startTracer(TransactionActivity txa, Object target, int signatureId, String metricName, int flags) {
ClassMethodSignature sig = ClassMethodSignatures.get().get(signatureId);
MetricNameFormat mnf = MetricNameFormats.getFormatter(target, sig, metricName, flags);
Tracer tracer;
if (TracerFlags.isRoot(flags)) {
// Dispatcher || Async
tracer = new OtherRootTracer(txa, sig, target, mnf, flags, System.nanoTime());
} else {
tracer = new DefaultTracer(txa, sig, target, mnf, flags);
}
txa.tracerStarted(tracer);
return tracer;
}
use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.
the class TransactionStateImplTest method createTracer.
private Tracer createTracer() throws Exception {
Transaction tx = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
return new DefaultTracer(tx, sig, this, new SimpleMetricNameFormat("test"));
}
use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.
the class TransactionTest method testTracerLimit1.
@SuppressWarnings("unchecked")
@Test
public void testTracerLimit1() throws Exception {
Map<String, Object> config = createConfigMap();
Map<String, Object> ttmap = (Map) config.get(AgentConfigImpl.TRANSACTION_TRACER);
ttmap.put("segment_limit", 3);
createServiceManager(config);
Transaction.clearTransaction();
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer rootTracer = (BasicRequestRootTracer) createDispatcherTracer(true);
tx.getTransactionActivity().tracerStarted(rootTracer);
DefaultTracer t1 = createBasicTracer("one");
tx.getTransactionActivity().tracerStarted(t1);
DefaultTracer t2 = createBasicTracer("two");
tx.getTransactionActivity().tracerStarted(t2);
DefaultTracer t3 = createBasicTracer("three");
tx.getTransactionActivity().tracerStarted(t3);
DefaultTracer t4 = createBasicTracer("four");
tx.getTransactionActivity().tracerStarted(t4);
DefaultTracer t5 = createBasicTracer("five");
tx.getTransactionActivity().tracerStarted(t5);
tx.getTransactionActivity().tracerFinished(t5, 0);
tx.getTransactionActivity().tracerFinished(t4, 0);
tx.getTransactionActivity().tracerFinished(t3, 0);
tx.getTransactionActivity().tracerFinished(t2, 0);
tx.getTransactionActivity().tracerFinished(t1, 0);
finishTransaction(tx, rootTracer);
Set<TransactionActivity> done = tx.getFinishedChildren();
assertEquals(1, done.size());
TransactionActivity txa = done.iterator().next();
List<Tracer> tracers = txa.getTracers();
assertEquals(3, tracers.size());
assertTrue(tracers.contains(t1));
assertTrue(tracers.contains(t2));
assertTrue(tracers.contains(t3));
// Verify that we send up the segment_clamp supportability metric
TransactionStats stats = txa.getTransactionStats();
assertNotNull(stats);
StatsImpl segmentClamp = (StatsImpl) stats.getUnscopedStats().getStatsMap().get(MetricNames.SUPPORTABILITY_TRANSACTION_SEGMENT_CLAMP);
assertNotNull(segmentClamp);
// The limit is 3 so the clamp will take effect at 4
assertEquals(4, (int) segmentClamp.getTotal());
// Should get incremented once for the tx
assertEquals(1, segmentClamp.getCallCount());
}
use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.
the class TransactionTest method testTracerLimit2.
@SuppressWarnings("unchecked")
@Test
public void testTracerLimit2() throws Exception {
Map<String, Object> config = createConfigMap();
Map<String, Object> ttmap = (Map) config.get(AgentConfigImpl.TRANSACTION_TRACER);
ttmap.put("segment_limit", 3);
createServiceManager(config);
Transaction.clearTransaction();
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer rootTracer = (BasicRequestRootTracer) createDispatcherTracer(true);
tx.getTransactionActivity().tracerStarted(rootTracer);
DefaultTracer t1 = createBasicTracer("one");
tx.getTransactionActivity().tracerStarted(t1);
tx.getTransactionActivity().tracerFinished(t1, 0);
DefaultTracer t2 = createBasicTracer("two");
tx.getTransactionActivity().tracerStarted(t2);
tx.getTransactionActivity().tracerFinished(t2, 0);
DefaultTracer t3 = createBasicTracer("three");
tx.getTransactionActivity().tracerStarted(t3);
tx.getTransactionActivity().tracerFinished(t3, 0);
DefaultTracer t4 = createBasicTracer("four");
tx.getTransactionActivity().tracerStarted(t4);
tx.getTransactionActivity().tracerFinished(t4, 0);
DefaultTracer t5 = createBasicTracer("five");
tx.getTransactionActivity().tracerStarted(t5);
tx.getTransactionActivity().tracerFinished(t5, 0);
finishTransaction(tx, rootTracer);
Set<TransactionActivity> done = tx.getFinishedChildren();
assertEquals(1, done.size());
TransactionActivity txa = done.iterator().next();
List<Tracer> tracers = txa.getTracers();
assertEquals(3, tracers.size());
assertTrue(tracers.contains(t1));
assertTrue(tracers.contains(t2));
assertTrue(tracers.contains(t3));
}
Aggregations