use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.
the class CXFInvokerPointCut method doGetTracer.
@Override
public Tracer doGetTracer(Transaction transaction, ClassMethodSignature sig, Object invoker, Object[] args) {
Object service = args[1];
Method method = (Method) args[2];
String address = (String) transaction.getInternalParameters().remove(CXFPointCut.CXF_ENDPOINT_ADDRESS_PARAMETER_NAME);
if (address != null) {
StringBuilder path = new StringBuilder(address);
if (!address.endsWith("/")) {
path.append('/');
}
path.append(method.getName());
setTransactionName(transaction, getCXFRequestUri(address, method));
} else {
Agent.LOG.log(Level.FINEST, "The CXF endpoint address is null.");
String txnName = buildCXFTransactionName(service.getClass().getName(), method.getName());
setTransactionName(transaction, txnName);
}
return new DefaultTracer(transaction, sig, invoker, new SimpleMetricNameFormat(Strings.join('/', MetricNames.JAVA, service.getClass().getName(), method.getName())));
}
use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.
the class CXFPointCut method doGetTracer.
@Override
public Tracer doGetTracer(Transaction transaction, ClassMethodSignature sig, final Object servletDest, Object[] args) {
try {
Object endpointInfo = servletDest.getClass().getMethod("getEndpointInfo").invoke(servletDest);
Object address = endpointInfo.getClass().getMethod("getAddress").invoke(endpointInfo);
transaction.getInternalParameters().put(CXF_ENDPOINT_ADDRESS_PARAMETER_NAME, address);
} catch (Throwable t) {
Agent.LOG.log(Level.FINER, "Error parsing CXF transaction", t);
}
return new DefaultTracer(transaction, sig, servletDest, new ClassMethodMetricNameFormat(sig, servletDest));
}
use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.
the class TransactionTimesTest method createDefaultTraer.
private DefaultTracer createDefaultTraer(String methodName) {
Transaction tx = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), methodName, "()V");
return new DefaultTracer(tx, sig, this);
}
use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.
the class TransactionTimesTest method testTransactionTimes.
@Test
public void testTransactionTimes() throws InterruptedException {
Transaction tx = Transaction.getTransaction();
OtherRootTracer root = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(root);
DefaultTracer tracer1 = createDefaultTraer("hello1");
tx.getTransactionActivity().tracerStarted(tracer1);
DefaultTracer tracer2 = createDefaultTraer("hello2");
tx.getTransactionActivity().tracerStarted(tracer2);
Thread.sleep(10);
tracer2.finish(0, null);
tracer1.finish(0, null);
root.finish(0, null);
Assert.assertNotNull(stats);
SimpleStatsEngine unscoped = stats.getUnscopedStats();
Assert.assertNotNull(unscoped.getOrCreateResponseTimeStats("OtherTransaction/all"));
Assert.assertNotNull(unscoped.getOrCreateResponseTimeStats("OtherTransactionTotalTime/all"));
Assert.assertNotNull(unscoped.getOrCreateResponseTimeStats("OtherTransaction/myMetricName"));
Assert.assertNotNull(unscoped.getOrCreateResponseTimeStats("OtherTransactionTotalTime/myMetricName"));
Assert.assertEquals(1, unscoped.getOrCreateResponseTimeStats("OtherTransaction/all").getCallCount());
Assert.assertEquals(1, unscoped.getOrCreateResponseTimeStats("OtherTransactionTotalTime").getCallCount());
Assert.assertEquals(1, unscoped.getOrCreateResponseTimeStats("OtherTransaction/myMetricName").getCallCount());
Assert.assertEquals(1, unscoped.getOrCreateResponseTimeStats("OtherTransactionTotalTime/myMetricName").getCallCount());
SimpleStatsEngine scoped = stats.getScopedStats();
Assert.assertNotNull(scoped.getOrCreateResponseTimeStats("Java/com.newrelic.agent.transaction.TransactionTimesTest/dude"));
Assert.assertEquals(1, scoped.getOrCreateResponseTimeStats("Java/com.newrelic.agent.transaction.TransactionTimesTest/dude").getCallCount());
Assert.assertEquals(root.getDuration(), tx.getTransactionTimer().getTotalSumTimeInNanos());
Assert.assertEquals(root.getDuration(), tx.getTransactionTimer().getResponseTimeInNanos());
Assert.assertEquals(1, tx.getFinishedChildren().size());
}
use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.
the class IntrospectorImplTest method createDefaultTracer.
// Create a Tracer for tests that require one.
public static DefaultTracer createDefaultTracer(String methodName) {
Transaction tx = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature("MyClass", methodName, "()V");
DefaultTracer brrt = new DefaultTracer(tx, sig, new Object(), new SimpleMetricNameFormat("Custom/" + methodName));
return brrt;
}
Aggregations