@Override public RequestLog log() { return delegate().log(); }
reqCtx.log().addListener(accessLogWriter::log, RequestLogAvailability.COMPLETE); }); return future;
public static void setup(RequestContext ctx, MeterIdPrefixFunction meterIdPrefixFunction) { if (ctx.hasAttr(ATTR_REQUEST_METRICS_SET)) { return; } ctx.attr(ATTR_REQUEST_METRICS_SET).set(true); ctx.log().addListener(log -> onRequest(log, meterIdPrefixFunction), RequestLogAvailability.REQUEST_HEADERS, RequestLogAvailability.REQUEST_CONTENT); }
@Override protected void append(ILoggingEvent eventObject) { final RequestContext ctx = RequestContext.mapCurrent(Function.identity(), () -> null); if (ctx != null) { final State state = state(ctx); final RequestLog log = ctx.log(); final Set<RequestLogAvailability> availabilities = log.availabilities(); // Note: This equality check is extremely fast. // See RequestLogAvailabilitySet for more information. if (!availabilities.equals(state.availabilities)) { state.availabilities = availabilities; export(state, ctx, log); } final Map<String, String> originalMdcMap = eventObject.getMDCPropertyMap(); final Map<String, String> mdcMap; // Create a copy of 'state' to avoid the race between: // - the delegate appenders who iterate over the MDC map and // - this class who update 'state'. if (!originalMdcMap.isEmpty()) { mdcMap = new UnionMap<>(state.clone(), originalMdcMap); } else { mdcMap = state.clone(); } eventObject = new LoggingEventWrapper(eventObject, mdcMap); } aai.appendLoopOnAppenders(eventObject); }
private static void onRequest(RequestLog log, MeterIdPrefixFunction meterIdPrefixFunction) { final RequestContext ctx = log.context(); final MeterRegistry registry = ctx.meterRegistry(); final MeterIdPrefix activeRequestsId = meterIdPrefixFunction.activeRequestPrefix(registry, log) .append("activeRequests"); final ActiveRequestMetrics activeRequestMetrics = MicrometerUtil.register( registry, activeRequestsId, ActiveRequestMetrics.class, (reg, prefix) -> reg.gauge(prefix.name(), prefix.tags(), new ActiveRequestMetrics(), ActiveRequestMetrics::doubleValue)); activeRequestMetrics.increment(); ctx.log().addListener(requestLog -> onResponse(requestLog, meterIdPrefixFunction, activeRequestMetrics), RequestLogAvailability.COMPLETE); }
@Override protected void append(ILoggingEvent eventObject) { final RequestContext ctx = RequestContext.mapCurrent(Function.identity(), () -> null); if (ctx != null) { final State state = state(ctx); final RequestLog log = ctx.log(); final Set<RequestLogAvailability> availabilities = log.availabilities(); // Note: This equality check is extremely fast. // See RequestLogAvailabilitySet for more information. if (!availabilities.equals(state.availabilities)) { state.availabilities = availabilities; export(state, ctx, log); } final Map<String, String> originalMdcMap = eventObject.getMDCPropertyMap(); final Map<String, String> mdcMap; // Create a copy of 'state' to avoid the race between: // - the delegate appenders who iterate over the MDC map and // - this class who update 'state'. if (!originalMdcMap.isEmpty()) { mdcMap = new UnionMap<>(state.clone(), originalMdcMap); } else { mdcMap = state.clone(); } eventObject = new LoggingEventWrapper(eventObject, mdcMap); } aai.appendLoopOnAppenders(eventObject); }
@Override protected void append(ILoggingEvent eventObject) { final RequestContext ctx = RequestContext.mapCurrent(Function.identity(), () -> null); if (ctx != null) { final State state = state(ctx); final RequestLog log = ctx.log(); final Set<RequestLogAvailability> availabilities = log.availabilities(); // Note: This equality check is extremely fast. // See RequestLogAvailabilitySet for more information. if (!availabilities.equals(state.availabilities)) { state.availabilities = availabilities; export(state, ctx, log); } final Map<String, String> originalMdcMap = eventObject.getMDCPropertyMap(); final Map<String, String> mdcMap; // Create a copy of 'state' to avoid the race between: // - the delegate appenders who iterate over the MDC map and // - this class who update 'state'. if (!originalMdcMap.isEmpty()) { mdcMap = new UnionMap<>(state.clone(), originalMdcMap); } else { mdcMap = state.clone(); } eventObject = new LoggingEventWrapper(eventObject, mdcMap); } aai.appendLoopOnAppenders(eventObject); }