Search in sources :

Example 71 with Segment

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

the class HttpExtInstrumentation method singleRequest.

// We are weaving the singleRequestImpl method here rather than just singleRequest because the javadsl only flows through here
public Future<HttpResponse> singleRequest(HttpRequest httpRequest, HttpsConnectionContext connectionContext, ConnectionPoolSettings settings, LoggingAdapter log, Materializer fm) {
    final Segment segment = NewRelic.getAgent().getTransaction().startSegment("Akka", "singleRequest");
    Future<HttpResponse> responseFuture = Weaver.callOriginal();
    AkkaHttpUtils.finishSegmentOnComplete(httpRequest, responseFuture, segment);
    return responseFuture;
}
Also used : HttpResponse(akka.http.scaladsl.model.HttpResponse) Segment(com.newrelic.api.agent.Segment)

Example 72 with Segment

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

the class ClientCalls_Instrumentation method startCall.

private static <ReqT, RespT> void startCall(ClientCall_Instrumentation<ReqT, RespT> call, ClientCalls_Instrumentation.StartableListener_Instrumentation<RespT> responseListener) {
    Segment segment = NewRelic.getAgent().getTransaction().startSegment("gRPC", "External");
    call.segment = segment;
    Weaver.callOriginal();
}
Also used : Segment(com.newrelic.api.agent.Segment)

Example 73 with Segment

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

the class TestClient method helloStreaming.

@Trace(dispatcher = true)
public void helloStreaming(String name) {
    final Segment segment = NewRelic.getAgent().getTransaction().startSegment("helloStreaming");
    StreamObserver<io.grpc.examples.manualflowcontrol.HelloRequest> stream = streamingGreeterStub.sayHelloStreaming(new StreamObserver<io.grpc.examples.manualflowcontrol.HelloReply>() {

        @Override
        public void onNext(io.grpc.examples.manualflowcontrol.HelloReply value) {
            System.out.println("Next: " + value);
        }

        @Override
        public void onError(Throwable t) {
        }

        @Override
        public void onCompleted() {
            segment.end();
        }
    });
    io.grpc.examples.manualflowcontrol.HelloRequest request = io.grpc.examples.manualflowcontrol.HelloRequest.newBuilder().setName(name).build();
    stream.onNext(request);
    stream.onCompleted();
}
Also used : HelloRequest(io.grpc.examples.helloworld.HelloRequest) Segment(com.newrelic.api.agent.Segment) HelloReply(io.grpc.examples.helloworld.HelloReply) Trace(com.newrelic.api.agent.Trace)

Example 74 with Segment

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

the class TestClient method helloAsync.

@Trace(dispatcher = true)
public void helloAsync(String name) {
    final Segment segment = NewRelic.getAgent().getTransaction().startSegment("helloAsync");
    HelloRequest request = HelloRequest.newBuilder().setName(name).build();
    asyncGreeterStub.sayHello(request, new StreamObserver<HelloReply>() {

        @Override
        public void onNext(HelloReply value) {
            System.out.println("Next: " + value);
        }

        @Override
        public void onError(Throwable t) {
        }

        @Override
        public void onCompleted() {
            segment.end();
        }
    });
}
Also used : HelloRequest(io.grpc.examples.helloworld.HelloRequest) HelloReply(io.grpc.examples.helloworld.HelloReply) Segment(com.newrelic.api.agent.Segment) Trace(com.newrelic.api.agent.Trace)

Example 75 with Segment

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

the class HttpClientImpl_Instrumentation method send.

@Trace
public <T> HttpResponse<T> send(HttpRequest req, HttpResponse.BodyHandler<T> responseHandler) throws IOException, InterruptedException {
    URI uri = req.uri();
    Segment segment = startSegment(uri);
    HttpResponse<T> response;
    try {
        response = Weaver.callOriginal();
        if (segment == null) {
            return response;
        }
    } catch (Exception e) {
        handleConnectException(e, req, segment);
        throw e;
    }
    processResponse(response, segment);
    return response;
}
Also used : URI(java.net.URI) Segment(com.newrelic.api.agent.Segment) IOException(java.io.IOException) 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