Search in sources :

Example 1 with WrappedFunction0

use of com.nr.agent.instrumentation.scala.WrappedFunction0 in project newrelic-java-agent by newrelic.

the class FutureInnerClass_Instrumentation method apply.

public <T> scala.concurrent.Future<T> apply(Function0<T> body, final ExecutionContext executor) {
    AgentBridge.TokenAndRefCount tokenAndRefCount = AgentBridge.activeToken.get();
    if (tokenAndRefCount == null) {
        Transaction tx = AgentBridge.getAgent().getTransaction(false);
        if (tx != null && (!body.getClass().getName().startsWith("akka."))) {
            AgentBridge.TokenAndRefCount tokenAndRef = new AgentBridge.TokenAndRefCount(tx.getToken(), AgentBridge.getAgent().getTracedMethod(), new AtomicInteger(1));
            body = new WrappedFunction0(body, tokenAndRef);
        }
    } else {
        body = new WrappedFunction0(body, tokenAndRefCount);
        tokenAndRefCount.refCount.incrementAndGet();
    }
    scala.concurrent.Future<T> value = Weaver.callOriginal();
    return value;
}
Also used : Transaction(com.newrelic.agent.bridge.Transaction) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AgentBridge(com.newrelic.agent.bridge.AgentBridge) WrappedFunction0(com.nr.agent.instrumentation.scala.WrappedFunction0)

Aggregations

AgentBridge (com.newrelic.agent.bridge.AgentBridge)1 Transaction (com.newrelic.agent.bridge.Transaction)1 WrappedFunction0 (com.nr.agent.instrumentation.scala.WrappedFunction0)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1