Search in sources :

Example 1 with OutboundWrapper

use of com.nr.instrumentation.jersey.client.OutboundWrapper in project newrelic-java-agent by newrelic.

the class ClientHandler_Instrumentation method handle.

@Trace(leaf = true)
public ClientResponse handle(ClientRequest request) throws ClientHandlerException {
    NewRelic.getAgent().getTracedMethod().addOutboundRequestHeaders(new OutboundWrapper(request));
    ClientResponse response = Weaver.callOriginal();
    NewRelic.getAgent().getTracedMethod().reportAsExternal(HttpParameters.library(JerseyClientUtils.JERSEY_CLIENT).uri(request.getURI()).procedure(request.getMethod()).inboundHeaders(new InboundWrapper(response)).build());
    return response;
}
Also used : InboundWrapper(com.nr.instrumentation.jersey.client.InboundWrapper) OutboundWrapper(com.nr.instrumentation.jersey.client.OutboundWrapper) Trace(com.newrelic.api.agent.Trace)

Example 2 with OutboundWrapper

use of com.nr.instrumentation.jersey.client.OutboundWrapper 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 OutboundWrapper

use of com.nr.instrumentation.jersey.client.OutboundWrapper in project newrelic-java-agent by newrelic.

the class ClientRuntime_Instrumentation method invoke.

@Trace(leaf = true)
public ClientResponse invoke(final ClientRequest request) throws Exception {
    NewRelic.getAgent().getTracedMethod().addOutboundRequestHeaders(new OutboundWrapper(request));
    ClientResponse response;
    try {
        response = Weaver.callOriginal();
    } catch (ProcessingException ex) {
        if (ex.getCause() instanceof UnknownHostException) {
            NewRelic.getAgent().getTracedMethod().reportAsExternal(HttpParameters.library(JerseyClientUtils.JERSEY_CLIENT).uri(JerseyClientUtils.UNKNOWN_HOST_URI).procedure(JerseyClientUtils.FAILED).noInboundHeaders().build());
        }
        throw ex;
    }
    NewRelic.getAgent().getTracedMethod().reportAsExternal(HttpParameters.library(JerseyClientUtils.JERSEY_CLIENT).uri(request.getUri()).procedure(request.getMethod()).inboundHeaders(new InboundWrapper(response)).build());
    return response;
}
Also used : UnknownHostException(java.net.UnknownHostException) InboundWrapper(com.nr.instrumentation.jersey.client.InboundWrapper) OutboundWrapper(com.nr.instrumentation.jersey.client.OutboundWrapper) ProcessingException(javax.ws.rs.ProcessingException) Trace(com.newrelic.api.agent.Trace)

Example 4 with OutboundWrapper

use of com.nr.instrumentation.jersey.client.OutboundWrapper 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)

Aggregations

OutboundWrapper (com.nr.instrumentation.jersey.client.OutboundWrapper)4 Transaction (com.newrelic.agent.bridge.Transaction)2 Trace (com.newrelic.api.agent.Trace)2 InboundWrapper (com.nr.instrumentation.jersey.client.InboundWrapper)2 UnknownHostException (java.net.UnknownHostException)1 ProcessingException (javax.ws.rs.ProcessingException)1