Search in sources :

Example 1 with Complete

use of akka.http.javadsl.server.Complete in project pinpoint by naver.

the class RequestContextImplCompleteInterceptor method doInAfterTrace.

@Override
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
    try {
        if (result instanceof Future && ((Future) result).isCompleted()) {
            Option value = ((Future) result).value();
            if (value == null) {
                return;
            }
            Object routeResult = value.get();
            if (routeResult instanceof Success) {
                Object success = ((Success) routeResult).get();
                if (success instanceof Complete) {
                    akka.http.javadsl.model.HttpResponse response = ((Complete) success).getResponse();
                    if (response == null) {
                        return;
                    }
                    akka.http.javadsl.model.StatusCode status = response.status();
                    if (status == null) {
                        return;
                    }
                    recorder.recordAttribute(AnnotationKey.HTTP_STATUS_CODE, status.intValue());
                }
            } else if (routeResult instanceof Failure) {
                Throwable failure = ((Failure) routeResult).exception();
                recorder.recordException(failure);
            }
        }
    } finally {
        recorder.recordApi(methodDescriptor);
        recorder.recordServiceType(AkkaHttpConstants.AKKA_HTTP_SERVER_INTERNAL);
        recorder.recordException(throwable);
    }
}
Also used : Complete(akka.http.javadsl.server.Complete) Future(scala.concurrent.Future) Option(scala.Option) Success(scala.util.Success) Failure(scala.util.Failure)

Aggregations

Complete (akka.http.javadsl.server.Complete)1 Option (scala.Option)1 Future (scala.concurrent.Future)1 Failure (scala.util.Failure)1 Success (scala.util.Success)1