lightblue-platform / lightblue-rest

Data access layer as service REST API
GNU General Public License v3.0
9 stars 16 forks source link

Fixes #249 - Loggingfilter #250

Closed dcrissman closed 8 years ago

dcrissman commented 8 years ago

Fixes https://github.com/lightblue-platform/lightblue-rest/issues/249

Add LoggingFilter to create a UUID for every request. That UUID is registered with the MDC so that it can be included in log4j patterns using %X{RequestUUID}

bserdar commented 8 years ago

LSB would return the last part of the string, MSB would return the first part. I suppose both should be somewhat equally distinct.

On Fri, Sep 30, 2016 at 12:13 PM, Dennis Crissman notifications@github.com wrote:

@dcrissman commented on this pull request.

In common/src/main/java/com/redhat/lightblue/rest/logging/ LoggingFilter.java https://github.com/lightblue-platform/lightblue-rest/pull/250:

+@WebFilter(urlPatterns = {"/*"}) +public class LoggingFilter implements Filter { +

  • private static final Logger LOGGER = LoggerFactory.getLogger(LoggingFilter.class); +
  • public static final String HEADER_REQUEST_UUID = "RequestUUID"; +
  • @Override
  • public void destroy() {
  • //Do Nothing!
  • } +
  • @Override
  • public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
  • try {
  • String requestUUID = UUID.randomUUID().toString();

I am not exactly sure of the difference, but I went with getMostSignificantBits. Mostly because it sounded more... significant.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lightblue-platform/lightblue-rest/pull/250, or mute the thread https://github.com/notifications/unsubscribe-auth/ADgDDasYbQUYKMFTXdKzPCDZlPUWXwMJks5qvVFdgaJpZM4KKp31 .

dcrissman commented 8 years ago

LSB would return the last part of the string, MSB would return the first part. I suppose both should be somewhat equally distinct.

I am honestly good either way. Whichever then you'd like.