use of com.newrelic.agent.tracers.Tracer 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.Tracer 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.Tracer 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());
}
use of com.newrelic.agent.tracers.Tracer 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.Tracer in project newrelic-java-agent by newrelic.
the class TransactionTest method testCreatePayload.
@Test
public void testCreatePayload() throws Exception {
Map<String, Object> configMap = createConfigMap();
configMap.put(AgentConfigImpl.DISTRIBUTED_TRACING, ImmutableMap.of("enabled", Boolean.TRUE));
createServiceManager(configMap);
Transaction.clearTransaction();
Tracer dispatcherTracer = createDispatcherTracer(true);
Transaction transaction = dispatcherTracer.getTransactionActivity().getTransaction();
transaction.getTransactionActivity().tracerStarted(dispatcherTracer);
String spanId = "honkhonkhonk";
DistributedTracePayloadImpl payload = transaction.createDistributedTracePayload(spanId);
assertNotNull(payload);
dispatcherTracer.finish(Opcodes.ARETURN, null);
assertEquals("App", payload.parentType);
assertEquals(spanId, payload.guid);
// first 10 transactions should be sampled
assertTrue(DistributedTraceUtil.isSampledPriority(payload.priority));
}
Aggregations