-
Notifications
You must be signed in to change notification settings - Fork 82
Reimplement contextLog to populate MDC even when disabled #907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimplement contextLog to populate MDC even when disabled #907
Conversation
@morgen-peschke Would you mind reviewing this PR? |
move state to local logger
Took a minute to confirm my suspicion here, but the concern isn't the performance, it's that the Something like this would be trouble:
|
Riight I see, that makes sense. I am now a bit unsure how to implement this in one effect, as I think we need:
This worked before because isEnabled was done as step one. But to properly set the MDC before the log is called (which is needed for TurboFilters to work) it has to be second. Do you have any ideas on how this could work? I will continue to have a look into this as well. |
@bcarter97 here's a possible idea you can explore. In Cats Effect v3.6.0, we introduced the ability to create a The part I'm less sure about, that you should explore, is if it's possible to make a custom MDC implementation that is based on the |
I think that, with a bit of restructuring, we can get there without major structural changes outside of I was poking at it and ended up with #910, and it looks like it might do what you need. |
Yeah I was doing some digging and I don't think it will be possible with only 1 effect without exposing the logger's @armanbilge I had a look at how this could be done with IOLocal - slf4j exposes an SPI for MDCAdapter. I've looked at how Otel4s does this with IOLocalContextStorage, but I can't say I'm very confident I'd be able to replicate something similar. I think I'll close this PR in favour of #910, as the implementation is flawed. |
My attempt at solving #868.
false
<level>isEnabled
is checked, to assert it is updated even if the check resolves to false