/** * Retrieves {@link com.yahoo.bard.webservice.logging.blocks.BardQueryInfo} from * {@link com.yahoo.bard.webservice.logging.RequestLog}. * * @return {@link com.yahoo.bard.webservice.logging.blocks.BardQueryInfo} from * {@link com.yahoo.bard.webservice.logging.RequestLog} */ public static BardQueryInfo getBardQueryInfo() { return ((BardQueryInfo) RequestLog.retrieve(BardQueryInfo.class)); }
/** * Registers the duration of this timer with the RequestLog. * <p> * It is highly recommended that you {@link TimedPhase#stop()}} the timer first. Otherwise, the timings may * be inaccurate. To both stop and register the timer at once see {@link TimedPhase#close}. * * @see TimedPhase#stop() * @see TimedPhase#close() */ public void registerTime() { RequestLog.registerTime(this); }
/** * Stops the timer, and registers the timer with the RequestLog. * <p> * This is primarily meant to be used by the try-with-resources block, which both stops the timer and registers it * with the RequestLog, though it can of course be called manually as well. If you want to stop the timer, but * don't want to register the timer just yet, then see {@link TimedPhase#stop}. * * @see TimedPhase#stop() * @see TimedPhase#registerTime() */ @Override public void close() { stop(); registerTime(); } }
/** * Exports current thread's request log object as a formatted string without resetting it. * * @return log object as a formatted string */ public static String export() { RequestLog current = RLOG.get(); record(new Durations(current.aggregateDurations())); record(new Threads(current.threadIds)); return LogFormatterProvider.getInstance().format(current.info); }
@Override public void filter(ClientRequestContext request, ClientResponseContext response) { RequestLog.stopTiming("TestLogWrapper"); RequestLog.log(); } }
/** * Stop the request timer, start the response timer, and then invoke the failure callback code. * * @param error The error that caused the failure */ default void dispatch(Throwable error) { RequestLog.stopTiming(REQUEST_WORKFLOW_TIMER); RequestLog.startTiming(RESPONSE_WORKFLOW_TIMER); invoke(error); } }
@Override public void filter(final ContainerRequestContext request) { RequestLog.startTiming("TestLogWrapper"); }
/** * Sends the response back to the user. * * @param response The response to send to the user * @param asyncResponse The channel over which to send the response */ private void send(Response response, AsyncResponse asyncResponse) { if (RequestLog.isRunning(RESPONSE_WORKFLOW_TIMER)) { RequestLog.stopTiming(RESPONSE_WORKFLOW_TIMER); } asyncResponse.resume(response); }
/** * 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); }
/** * Exports a snapshot of the request log of the current thread and also resets the request log for that thread. * * @return the log context of the current thread */ public static RequestLog dump() { RequestLog current = RLOG.get(); RequestLog copy = new RequestLog(current); current.clear(); RLOG.remove(); return copy; }
@Override public void close() { stop(); }
/** * Append a part of logging information defined in this LogBlock. * * @param phase A {@link LogInfo} object including the information to be logged. */ public void add(LogInfo phase) { body.put(phase.getName(), phase); }
@Override public void filter(ContainerRequestContext request, ContainerResponseContext response) { RequestLog.stopTiming("TestLogWrapper"); RequestLog.log(); }
@Override public void filter(final ClientRequestContext request) { RequestLog.startTiming("TestLogWrapper"); }
@Override public void close() { stop(); }
@Override public void filter(ContainerRequestContext request, ContainerResponseContext response) { RequestLog.stopTiming("TestLogWrapper"); RequestLog.log(); }
@Override public void filter(final ContainerRequestContext request) { RequestLog.startTiming("TestLogWrapper"); }
@Override public void filter(ClientRequestContext request, ClientResponseContext response) { RequestLog.stopTiming("TestLogWrapper"); RequestLog.log(); } }
@Override public void filter(final ClientRequestContext request) { RequestLog.startTiming("TestLogWrapper"); }