Package com.google.cloud.spring.logging
Class TraceIdLoggingWebMvcInterceptor
java.lang.Object
com.google.cloud.spring.logging.TraceIdLoggingWebMvcInterceptor
- All Implemented Interfaces:
org.springframework.web.servlet.HandlerInterceptor
public class TraceIdLoggingWebMvcInterceptor
extends Object
implements org.springframework.web.servlet.HandlerInterceptor
HandlerInterceptor
that extracts the request trace ID
from the "x-cloud-trace-context" HTTP header and stores it in a thread-local using TraceIdLoggingEnhancer.setCurrentTraceId(java.lang.String)
.
The TraceIdLoggingEnhancer
can then be used in a logging appender to add the trace ID
metadata to log messages.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterCompletion
(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse, Object handler, Exception e) boolean
preHandle
(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp, Object handler) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.web.servlet.HandlerInterceptor
postHandle
-
Constructor Details
-
TraceIdLoggingWebMvcInterceptor
-
-
Method Details
-
getTraceIdExtractor
-
preHandle
public boolean preHandle(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp, Object handler) - Specified by:
preHandle
in interfaceorg.springframework.web.servlet.HandlerInterceptor
-
afterCompletion
public void afterCompletion(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse, Object handler, Exception e) - Specified by:
afterCompletion
in interfaceorg.springframework.web.servlet.HandlerInterceptor
-