Search in sources :

Example 1 with DefaultTracer

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);
}
Also used : DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) Tracer(com.newrelic.agent.tracers.Tracer) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) OtherRootSqlTracer(com.newrelic.agent.tracers.OtherRootSqlTracer) UltraLightTracer(com.newrelic.agent.tracers.UltraLightTracer) DefaultSqlTracer(com.newrelic.agent.tracers.DefaultSqlTracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) SkipTracer(com.newrelic.agent.tracers.SkipTracer) MetricNameFormat(com.newrelic.agent.tracers.metricname.MetricNameFormat) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer)

Example 2 with DefaultTracer

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;
}
Also used : ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) ExitTracer(com.newrelic.agent.bridge.ExitTracer) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) UltraLightTracer(com.newrelic.agent.tracers.UltraLightTracer) DefaultSqlTracer(com.newrelic.agent.tracers.DefaultSqlTracer) Tracer(com.newrelic.agent.tracers.Tracer) OtherRootSqlTracer(com.newrelic.agent.tracers.OtherRootSqlTracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) MetricNameFormat(com.newrelic.agent.tracers.metricname.MetricNameFormat) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer)

Example 3 with DefaultTracer

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"));
}
Also used : ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)

Example 4 with DefaultTracer

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());
}
Also used : BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) Tracer(com.newrelic.agent.tracers.Tracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) ImmutableMap(com.google.common.collect.ImmutableMap) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) Test(org.junit.Test) SegmentTest(com.newrelic.agent.transaction.SegmentTest)

Example 5 with DefaultTracer

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));
}
Also used : DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) Tracer(com.newrelic.agent.tracers.Tracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) ImmutableMap(com.google.common.collect.ImmutableMap) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) Test(org.junit.Test) SegmentTest(com.newrelic.agent.transaction.SegmentTest)

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