use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class RequestUriConfigTests method startTracer.
private DefaultTracer startTracer() throws SQLException {
DummyConnection conn = new DummyConnection();
Statement statement = conn.createStatement();
Transaction tx = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature("com.foo.Statement", "executeQuery", "(Ljava/lang/String;)Ljava/sql/ResultSet;");
DefaultTracer tracer = new OtherRootTracer(tx, sig, statement, new SimpleMetricNameFormat("metric", "segment", "some uri")) {
@Override
public long getDuration() {
return 100000;
}
};
tx.getTransactionActivity().tracerStarted(tracer);
return tracer;
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class CustomTracerFactoryTest method testNoTracerWithParent.
@Test
public void testNoTracerWithParent() {
Transaction transaction = Transaction.getTransaction();
transaction.getTransactionActivity().tracerStarted(new OtherRootTracer(transaction, signature, this, new SimpleMetricNameFormat("test")));
NoTracerMethodTracerFactory mtf = new NoTracerMethodTracerFactory();
CustomTracerFactory factory = new CustomTracerFactory(mtf);
Tracer tracer = factory.getTracer(transaction, signature, this, new Object[0]);
Assert.assertFalse(tracer instanceof TransactionActivityInitiator);
Assert.assertEquals(1, mtf.invocationCount);
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class XWork2ResultPC method doGetTracer.
@Override
public Tracer doGetTracer(Transaction transaction, ClassMethodSignature sig, Object result, Object[] args) {
String name;
try {
Object action;
if (args[0] instanceof ActionInvocation) {
action = ((ActionInvocation) args[0]).getAction();
} else {
action = args[0].getClass().getMethod("getAction").invoke(args[0]);
}
name = action.getClass().getName();
} catch (Throwable t) {
name = "Unknown";
}
return new DefaultTracer(transaction, sig, result, new SimpleMetricNameFormat("StrutsResult/" + name));
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class HandleInternalInvokerPointCut method doGetTracer.
@Override
public Tracer doGetTracer(final Transaction transaction, ClassMethodSignature sig, Object invoker, final Object[] args) {
String methodName = null;
Class<?> controller = null;
StringBuilder tracerName = new StringBuilder("Spring/Java");
// grab the information we need
try {
HandlerMethod methodInfo = (HandlerMethod) args[2];
methodName = methodInfo._nr_getBridgedMethod().getName();
controller = methodInfo._nr_getBean().getClass();
// build the tracer name;
tracerName.append(getControllerName(methodName, controller));
setTransactionName(transaction, methodName, controller);
} catch (Exception e) {
// if it fails use the method name
Agent.LOG.log(Level.FINE, "Unable to pull controller and method from spring framework.");
Agent.LOG.log(Level.FINEST, "Exception grabbing spring controller.", e);
tracerName.append(sig.getMethodName());
}
return new DefaultTracer(transaction, sig, invoker, new SimpleMetricNameFormat(tracerName.toString()));
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class HandlerMethodInvoker3PointCut method doGetTracer.
@Override
public Tracer doGetTracer(final Transaction transaction, ClassMethodSignature sig, Object invoker, final Object[] args) {
StringBuilder tracerName = new StringBuilder("Spring/Java");
String methodName = ((Method) args[0]).getName();
Class<?> controller = args[1].getClass();
// build the tracer name;
tracerName.append(getControllerName(methodName, controller));
return new DefaultTracer(transaction, sig, invoker, new SimpleMetricNameFormat(tracerName.toString()));
}
Aggregations