-
Notifications
You must be signed in to change notification settings - Fork 693
Web Request Filters are not pushing traceId to Cloud Logging, so log lines are not grouped #2573
Comments
My hunch is that there's something up with the filter ordering. I had a sample app handy in the debugger with the latest milestone of Spring Cloud: You can see that there are 3 relevant filters: Here is
And the resulting traces in Stackdriver: Can you hit a debug point and peek at your filter config? Does it look anything like mine? If not, what does yours look like? |
Yep - you can find the changes on this commit: ttomsu@90350c1 You can run the sample and/or the test with the following steps:
Here's what I see in the Cloud Console: |
Hello,
Then I wanted to try directly from online environment, so I deploy the application, with a couple of more changes
Then I simply hit the So what is changed here compared to my previous test? Do I need to always enable tracing?
If so, why this is needed only for Filter logs? W/o this the request logs are working fine. EDIT |
Yes, the tracing module needs to be added to your Tracing and Logging are separate but related modules - AFAIK you can have one, the other, or both. If you have both, you get some nice features where you can jump from the Trace timing page into the logs that resulted from just that trace (which is the behavior I think you're after). The I'm glad to see you've got it working! I'm going to close this issue for now, but feel free to reopen if you have more questions. |
Ok thank you. With this additional configuration the filter log lines are also grouped, so it seems to be a very mandatory configuration for the log part, even if I don't need the Trace part. |
Hi @NicolaSpreafico , I discussed this with my team a bit more and I think I have a better handler of what's going on - namely that you shouldn't have to add the Background context: When a request is being handled through Spring MVC, it goes through several stages:
When you just have the logging module included in your POM, we look for the When we add the I added the same So ultimately you can choose to keep the Trace library added or play with a little Spring bean magic and implement your desired logic as an |
Hi @ttomsu, For future improvements I keep record of your suggestion, but right now it's enough as it is. Thanks |
Hello @ttomsu, I have a second filter which manage all uncaught errors, like if I get a nullpointer somewhere or any kind of unmanaged error that need to be logged. I find that when is the case, the actual logs with severe level doesn't contain the trace id Here is the log with the stacktrace inside the text content, you can see that there is not traceId (it is an illegalargumentexception) Is it possible that because the request crashed during execution the component which actually manage the logs has been deactivated? |
I'm not sure of the root cause without more knowledge of when the NPE is thrown and what has been processed up to that point. Including the As a reminder - having Sleuth manage the trace context is separate from the sampler's probability. By setting |
@ttomsu I think I was mislead by previous case. In my actual project the problem it isn't that error log are not traced, the problem is that more than 1 filter is not traced at all. I have 3 different filters in my project and only one produces log which actually has trace ids. In your previous examples did you tried more than 1 filter in order to see if all logs of all filters are actually traced? I found this about filter priority, do you think is the actual cause? |
@NicolaSpreafico Backtracking a bit, I just want to reiterate what @ttomsu already said about trace ID working without Sleuth. So, if you don't require tracing, you should remove
|
Hello,
I found similar issue but no an actual idea or resolution:
I have a Spring Boot Java11 application deployed on GCP App Engine Standard. My goal is to obtain log lines to be grouped under a common parent (the request log), so I can expand them and isolate them across different requests. In order to do so I understood I need to user the logback plugin, so starting from:
I implemented the needed configurations
and the
logback-spring
xml fileAs test code I started from the Hello World project: https://cloud.google.com/appengine/docs/standard/java11/quickstart
I add a simple log line in the controller
and it's working
The problem here, which is why I'm opening this issue, is that logs generated by Request Filters are logged w/o a traceId, so the Logging Console is not able do group them.
I created 2 very simple filters, just for example,
Filter1
andFilter2
and I can see the log lines displayed
but because the filter log lines do not have any traceId, the parent view is not workin
In my actual application I have a couple of actual filters that are providing log lines, and I would like very much to see them under the actual parent request. Is something that can be done? Am I missing some configuration?
The text was updated successfully, but these errors were encountered: