Search in sources :

Example 1 with HttpMessageEnd

use of spray.http.HttpMessageEnd in project newrelic-java-agent by newrelic.

the class ClientFrontendPipeline_Instrumentation method apply.

@Trace(async = true)
public final void apply(final Tcp.Event event) {
    if (event instanceof Http.MessageEvent && ((Http.MessageEvent) event).ev() instanceof HttpMessageEnd) {
        final HttpMessageEnd httpMessageEnd = (HttpMessageEnd) ((Http.MessageEvent) event).ev();
        if (this.$outer.spray$can$client$ClientFrontend$$anon$$anon$$openRequests().size() == 1) {
            RequestRecord_Instrumentation requestRecord = this.$outer.spray$can$client$ClientFrontend$$anon$$anon$$openRequests().head();
            HttpRequestPart request = requestRecord.request();
            if (request instanceof HttpRequest_Instrumentation) {
                Segment segment = ((HttpRequest_Instrumentation) request).segment;
                try {
                    boolean isSSL = ((HttpRequest_Instrumentation) request).isSSL;
                    InetSocketAddress hostAndPort = ((HttpRequest_Instrumentation) request).remoteAddress;
                    segment.reportAsExternal(HttpParameters.library("SprayCanClient").uri(new URI((isSSL ? "https" : "http"), null, hostAndPort.getHostName(), hostAndPort.getPort(), ((HttpRequest_Instrumentation) request).uri().path().toString(), null, null)).procedure("connection").inboundHeaders(new InboundHttpHeaders((HttpResponse) httpMessageEnd)).build());
                    segment.end();
                } catch (Exception e) {
                    NewRelic.getAgent().getLogger().log(Level.FINE, e, "Unable to record SprayCanClient externals");
                }
            }
        }
    }
    Weaver.callOriginal();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) HttpResponse(spray.http.HttpResponse) Http(spray.can.Http) HttpMessageEnd(spray.http.HttpMessageEnd) HttpRequest_Instrumentation(spray.http.HttpRequest_Instrumentation) URI(java.net.URI) Segment(com.newrelic.api.agent.Segment) HttpRequestPart(spray.http.HttpRequestPart) InboundHttpHeaders(com.nr.agent.instrumentation.spray.can.client.InboundHttpHeaders) Trace(com.newrelic.api.agent.Trace)

Aggregations

Segment (com.newrelic.api.agent.Segment)1 Trace (com.newrelic.api.agent.Trace)1 InboundHttpHeaders (com.nr.agent.instrumentation.spray.can.client.InboundHttpHeaders)1 InetSocketAddress (java.net.InetSocketAddress)1 URI (java.net.URI)1 Http (spray.can.Http)1 HttpMessageEnd (spray.http.HttpMessageEnd)1 HttpRequestPart (spray.http.HttpRequestPart)1 HttpRequest_Instrumentation (spray.http.HttpRequest_Instrumentation)1 HttpResponse (spray.http.HttpResponse)1