use of com.netflix.zuul.niws.RequestAttempts in project zuul by Netflix.
the class PassportLoggingHandler method logPassport.
private void logPassport(Channel channel) {
// Collect attributes.
CurrentPassport passport = CurrentPassport.fromChannel(channel);
HttpRequestMessage request = ClientRequestReceiver.getRequestFromChannel(channel);
HttpResponseMessage response = ClientRequestReceiver.getResponseFromChannel(channel);
SessionContext ctx = request == null ? null : request.getContext();
String topLevelRequestId = getRequestId(channel, ctx);
// Do some debug logging of the Passport.
if (LOG.isDebugEnabled()) {
LOG.debug("State after complete. " + ", current-server-conns = " + ConnCounter.from(channel).getCurrentActiveConns() + ", current-http-reqs = " + HttpMetricsChannelHandler.getInflightRequestCountFromChannel(channel) + ", status = " + (response == null ? getRequestId(channel, ctx) : response.getStatus()) + ", nfstatus = " + String.valueOf(StatusCategoryUtils.getStatusCategory(ctx)) + ", toplevelid = " + topLevelRequestId + ", req = " + request.getInfoForLogging() + ", passport = " + String.valueOf(passport));
}
// Some logging of session states if certain criteria match:
if (LOG.isInfoEnabled()) {
if (passport.wasProxyAttempt()) {
if (passport.findStateBackwards(PassportState.OUT_RESP_LAST_CONTENT_SENDING) == null) {
incompleteProxySessionCounter.increment();
LOG.info("Incorrect final state! toplevelid = " + topLevelRequestId + ", " + ChannelUtils.channelInfoForLogging(channel));
}
}
if (!passport.wasProxyAttempt()) {
if (ctx != null && !isHealthcheckRequest(request)) {
// Why did we fail to attempt to proxy this request?
RequestAttempts attempts = RequestAttempts.getFromSessionContext(ctx);
LOG.debug("State after complete. " + ", context-error = " + String.valueOf(ctx.getError()) + ", current-http-reqs = " + HttpMetricsChannelHandler.getInflightRequestCountFromChannel(channel) + ", toplevelid = " + topLevelRequestId + ", req = " + request.getInfoForLogging() + ", attempts = " + String.valueOf(attempts) + ", passport = " + String.valueOf(passport));
}
}
StartAndEnd inReqToOutResp = passport.findFirstStartAndLastEndStates(PassportState.IN_REQ_HEADERS_RECEIVED, PassportState.OUT_REQ_LAST_CONTENT_SENT);
if (passport.calculateTimeBetween(inReqToOutResp) > WARN_REQ_PROCESSING_TIME_NS.get()) {
LOG.info("Request processing took longer than threshold! toplevelid = " + topLevelRequestId + ", " + ChannelUtils.channelInfoForLogging(channel));
}
StartAndEnd inRespToOutResp = passport.findLastStartAndFirstEndStates(PassportState.IN_RESP_HEADERS_RECEIVED, PassportState.OUT_RESP_LAST_CONTENT_SENT);
if (passport.calculateTimeBetween(inRespToOutResp) > WARN_RESP_PROCESSING_TIME_NS.get()) {
LOG.info("Response processing took longer than threshold! toplevelid = " + topLevelRequestId + ", " + ChannelUtils.channelInfoForLogging(channel));
}
}
}
use of com.netflix.zuul.niws.RequestAttempts in project zuul by Netflix.
the class ZuulSessionContextDecorator method decorate.
@Override
public SessionContext decorate(SessionContext ctx) {
// TODO split out commons parts from BaseSessionContextDecorator
ChannelHandlerContext nettyCtx = (ChannelHandlerContext) ctx.get(CommonContextKeys.NETTY_SERVER_CHANNEL_HANDLER_CONTEXT);
if (nettyCtx == null) {
return null;
}
Channel channel = nettyCtx.channel();
// set injected origin manager
ctx.put(CommonContextKeys.ORIGIN_MANAGER, originManager);
// TODO
/* // The throttle result info.
ThrottleResult throttleResult = channel.attr(HttpRequestThrottleChannelHandler.ATTR_THROTTLE_RESULT).get();
ctx.set(CommonContextKeys.THROTTLE_RESULT, throttleResult);*/
// Add a container for request attempts info.
ctx.put(CommonContextKeys.REQUEST_ATTEMPTS, new RequestAttempts());
// Providers for getting the size of read/written request and response body sizes from channel.
ctx.put(CommonContextKeys.REQ_BODY_SIZE_PROVIDER, HttpBodySizeRecordingChannelHandler.getCurrentInboundBodySize(channel));
ctx.put(CommonContextKeys.RESP_BODY_SIZE_PROVIDER, HttpBodySizeRecordingChannelHandler.getCurrentOutboundBodySize(channel));
CurrentPassport passport = CurrentPassport.fromChannel(channel);
ctx.put(CommonContextKeys.PASSPORT, passport);
ctx.setUUID(UUID_FACTORY.generateRandomUuid().toString());
return ctx;
}
use of com.netflix.zuul.niws.RequestAttempts in project zuul by Netflix.
the class NettyRequestAttemptFactory method mapNettyToOutboundException.
public OutboundException mapNettyToOutboundException(final Throwable t, final SessionContext context) {
if (t instanceof OutboundException) {
return (OutboundException) t;
}
// Map this throwable to zuul's OutboundException.
final ErrorType errorType = mapNettyToOutboundErrorType(t);
final RequestAttempts attempts = RequestAttempts.getFromSessionContext(context);
if (errorType == OTHER) {
return new OutboundException(errorType, attempts, t);
}
return new OutboundException(errorType, attempts);
}
Aggregations