use of play.libs.ws.StandaloneWSResponse in project newrelic-java-agent by newrelic.
the class JavaPlayWSUtils method finish.
public static CompletionStage<? extends StandaloneWSResponse> finish(Segment segment, String procedure, StandaloneWSRequest request, CompletionStage<? extends StandaloneWSResponse> response) {
if (segment == null) {
return response;
}
final Segment localSegment = segment;
localSegment.setMetricName("External", "PlayWS", procedure);
try {
response = response.whenComplete(new BiConsumer<StandaloneWSResponse, Throwable>() {
@Override
public void accept(StandaloneWSResponse standaloneWSResponse, Throwable throwable) {
if (throwable != null) {
try {
localSegment.reportAsExternal(HttpParameters.library("PlayWS").uri(new URL(request.getUrl()).toURI()).procedure(procedure).noInboundHeaders().build());
localSegment.end();
} catch (Exception e) {
}
} else {
try {
localSegment.reportAsExternal(HttpParameters.library("PlayWS").uri(new URL(request.getUrl()).toURI()).procedure(procedure).inboundHeaders(new JavaInboundWrapper(standaloneWSResponse)).build());
localSegment.end();
} catch (Exception e) {
}
}
}
});
} catch (Throwable t) {
AgentBridge.instrumentation.noticeInstrumentationError(t, Weaver.getImplementationTitle());
try {
localSegment.end();
} catch (Throwable t1) {
AgentBridge.instrumentation.noticeInstrumentationError(t, Weaver.getImplementationTitle());
}
}
return response;
}
Aggregations