use of com.newrelic.agent.bridge.TracedMethod in project newrelic-java-agent by newrelic.
the class FlyweightTraceMethodVisitor method onEveryExit.
/**
* This code is injected at every exit instruction, whether a return or an ATHROW.
*
* @see Transaction#finishFlyweightTracer(TracedMethod, long, long, String, String, String, String, String[])
*/
private void onEveryExit() {
Label skip = super.newLabel();
super.loadLocal(parentTracerLocal);
super.ifNull(skip);
BridgeUtils.getCurrentTransactionOrNull(this);
super.ifNull(skip);
BridgeUtils.getCurrentTransaction(this);
BytecodeGenProxyBuilder<Transaction> builder = BytecodeGenProxyBuilder.newBuilder(Transaction.class, this, true);
Variables loader = builder.getVariables();
String[] rollupMetricNames;
if (rollupMetricNamesCacheId >= 0) {
rollupMetricNames = loader.load(String[].class, new Runnable() {
@Override
public void run() {
getStatic(BridgeUtils.AGENT_BRIDGE_TYPE, BridgeUtils.INSTRUMENTATION_FIELD_NAME, BridgeUtils.INSTRUMENTATION_TYPE);
BytecodeGenProxyBuilder.newBuilder(Instrumentation.class, FlyweightTraceMethodVisitor.this, true).build().getCachedObject(rollupMetricNamesCacheId);
checkCast(Type.getType(String[].class));
}
});
} else {
rollupMetricNames = null;
}
// -1 and -2 are identifiers that tell the ApiBuilder's proxy to (-1) load a local variable and (-2) call
// System.nanoTime when those values are
// encountered
long startTime = loader.loadLocal(startTimeLocal, Type.LONG_TYPE, -1L);
long loadEndTime = loader.load(-2l, new Runnable() {
@Override
public void run() {
invokeStatic(Type.getType(System.class), new Method("nanoTime", Type.LONG_TYPE, new Type[0]));
}
});
Transaction transactionApi = builder.build();
transactionApi.finishFlyweightTracer(loader.loadLocal(parentTracerLocal, TracedMethod.class), startTime, loadEndTime, className, this.method.getName(), this.methodDesc, loader.loadLocal(metricNameLocal, String.class), rollupMetricNames);
super.visitLabel(skip);
}
Aggregations