@Override public void filter(ContainerRequestContext request, ContainerResponseContext response) throws IOException { response.getHeaders().putSingle(X_REQUEST_ID, RequestLog.getId()); } }
/** * Prepend an id prefix to generated druid query id. * * @param idPrefix Prefix for queryId sent to druid */ public static void addIdPrefix(String idPrefix) { RequestLog current = RLOG.get(); String newId = idPrefix + getId(); current.info = current.info.withUuid(newId); current.logId = newId; MDC.put(ID_KEY, newId); }
/** * Gathers some interesting data from the request and builds a string out of it. * * @param requestContext The request context. Contains info we want to log * @return the StringBuilder containing our logging info */ protected StringBuilder builderErrorResponseBody(ContainerRequestContext requestContext) { StringBuilder debugMsgBuilder = new StringBuilder(); if (requestContext.getSecurityContext().getUserPrincipal() != null) { String user = requestContext.getSecurityContext().getUserPrincipal().getName(); debugMsgBuilder.append("User=") .append(user) .append(System.lineSeparator()); } debugMsgBuilder.append("Timestamp: ") .append(java.time.Clock.systemUTC().instant().toString()) .append(System.lineSeparator()); debugMsgBuilder.append("Request ID: ") .append(RequestLog.getId()) .append(System.lineSeparator()); return debugMsgBuilder; } }
/** * Constructor. * * @param queryType The type of this query * @param dataSource The datasource * @param context The context * @param incrementQueryId true to fork a new context and bump up the query id, or false to create an exact copy * of the context. */ protected AbstractDruidQuery( QueryType queryType, DataSource dataSource, QueryContext context, boolean incrementQueryId ) { this.queryType = queryType; this.dataSource = dataSource; this.context = context == null ? new QueryContext(Collections.<QueryContext.Param, Object>emptyMap(), null) .withQueryId(RequestLog.getId()) : incrementQueryId ? context.fork() : context; }
responseMap.put("description", description); responseMap.put("druidQuery", druidQuery); responseMap.put("requestId", RequestLog.getId());
LOG.debug("Cache entry present but invalid for query with id: {}", RequestLog.getId()); CACHE_POTENTIAL_HITS.mark(1); CACHE_MISSES.mark(1);