Skip to content
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

SLF4J-522 - Adds NDC.contains() Method #267

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mwootendev
Copy link

Updates the NDC class in slf4j-ext to include a static contains() method
that can check the existing nested diagnostic context for the presence
of a value.

Added unit tests to test the new NDC.contains() method.

Updates the NDC class in slf4j-ext to include a static contains() method
that can check the existing nested diagnostic context for the presence
of a value.

Added unit tests to test the new NDC.contains() method.

Signed-off-by: Michael Wooten <[email protected]>
@ceki
Copy link
Member

ceki commented Sep 10, 2021

@mwootendev Can you kindly describe what type of problems are better solved by NDC instead of MDC?

@mwootendev
Copy link
Author

@ceki I've actually found the NDC useful for tracing a path through a system. It serves as a good "how did we get here", especially when there are multiple paths that interface with some common services. For instance, if there is a low-level service for looking up a user, there will probably be multiple higher-level parts of the system that utilize it. If each layer pushes its own NDC context you get a fairly accurate picture of how you got there. For instance, the same logging statement in that user service may end up with different NDCs of [ORDERS USER LOOKUP], [USER REGISTRATION LOOKUP], and [USER ACTIVATION LOOKUP] depending on how that service was reached. This is especially useful for log statements that are not errors and do not have a stack trace.

I tend to differentiate MDC as the "what did we get here", like an order number or user ID. Having the context of "how" can often greatly enhance the value of the "what."

@ceki
Copy link
Member

ceki commented Sep 10, 2021

@mwootendev OK, I am still trying to understand. So [ORDERS USER LOOKUP], [USER REGISTRATION LOOKUP], and [USER ACTIVATION LOOKUP] are NDC values?

If so, [ORDERS USER LOOKUP] describes the ORDERS -> USER -> LOOKUP path?

@mwootendev
Copy link
Author

@ceki Yes, that would be correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants