-
Notifications
You must be signed in to change notification settings - Fork 454
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
CDRIVER-3775 mongoc_structured_log #1795
Open
mdbmes
wants to merge
82
commits into
mongodb:master
Choose a base branch
from
mdbmes:CDRIVER-3775
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
And that's why you shouldn't trust your IDE to correctly add include statements
…alization The command-logging-and-monitoring tests use the serverDescriptionChanged event. In implementing a new event type, it made sense to refactor the implementation for event storage and serialization. The serialization from observeEvents and storeEventsAsEntities unnecessarily diverged into a late-serialization and an early-serialization style. This decides on early serialization, opting to build a canonical bson representation as soon as possible and extract fields from it later as necessary for comparisons. This has fewer opportunities for optimization in some cases, but here the extra simplicity is a good match for the test runner environment.
These aren't long lived strings, they might be part of a temporary bson document like in createEntities.
Use a separate atomic flag instead of trying to make an atomic func pointer, to avoid non-portable hacks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a revival of an old pull request by @alcaeus to add structured logging to the C driver. (#684)
One unanswered question from that PR remains open: Should we integrate structured logging more closely with unstructured logging? I've opted so far to continue with the previous PR's approach and keep the subsystems fully separate, but this may still be up for debate.
The previous PR defined a global log mutex. I've continued that design, but this is the time to consider carefully if we want a big logging lock. (It's likely not a big deal for perf, but any contention here will be a problem for multi-threaded apps and this is the time to get the design right.)
The public API is still similar to the one @alcaeus designed, with minor modifications to support efficient log level filtering and to allow necessary copies of message data to be owned and retained by the callback if necessary, potentially avoiding additional copies in cases where apps would like to store log messages. (e.g. in our own unified test runner, or in any application that handles log messages asynchronously.)
The internal API has been redesigned. The previous PR required each new type of log message to have functions and structures associated with that specific message format. In this redesign, I've split the single callback into a variable length list of callbacks, and added a set of macros to make it straightforward to build these function tables. This has some nice properties:
Here's a sample invocation:
The macros are explained by doc comments in
mongoc-structured-log-private.h
.This PR includes updated unified tests from the command logging and monitoring spec, which now pass. This required several other changes to the unified test runner.
Contents:
observeLogMessages
,waitForEvent
,$$matchAsDocument
,$$matchAsRoot
serverDescriptionChangedEvent
to the unified test runner and unify its two event serialization systemsoid()
values