-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a header for distinguishing the services in logs #133
Comments
Why do you think so? The following should achieve it: @Filter(Filter.MATCH_ALL_PATTERN)
public class XReqIdHeaderFilter implements HttpServerFilter {
public static final String HEADER = "X-Request-ID";
@Override
public Publisher<MutableHttpResponse<?>> doFilter(final HttpRequest<?> request, final ServerFilterChain chain) {
return chain.proceed(request.mutate().header(HEADER, UUID.randomUUID().toString()));
}
}
I don't see the benefit here. This would mean only the caller has the ID, but we still wouldn't have a mechanism to find its logs in the callee.
Why can't we? Sure, we would need to keep some sort of context alongside all calls, but I wouldn't mind.
This is basically Option 2, but instead the callee sets it. It still has the same problem, because the callee generates the ID only after having done all the work. I would suggest looking into option 1 again and let the filter always set the header if it doesn't exist yet. This means the first time we get a request (in the manager or gateway), we attach an ID and use it for all subsequent requests in the system. |
This is not completely correct. You have to differentiate between incoming and outgoing requests. Incoming: Inside the controller you can send outgoing requests to other services: Inside the brackets happens the flow for incoming requests, but in a different service. |
To provide more context to log statements and facilitate the process of discerning them (what belongs where?), a X-Request-ID Header can be set.
A possible implementation involves the use of the HttpFilter and an Interceptor.
Furthermore, the functionality of setting a header should be configurable (on-off).
Implementation
If I understood correctly, the path from a request to a response is the following:
Req (1) -> Filter (2) -> Interceptor (3) -> Controller (4) -> Interceptor (5) -> Filter (6) -> Response (7)
The id could be later retrieved to extend the log statement with the ID information.
The problem is that we do this at the late stage and can't track as much info as we could.
DefaultMirrorRequestManager
. However, this solution is not robust as we must manually track all places in code where we create requests.The text was updated successfully, but these errors were encountered: