-
Notifications
You must be signed in to change notification settings - Fork 454
CDRIVER-4487 server selection logging #1821
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
Conversation
from commit ccb981601f3400784d187bb583b5c3d1dac7a963 in the specifications repository
The other server_selection tests don't use the unified format.
This has an immense amount of plumbing relative to the actual functionality, due to the additional context we need about the operation that prompted server selection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[...] the logs need information about both low-level server selection progress and high-level operation context. I considered alternatives, including a thread-local stack allowing functions to append log items to logs issued by a callee. This explicit context structure was chosen in order to optimize for clarity at the expense of some verbosity.
I support this design decision.
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A minor non-blocking suggestion; otherwise, LGTM! 👍
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Thanks for the reviews! |
#1826) This PR is a follow-up for #1795, #1821, and #1816. The new internal string and json APIs are used to implement missing functionality and tests for the structured logging subsystem. * Adds public APIs for the max_document_length within a mongoc_structured_log_opts_t. * Addresses the remainder of CDRIVER-4485: JSON documents within structured log messages are truncated correctly according to the rules set out in the Logging specification. * Addresses the remainder of CDRIVER-4486 by implementing prose tests. * Addresses CDRIVER-4814. Command or payload data beyond the truncation limit no longer degrades logging performance. (New serializer for command-with-payload) * Unified tests use the suggested max document length of 10000 from the spec * Replace atomic counter with atomic flag for environment error guards * Tests for environment defaults now skip if relevant variables are set externally
This patch addresses CDRIVER-4487: structured log messages for server selection.
Note:
Contents:
Much of the noise in here is related to that new mongoc_ss_log_context_t, required because the logs need information about both low-level server selection progress and high-level operation context. I considered alternatives, including a thread-local stack allowing functions to append log items to logs issued by a callee. This explicit context structure was chosen in order to optimize for clarity at the expense of some verbosity.
The mongoc_ss_log_context_t provides the "operation" name, defined in the spec as "The name of the operation for which a server is being selected. When server selection is being performed to select a server for a command, this MUST be the command name." In case operations are never expected to generate user-visible logs, like tests, the operation name is still required but it may be arbitrary. I considered making the entire mongoc_ss_log_context_t optional, but retained it as a required parameter to reduce the potential for omissions in non-testing paths. Some operations are not commands but nevertheless will be user-visible (mongoc_client_session_start_transaction) and in this case I chose the libmongoc API name as the "operation".
We might consider C99 compound literals for the mongoc_ss_log_context_t instances. So far I've opted not to, for simplicity and in order to keep the parameter list lengths under control.