@Override public void filter(final ContainerRequestContext request, final ContainerResponseContext response) throws IOException { String id = request.getHeaderString(REQUEST_ID); if (Strings.isNullOrEmpty(id)) { id = generateRandomUuid().toString(); } logger.trace("method={} path={} request_id={} status={} length={}", request.getMethod(), request.getUriInfo().getPath(), id, response.getStatus(), response.getLength()); response.getHeaders().putSingle(REQUEST_ID, id); }
@Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { if (LOG.isDebugEnabled()) { try { final String rawQuery = requestContext.getUriInfo().getRequestUri().getRawQuery(); final Date requestDate = requestContext.getDate(); final String userName = RestTools.getUserNameFromRequest(requestContext); final String remoteAddress = RestTools.getRemoteAddrFromRequest(response.getRequest(), trustedProxies); final String userAgent = requestContext.getHeaderString(HttpHeaders.USER_AGENT); LOG.debug("{} {} [{}] \"{} {}{}\" {} {} {}", remoteAddress, userName == null ? "-" : userName, (requestDate == null ? "-" : requestDate), requestContext.getMethod(), requestContext.getUriInfo().getPath(), (rawQuery == null ? "" : "?" + rawQuery), (userAgent == null ? "-" : userAgent), responseContext.getStatus(), responseContext.getLength()); } catch (Exception e) { LOG.error("Error while processing REST API access log", e); } } } }
@Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { // 补充服务端request和response大小 if (RpcInternalContext.isAttachmentEnable()) { RpcInternalContext context = RpcInternalContext.getContext(); context.setAttachment(RpcConstants.INTERNAL_KEY_REQ_SIZE, requestContext.getLength()); context.setAttachment(RpcConstants.INTERNAL_KEY_RESP_SIZE, responseContext.getLength()); Long startTime = (Long) context.removeAttachment(RpcConstants.INTERNAL_KEY_SERVER_RECEIVE_TIME); if (startTime != null) { context.setAttachment(RpcConstants.INTERNAL_KEY_IMPL_ELAPSE, RpcRuntimeContext.now() - startTime); } } } }
@Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { // 补充服务端request和response大小 if (RpcInternalContext.isAttachmentEnable()) { RpcInternalContext context = RpcInternalContext.getContext(); context.setAttachment(RpcConstants.INTERNAL_KEY_REQ_SIZE, requestContext.getLength()); context.setAttachment(RpcConstants.INTERNAL_KEY_RESP_SIZE, responseContext.getLength()); Long startTime = (Long) context.removeAttachment(RpcConstants.INTERNAL_KEY_SERVER_RECEIVE_TIME); if (startTime != null) { context.setAttachment(RpcConstants.INTERNAL_KEY_IMPL_ELAPSE, RpcRuntimeContext.now() - startTime); } } } }
private boolean isTooSmall(ContainerResponseContext response) { int length = response.getLength(); return length != -1 && length < minCompressionBytes; }
@Override public long getLength() { int res = ctx.getLength(); if (res < 0) { if (ctx.hasEntity()) { res = ctx.getEntity().toString().length(); } } return res; }
@Override public long getLength() { int res = ctx.getLength(); if (res < 0) { if (ctx.hasEntity()) { res = ctx.getEntity().toString().length(); } } return res; }
@Override public void filter(final ContainerRequestContext request, final ContainerResponseContext response) throws IOException { String id = request.getHeaderString(REQUEST_ID); if (Strings.isNullOrEmpty(id)) { id = generateRandomUuid().toString(); } logger.trace("method={} path={} request_id={} status={} length={}", request.getMethod(), request.getUriInfo().getPath(), id, response.getStatus(), response.getLength()); response.getHeaders().putSingle(REQUEST_ID, id); }
@Override public void filter( ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { HttpRequestContext context = (HttpRequestContext) requestContext.getProperty(CONTEXT_PROPERTY); if (context == null) { // JAX-RS response filters are always invoked - we only want to record something if // request came through this filter return; } Scope scope = (Scope) requestContext.getProperty(SPAN_PROPERTY); if (scope != null) { scope.close(); } if (responseContext.getLength() > 0) { handler.handleMessageSent(context, responseContext.getLength()); } ExtendedContainerRequest extendedRequest = new ExtendedContainerRequest(requestContext, info); handler.handleEnd(context, extendedRequest, responseContext, null); } }
@Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { if (LOG.isDebugEnabled()) { try { final String rawQuery = requestContext.getUriInfo().getRequestUri().getRawQuery(); final Date requestDate = requestContext.getDate(); final String userName = RestTools.getUserNameFromRequest(requestContext); final String remoteAddress = RestTools.getRemoteAddrFromRequest(response.getRequest(), trustedProxies); final String userAgent = requestContext.getHeaderString(HttpHeaders.USER_AGENT); LOG.debug("{} {} [{}] \"{} {}{}\" {} {} {}", remoteAddress, userName == null ? "-" : userName, (requestDate == null ? "-" : requestDate), requestContext.getMethod(), requestContext.getUriInfo().getPath(), (rawQuery == null ? "" : "?" + rawQuery), (userAgent == null ? "-" : userAgent), responseContext.getStatus(), responseContext.getLength()); } catch (Exception e) { LOG.error("Error while processing REST API access log", e); } } } }
if (response.getLength() == -1 && response.hasEntity()) { request.setProperty(PROPERTY_OUTPUT_STREAM, stream); } else { debugMsgBuilder.append("length=").append(response.getLength()).append("\t"); Observable.just((long) response.getLength()).subscribe(responseLengthObserver); LOG.debug(debugMsgBuilder.toString()); RequestLog.stopTiming(this);
(sessionExtended ? "true" : "false"), responseContext.getStatus(), responseContext.getLength()); } catch (Exception ignored) { LOG.error(":(", ignored);
@Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { // 补充服务端request和response大小 if (RpcInternalContext.isAttachmentEnable()) { RpcInternalContext context = RpcInternalContext.getContext(); context.setAttachment(RpcConstants.INTERNAL_KEY_REQ_SIZE, requestContext.getLength()); context.setAttachment(RpcConstants.INTERNAL_KEY_RESP_SIZE, responseContext.getLength()); Long startTime = (Long) context.removeAttachment(RpcConstants.INTERNAL_KEY_SERVER_RECEIVE_TIME); if (startTime != null) { context.setAttachment(RpcConstants.INTERNAL_KEY_IMPL_ELAPSE, RpcRuntimeContext.now() - startTime); } } } }