I have a proxy service based on netflix Zuul. For any logs, from my custom filters or Zuul built in filters, I want to have a request header called Flow-Id to be part of my log. I can do this by setting the value of this header in the MDC context using a pre filter. But this works only if all the filters are executed in same thread.
Are all Zuul filters for one request executed in same thread? And will this thread run anything else while this request is still in progress?
I looked into the code and figured out Zuul proxy is using a servlet. And the spring cloud wrap this servlet in a ServletWrappingController.
So to answer my own question, all filters are executed in one thread.
And to make sure that MDC context is set as early as possible, I did it in a servlet filter and added a spring bean.