I understand your reservations, though it’s often a matter of preference and the whole ecosystem in which you work. As much as I’m a fan of FP, I don’t think wrapping logging statements into the IO monad brings much benefit. On the contrary, it might hurt code readability. Same with trace ids — the signatures are often complicated enough.

There’s space for both approaches. Using ReaderT or MTL (as in https://gvolpe.github.io/http4s-tracer/) is tempting because of the simplicity of the underlying mechanisms.

I don’t mind however that my chosen effect monad does some extra work, esp if this is something as ubiquitous as request tracing.

Scala software engineer, Functional Programming enthusiast, SoftwareMill co-founder