@Test public void test_should_set_mdc_with_correlation_id() { MockHttpServletRequest request = new MockHttpServletRequest(); RequestContext.getCurrentContext().setRequest(request); correlationIdFilter.run(); assertNotNull(MDC.get("CORRELATION_ID")); }
@Override public Object run() { RequestContext ctx = RequestContext.getCurrentContext(); final String correlationId = UUID.randomUUID().toString(); MDC.put(CORRELATION_ID_KEY, correlationId); ctx.set(CORRELATION_ID_KEY, correlationId); logger.debug(RECEIVED_REQUEST_MESSAGE, ctx.getRequest().getRequestURI()); return null; }
CorrelationIdFilter extends ZuulFilter { @Override public Object run() { RequestContext ctx = RequestContext.getCurrentContext(); final String correlationId = UUID.randomUUID().toString(); MDC.put(CORRELATION_ID_KEY, correlationId); ctx.set(CORRELATION_ID_KEY, correlationId); logger.debug(RECEIVED_REQUEST_MESSAGE, ctx.getRequest().getRequestURI()); return null; } }
CorrelationIdFilter extends ZuulFilter { @Override public Object run() { RequestContext ctx = RequestContext.getCurrentContext(); final String correlationId = UUID.randomUUID().toString(); MDC.put(CORRELATION_ID_KEY, correlationId); ctx.set(CORRELATION_ID_KEY, correlationId); logger.debug(RECEIVED_REQUEST_MESSAGE, ctx.getRequest().getRequestURI()); return null; }  }
CorrelationIdFilter extends ZuulFilter { @Override public Object run() { RequestContext ctx = RequestContext.getCurrentContext(); final String correlationId = UUID.randomUUID().toString(); MDC.put(CORRELATION_ID_KEY, correlationId); ctx.set(CORRELATION_ID_KEY, correlationId); logger.debug(RECEIVED_REQUEST_MESSAGE, ctx.getRequest().getRequestURI()); return null; }  @Override String filterType(); @Override int filterOrder(); @Override boolean shouldFilter(); @Override Object run(); }
CorrelationIdFilter extends ZuulFilter { @Override public Object run() { RequestContext ctx = RequestContext.getCurrentContext(); final String correlationId = UUID.randomUUID().toString(); MDC.put(CORRELATION_ID_KEY, correlationId); ctx.set(CORRELATION_ID_KEY, correlationId); logger.debug(RECEIVED_REQUEST_MESSAGE, ctx.getRequest().getRequestURI()); return null; }  @Override String filterType(); @Override int filterOrder(); @Override boolean shouldFilter(); @Override Object run();  }