Reputation: 1
I have an issue after migrating to spring boot 3 with trace id, devs who maintaing upstream app did not check spring docs and update rest template creation using rest template builder, and our app stoped getting trace id and span, that is why has been made decision to send trace id as a custom header.
I qam trying to update app configuration so that if custom header for trace id is present, it will be used in observation context, but if it is not - app will use default configuration (use x-b3-traceid, x-b3-spanid if present).
I have tried to use 'OncePerRequestFilter' with high priority to set traceId from header via MDC context, but this values will be discarded by filter which will create new new observation context. I have found info that for such functionality I can use 'ObservationFilter' but I do not know how to set property for traceId so that it will work as expected.
if possible, please provide code example on how to get this done. thanks in advence.
Filter, OncePerRequestFilter, ObesrvationFilter.
Also tried to use HttpRequestWrapper to modify original request to add 'x-b3-traceId' with customer header as value, but it idid not work.
Upvotes: 0
Views: 140