Search in sources :

Example 1 with Transaction

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

the class ContainerResponse method close.

public void close() {
    Transaction tx = AgentBridge.getAgent().getTransaction(false);
    if (tx != null) {
        tx.getCrossProcessState().processOutboundResponseHeaders(new ResponseImpl(this), contentLength);
    }
    // Optimization. This allows the weaver to clear the backing NewField map
    contentLength = 0;
    Weaver.callOriginal();
}
Also used : Transaction(com.newrelic.agent.bridge.Transaction)

Example 2 with Transaction

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

the class ClientRuntime_Instrumentation method createRunnableForAsyncProcessing.

Runnable createRunnableForAsyncProcessing(ClientRequest request, final ResponseCallback_Instrumentation callback) {
    Transaction transaction = AgentBridge.getAgent().getTransaction(false);
    if (transaction != null) {
        callback.segment = transaction.startSegment(JerseyClientUtils.JERSEY_SEGMENT_NAME);
        callback.segment.addOutboundRequestHeaders(new OutboundWrapper(request));
    }
    return Weaver.callOriginal();
}
Also used : Transaction(com.newrelic.agent.bridge.Transaction) OutboundWrapper(com.nr.instrumentation.jersey.client.OutboundWrapper)

Example 3 with Transaction

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

the class ClientRuntime_Instrumentation method submit.

public void submit(final ClientRequest request, ResponseCallback_Instrumentation callback) {
    Transaction transaction = AgentBridge.getAgent().getTransaction(false);
    if (transaction != null) {
        callback.segment = transaction.startSegment(JerseyClientUtils.JERSEY_SEGMENT_NAME);
        callback.segment.addOutboundRequestHeaders(new OutboundWrapper(request));
    }
    Weaver.callOriginal();
}
Also used : Transaction(com.newrelic.agent.bridge.Transaction) OutboundWrapper(com.nr.instrumentation.jersey.client.OutboundWrapper)

Example 4 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.6.
 */
@Trace
public static MuleEvent transform(final HttpRequestContext requestContext, final MuleContext muleContext, final FlowConstruct flowConstruct, Boolean parseRequest, ListenerPath 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 5 with Transaction

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

the class NettyDispatcher method channelRead.

@Trace(dispatcher = true)
public static void channelRead(ChannelHandlerContext_Instrumentation ctx, Object msg) {
    ctx.pipeline().token = AgentBridge.getAgent().getTransaction().getToken();
    TracedMethod tracer = AgentBridge.getAgent().getTransaction().getTracedMethod();
    if (tracer == null) {
        // it happens.
        AgentBridge.getAgent().getLogger().log(Level.FINEST, "Unable to dispatch netty tx. No tracer.");
    } else {
        tracer.setMetricName("NettyUpstreamDispatcher");
        AgentBridge.getAgent().getTransaction().setTransactionName(TransactionNamePriority.SERVLET_NAME, true, "NettyDispatcher", "NettyDispatcher");
    }
    Transaction tx = AgentBridge.getAgent().getTransaction(false);
    if (tx != null) {
        tx.setWebRequest(new RequestWrapper((HttpRequest) msg));
    }
}
Also used : HttpRequest(io.netty.handler.codec.http.HttpRequest) Transaction(com.newrelic.agent.bridge.Transaction) RequestWrapper(com.agent.instrumentation.netty40.RequestWrapper) TracedMethod(com.newrelic.api.agent.TracedMethod) 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