Search in sources :

Example 26 with Transaction

use of com.newrelic.agent.bridge.Transaction in project newrelic-java-agent by newrelic.

the class MuleUtils method reportToAgent.

/**
 * Called outbound when using Http Transport. Verify this is consistent with usages of MuleHttpConnectorResponse in
 * the mule-3.6 and mule-3.7 modules.
 */
public static void reportToAgent(final HttpResponse response) {
    if (response == null) {
        NewRelic.getAgent().getLogger().log(Level.FINE, "MuleUtils#reportToAgent httpResponse is null");
        return;
    }
    final MuleHttpTransportResponse muleResponse = new MuleHttpTransportResponse(response);
    NewRelic.getAgent().getTracedMethod().addOutboundRequestHeaders(muleResponse);
    final Transaction txn = AgentBridge.getAgent().getTransaction(false);
    if (txn != null) {
        txn.setWebResponse(muleResponse);
        txn.getCrossProcessState().processOutboundResponseHeaders(muleResponse, getContentLength(muleResponse));
    }
}
Also used : Transaction(com.newrelic.agent.bridge.Transaction)

Example 27 with Transaction

use of com.newrelic.agent.bridge.Transaction in project newrelic-java-agent by newrelic.

the class HttpRequestToMuleEvent_Instrumentation method transform.

/**
 * Verify the method body produces the same URI information as in module-3.7.
 */
@Trace
public static MuleEvent transform(final HttpRequestContext requestContext, final MuleContext muleContext, final FlowConstruct flowConstruct, Boolean parseRequest, String listenerPath) {
    MuleEvent event = Weaver.callOriginal();
    final MuleHttpConnectorRequest muleRequest = new MuleHttpConnectorRequest(event, requestContext);
    URI uri = resolveUriForNR(requestContext);
    NewRelic.getAgent().getTracedMethod().reportAsExternal(HttpParameters.library("MuleHTTP").uri(uri).procedure("writeResponse").inboundHeaders(muleRequest).build());
    final Transaction txn = AgentBridge.getAgent().getTransaction(false);
    txn.setWebRequest(muleRequest);
    final String txnName = event.getMessage().getInboundProperty("http.listener.path") + " (" + muleRequest.getMethod() + ")";
    txn.setTransactionName(TransactionNamePriority.FRAMEWORK_HIGH, true, "Mule/Connector", txnName);
    return event;
}
Also used : Transaction(com.newrelic.agent.bridge.Transaction) MuleEvent(org.mule.api.MuleEvent) MuleHttpConnectorRequest(com.nr.agent.instrumentation.mule3.MuleHttpConnectorRequest) URI(java.net.URI) Trace(com.newrelic.api.agent.Trace)

Example 28 with Transaction

use of com.newrelic.agent.bridge.Transaction in project newrelic-java-agent by newrelic.

the class AbstractMessageReceiver_Implementation method processMessage.

@Trace(dispatcher = true)
protected void processMessage(final MessageProcessTemplate messageProcessTemplate, final MessageProcessContext messageProcessContext) {
    MessageSource messageSource = messageProcessContext.getMessageSource();
    if (messageSource instanceof DefaultInboundEndpoint) {
        DefaultInboundEndpoint endpoint = (DefaultInboundEndpoint) messageSource;
        final Transaction txn = AgentBridge.getAgent().getTransaction();
        // we only set transaction state on the outer-most one.
        if (((com.newrelic.agent.bridge.TracedMethod) txn.getTracedMethod()).getParentTracedMethod() == null) {
            final String protocol = endpoint.getConnector().getProtocol().toUpperCase();
            final String path = endpoint.getEndpointURI().getPath();
            final String txnName = protocol + path;
            txn.setTransactionName(TransactionNamePriority.FRAMEWORK_LOW, false, "Mule", txnName);
        }
    }
    Weaver.callOriginal();
}
Also used : Transaction(com.newrelic.agent.bridge.Transaction) DefaultInboundEndpoint(org.mule.endpoint.DefaultInboundEndpoint) MessageSource(org.mule.api.source.MessageSource) Trace(com.newrelic.api.agent.Trace)

Example 29 with Transaction

use of com.newrelic.agent.bridge.Transaction in project newrelic-java-agent by newrelic.

the class MuleWorkManager_Instrumentation method executeWork.

@Trace
private void executeWork(WorkerContext work, WorkExecutor workExecutor) {
    final Transaction txn = AgentBridge.getAgent().getTransaction(false);
    if (txn != null) {
        TracedMethod tm = (TracedMethod) txn.getTracedMethod();
        if (tm != null) {
            tm.setMetricName("Flow", "MuleWorkManager", "executeWork", name);
        }
    }
    Weaver.callOriginal();
}
Also used : Transaction(com.newrelic.agent.bridge.Transaction) TracedMethod(com.newrelic.agent.bridge.TracedMethod) Trace(com.newrelic.api.agent.Trace)

Example 30 with Transaction

use of com.newrelic.agent.bridge.Transaction in project newrelic-java-agent by newrelic.

the class WorkerContext_Instrumentation method workAccepted.

@Trace(async = true, excludeFromTransactionTrace = true)
public synchronized void workAccepted(Object anObject) {
    Transaction txn = AgentBridge.getAgent().getTransaction(false);
    if (txn != null) {
        String className = worker.getClass().getName();
        if (MuleUtils.ignoreClass(className)) {
            txn.ignore();
        } else {
            asyncToken = txn.getToken();
        }
    }
    Weaver.callOriginal();
}
Also used : Transaction(com.newrelic.agent.bridge.Transaction) Trace(com.newrelic.api.agent.Trace)

Aggregations

Transaction (com.newrelic.agent.bridge.Transaction)40 Trace (com.newrelic.api.agent.Trace)18 TracedMethod (com.newrelic.agent.bridge.TracedMethod)7 AgentBridge (com.newrelic.agent.bridge.AgentBridge)4 WeaveIntoAllMethods (com.newrelic.api.agent.weaver.WeaveIntoAllMethods)4 WeaveWithAnnotation (com.newrelic.api.agent.weaver.WeaveWithAnnotation)4 URI (java.net.URI)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 Segment (com.newrelic.api.agent.Segment)3 Label (org.objectweb.asm.Label)3 Method (org.objectweb.asm.commons.Method)3 TracedMethod (com.newrelic.api.agent.TracedMethod)2 MuleHttpConnectorRequest (com.nr.agent.instrumentation.mule3.MuleHttpConnectorRequest)2 OutboundWrapper (com.nr.instrumentation.jersey.client.OutboundWrapper)2 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 GET (javax.ws.rs.GET)2 HEAD (javax.ws.rs.HEAD)2 PUT (javax.ws.rs.PUT)2 Test (org.junit.Test)2