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;
}
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();
}
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();
}
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();
}
});
}
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;
}
Aggregations