-
Notifications
You must be signed in to change notification settings - Fork 543
CXX-2284 Append platform data to handshake #915
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
Codecov Report
@@ Coverage Diff @@
## master #915 +/- ##
==========================================
- Coverage 91.34% 91.28% -0.06%
==========================================
Files 384 384
Lines 23463 23312 -151
==========================================
- Hits 21432 21281 -151
Misses 2031 2031
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
LGTM, but with one possible improvement for handling MSVC.
src/mongocxx/instance.cpp
Outdated
// argument for consistency with the driver_name, and driver_version. | ||
std::stringstream platform; | ||
platform << "CXX=" << MONGOCXX_COMPILER_ID << " " << MONGOCXX_COMPILER_VERSION << " " | ||
<< "stdcxx=" << __cplusplus << " / "; |
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.
Possible tweak: The __cplusplus
macro is a lie for MSVC (by default). It would be useful to add a field for _MSVC_LANG
, which tells the true value of /std:
regardless of the compiler conformance options.
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.
Good point. The installation documentation suggests compiling with /Zc:__cplusplus
for C++17. But users may be building with older versions.
Updated to prefer _MSVC_LANG
. Filed CXX-2629 to consider setting /Zc:__cplusplus
as the default when building with MSVC.
Summary
Background & Motivation
The Handshake is the first command performed upon establishing the connection to MongoDB.
The Handshake includes metadata in the
client
field, so a client can identify itself. The Handshake metadata appears inmongod
logs.Here is a formatted log from
mongod
from a C++ driver connection before this change:The
platform
only includes information from the C driver. After this change, theplatform
field includes the C++ compiler ID and version in the prefix:cmake is used to determine the compiler ID and version. The C driver uses macros to determine the compiler ID and version, and falls back to values set by cmake. I see no reason to use macros instead of cmake to determine the compiler type and version for the C++ driver. The C driver may have preferred macros for consistent values between cmake and the now removed autotools build. But I am not sure.
A patch build was run to determine all
MONGOCXX_COMPILER_ID
andMONGOCXX_COMPILER_VERSION
for tested variants. The following table is the unique values: