We are creating range of dotnet core 2.0 microservices based on the servicestack framework. We want to use http-header based correlation tokens, so we can track a request in our distributed logging system (Seq).
We would like to use IoC to setup a a class holding a threadsafe JsonServiceClient for performance reasons, but how can we ensure that headers placed on one thread will not leak into another concurrent request? Client code example:
public TResponse Get(IReturn requestDto)
...
_serviceClient.AddHeader("r-id", theReqId); // how can we make these specific for the thread request only?
var responseFromDownstreamService = _serviceClient.Get(requestDto);