Search in sources :

Example 46 with Segment

use of com.newrelic.api.agent.Segment in project newrelic-java-agent by newrelic.

the class StandaloneWSRequest_Instrumentation method patch.

public CompletionStage<? extends StandaloneWSResponse> patch(BodyWritable body) {
    Segment currentSegment = this.segment;
    CompletionStage<? extends StandaloneWSResponse> responseFuture = Weaver.callOriginal();
    responseFuture = tryRecordExternalRequest("patch", responseFuture, currentSegment);
    return responseFuture;
}
Also used : Segment(com.newrelic.api.agent.Segment)

Example 47 with Segment

use of com.newrelic.api.agent.Segment in project newrelic-java-agent by newrelic.

the class StandaloneWSRequest_Instrumentation method addCookies.

public StandaloneWSRequest_Instrumentation addCookies(WSCookie... cookies) {
    Segment currentSegment = this.segment;
    this.segment = null;
    StandaloneWSRequest_Instrumentation result = Weaver.callOriginal();
    result.segment = currentSegment;
    return result;
}
Also used : Segment(com.newrelic.api.agent.Segment)

Example 48 with Segment

use of com.newrelic.api.agent.Segment in project newrelic-java-agent by newrelic.

the class StandaloneWSRequest_Instrumentation method setAuth.

public StandaloneWSRequest_Instrumentation setAuth(String username, String password, WSAuthScheme scheme) {
    Segment currentSegment = this.segment;
    this.segment = null;
    StandaloneWSRequest_Instrumentation result = Weaver.callOriginal();
    result.segment = currentSegment;
    return result;
}
Also used : Segment(com.newrelic.api.agent.Segment)

Example 49 with Segment

use of com.newrelic.api.agent.Segment 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)

Example 50 with Segment

use of com.newrelic.api.agent.Segment in project newrelic-java-agent by newrelic.

the class Transformation_Instrumentation method run.

@Trace(excludeFromTransactionTrace = true)
public void run() {
    Segment segment = null;
    boolean remove = false;
    if (tokenAndRefCount != null) {
        // If we are here and there is no activeToken in progress we are the first one so we set this boolean in
        // order to correctly remove the "activeToken" from the thread local after the original run() method executes
        remove = AgentBridge.activeToken.get() == null;
        AgentBridge.activeToken.set(tokenAndRefCount);
        // getTransaction implicitly makes Transaction available on Thread to runnable
        Transaction tx = AgentBridge.getAgent().getTransaction(false);
        if (scalaFuturesAsSegments && remove) {
            if (tx != null) {
                segment = tx.startSegment("Scala", "Callback");
                segment.setMetricName("Scala", "Callback", ScalaUtils.nameScalaFunction(_arg.getClass().getName()));
            }
        }
    }
    try {
        Weaver.callOriginal();
    } finally {
        if (tokenAndRefCount != null) {
            if (segment != null) {
                segment.end();
            }
            if (remove) {
                AgentBridge.activeToken.remove();
            }
            if (tokenAndRefCount.refCount.decrementAndGet() == 0) {
                tokenAndRefCount.token.expire();
                tokenAndRefCount.token = null;
            }
        }
    }
}
Also used : Transaction(com.newrelic.agent.bridge.Transaction) Segment(com.newrelic.api.agent.Segment) Trace(com.newrelic.api.agent.Trace)

Aggregations

Segment (com.newrelic.api.agent.Segment)138 Trace (com.newrelic.api.agent.Trace)13 URI (java.net.URI)6 NoOpSegment (com.newrelic.agent.bridge.NoOpSegment)5 URISyntaxException (java.net.URISyntaxException)4 HttpResponse (akka.http.scaladsl.model.HttpResponse)3 Transaction (com.newrelic.agent.bridge.Transaction)3 DatastoreParameters (com.newrelic.api.agent.DatastoreParameters)3 ExternalParameters (com.newrelic.api.agent.ExternalParameters)3 InetSocketAddress (java.net.InetSocketAddress)3 Test (org.junit.Test)3 Transaction (com.newrelic.agent.Transaction)2 MessageProduceParameters (com.newrelic.api.agent.MessageProduceParameters)2 Transaction (com.newrelic.api.agent.Transaction)2 OutboundWrapper (com.nr.agent.instrumentation.asynchttpclient.OutboundWrapper)2 HelloReply (io.grpc.examples.helloworld.HelloReply)2 HelloRequest (io.grpc.examples.helloworld.HelloRequest)2 IOException (java.io.IOException)2 SocketAddress (java.net.SocketAddress)2 MemcachedNode (net.spy.memcached.MemcachedNode)2