From 0f7625b5cdbc24ed0fce1e168059118cb025d869 Mon Sep 17 00:00:00 2001 From: Gabriel Russell Date: Thu, 20 Feb 2020 16:05:48 -0500 Subject: SERVER-45567 removing util/log.h where I can o converting some log lines that were missed o fixing some missing includes create mode 100644 src/mongo/transport/ismaster_metrics.cpp --- src/mongo/transport/baton_asio_linux.h | 4 +- src/mongo/transport/ismaster_metrics.cpp | 97 ++++++++++++++++++++++ src/mongo/transport/message_compressor_manager.cpp | 1 - .../transport/message_compressor_manager_test.cpp | 1 - src/mongo/transport/service_entry_point_impl.cpp | 1 - src/mongo/transport/service_entry_point_utils.cpp | 1 - src/mongo/transport/service_executor_adaptive.cpp | 1 - .../transport/service_executor_adaptive_test.cpp | 1 - src/mongo/transport/service_executor_reserved.cpp | 1 - .../transport/service_executor_synchronous.cpp | 1 - src/mongo/transport/service_executor_test.cpp | 1 - src/mongo/transport/service_state_machine.cpp | 1 - src/mongo/transport/service_state_machine_test.cpp | 1 - src/mongo/transport/session_asio.h | 13 ++- src/mongo/transport/transport_layer_asio.cpp | 1 - .../transport_layer_asio_integration_test.cpp | 1 - src/mongo/transport/transport_layer_asio_test.cpp | 1 - 17 files changed, 109 insertions(+), 19 deletions(-) create mode 100644 src/mongo/transport/ismaster_metrics.cpp (limited to 'src/mongo/transport') diff --git a/src/mongo/transport/baton_asio_linux.h b/src/mongo/transport/baton_asio_linux.h index d036a8a278b..6c102553599 100644 --- a/src/mongo/transport/baton_asio_linux.h +++ b/src/mongo/transport/baton_asio_linux.h @@ -328,7 +328,9 @@ public: // If poll failed, it better be in EINTR if (rval < 0 && errno != EINTR) { - severe() << "error in poll: " << errnoWithDescription(errno); + LOGV2_FATAL(23921, + "error in poll: {errnoWithDescription_errno}", + "errnoWithDescription_errno"_attr = errnoWithDescription(errno)); fassertFailed(50834); } } diff --git a/src/mongo/transport/ismaster_metrics.cpp b/src/mongo/transport/ismaster_metrics.cpp new file mode 100644 index 00000000000..dc1a2b68dda --- /dev/null +++ b/src/mongo/transport/ismaster_metrics.cpp @@ -0,0 +1,97 @@ +/** + * Copyright (C) 2020-present MongoDB, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * . + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the Server Side Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kNetwork +#include "mongo/transport/ismaster_metrics.h" + +namespace mongo { +namespace { +const auto IsMasterMetricsDecoration = ServiceContext::declareDecoration(); +const auto InExhaustIsMasterDecoration = transport::Session::declareDecoration(); +} // namespace + +IsMasterMetrics* IsMasterMetrics::get(ServiceContext* service) { + return &IsMasterMetricsDecoration(service); +} + +IsMasterMetrics* IsMasterMetrics::get(OperationContext* opCtx) { + return get(opCtx->getServiceContext()); +} + +size_t IsMasterMetrics::getNumExhaustIsMaster() const { + return _exhaustIsMasterConnections.load(); +} + +void IsMasterMetrics::incrementNumExhaustIsMaster() { + _exhaustIsMasterConnections.fetchAndAdd(1); +} + +void IsMasterMetrics::decrementNumExhaustIsMaster() { + _exhaustIsMasterConnections.fetchAndSubtract(1); +} + +size_t IsMasterMetrics::getNumAwaitingTopologyChanges() const { + return _connectionsAwaitingTopologyChanges.load(); +} + +void IsMasterMetrics::incrementNumAwaitingTopologyChanges() { + _connectionsAwaitingTopologyChanges.fetchAndAdd(1); +} + +void IsMasterMetrics::decrementNumAwaitingTopologyChanges() { + _connectionsAwaitingTopologyChanges.fetchAndSubtract(1); +} + +void IsMasterMetrics::resetNumAwaitingTopologyChanges() { + _connectionsAwaitingTopologyChanges.store(0); +} + +InExhaustIsMaster* InExhaustIsMaster::get(transport::Session* session) { + return &InExhaustIsMasterDecoration(session); +} + +InExhaustIsMaster::~InExhaustIsMaster() { + if (_inExhaustIsMaster) { + IsMasterMetrics::get(getGlobalServiceContext())->decrementNumExhaustIsMaster(); + } +} + +bool InExhaustIsMaster::getInExhaustIsMaster() const { + return _inExhaustIsMaster; +} + +void InExhaustIsMaster::setInExhaustIsMaster(bool inExhaustIsMaster) { + if (!_inExhaustIsMaster && inExhaustIsMaster) { + IsMasterMetrics::get(getGlobalServiceContext())->incrementNumExhaustIsMaster(); + } else if (_inExhaustIsMaster && !inExhaustIsMaster) { + IsMasterMetrics::get(getGlobalServiceContext())->decrementNumExhaustIsMaster(); + } + _inExhaustIsMaster = inExhaustIsMaster; +} + +} // namespace mongo \ No newline at end of file diff --git a/src/mongo/transport/message_compressor_manager.cpp b/src/mongo/transport/message_compressor_manager.cpp index a0bbf922112..1214149832e 100644 --- a/src/mongo/transport/message_compressor_manager.cpp +++ b/src/mongo/transport/message_compressor_manager.cpp @@ -41,7 +41,6 @@ #include "mongo/rpc/message.h" #include "mongo/transport/message_compressor_registry.h" #include "mongo/transport/session.h" -#include "mongo/util/log.h" namespace mongo { namespace { diff --git a/src/mongo/transport/message_compressor_manager_test.cpp b/src/mongo/transport/message_compressor_manager_test.cpp index c5c5f05f8a0..cc3b4bafb74 100644 --- a/src/mongo/transport/message_compressor_manager_test.cpp +++ b/src/mongo/transport/message_compressor_manager_test.cpp @@ -44,7 +44,6 @@ #include "mongo/transport/message_compressor_zlib.h" #include "mongo/transport/message_compressor_zstd.h" #include "mongo/unittest/unittest.h" -#include "mongo/util/log.h" namespace mongo { namespace { diff --git a/src/mongo/transport/service_entry_point_impl.cpp b/src/mongo/transport/service_entry_point_impl.cpp index 9381e1e7b95..b219240e6fa 100644 --- a/src/mongo/transport/service_entry_point_impl.cpp +++ b/src/mongo/transport/service_entry_point_impl.cpp @@ -40,7 +40,6 @@ #include "mongo/logv2/log.h" #include "mongo/transport/service_state_machine.h" #include "mongo/transport/session.h" -#include "mongo/util/log.h" #include "mongo/util/processinfo.h" #include "mongo/util/scopeguard.h" diff --git a/src/mongo/transport/service_entry_point_utils.cpp b/src/mongo/transport/service_entry_point_utils.cpp index ea273c7564e..f4e894e1168 100644 --- a/src/mongo/transport/service_entry_point_utils.cpp +++ b/src/mongo/transport/service_entry_point_utils.cpp @@ -40,7 +40,6 @@ #include "mongo/stdx/thread.h" #include "mongo/util/assert_util.h" #include "mongo/util/debug_util.h" -#include "mongo/util/log.h" #if !defined(_WIN32) #include diff --git a/src/mongo/transport/service_executor_adaptive.cpp b/src/mongo/transport/service_executor_adaptive.cpp index b43635df36c..6b6bb17885e 100644 --- a/src/mongo/transport/service_executor_adaptive.cpp +++ b/src/mongo/transport/service_executor_adaptive.cpp @@ -42,7 +42,6 @@ #include "mongo/transport/service_executor_task_names.h" #include "mongo/util/concurrency/thread_name.h" #include "mongo/util/duration.h" -#include "mongo/util/log.h" #include "mongo/util/processinfo.h" #include "mongo/util/scopeguard.h" #include "mongo/util/str.h" diff --git a/src/mongo/transport/service_executor_adaptive_test.cpp b/src/mongo/transport/service_executor_adaptive_test.cpp index d2bce821868..52cb1b4f85f 100644 --- a/src/mongo/transport/service_executor_adaptive_test.cpp +++ b/src/mongo/transport/service_executor_adaptive_test.cpp @@ -37,7 +37,6 @@ #include "mongo/logv2/log.h" #include "mongo/transport/service_executor_adaptive.h" #include "mongo/unittest/unittest.h" -#include "mongo/util/log.h" #include "mongo/util/scopeguard.h" #include diff --git a/src/mongo/transport/service_executor_reserved.cpp b/src/mongo/transport/service_executor_reserved.cpp index af114738ce7..fffd3d5a935 100644 --- a/src/mongo/transport/service_executor_reserved.cpp +++ b/src/mongo/transport/service_executor_reserved.cpp @@ -38,7 +38,6 @@ #include "mongo/transport/service_entry_point_utils.h" #include "mongo/transport/service_executor_gen.h" #include "mongo/transport/service_executor_task_names.h" -#include "mongo/util/log.h" #include "mongo/util/processinfo.h" namespace mongo { diff --git a/src/mongo/transport/service_executor_synchronous.cpp b/src/mongo/transport/service_executor_synchronous.cpp index 91cdf907b60..f0c991d5564 100644 --- a/src/mongo/transport/service_executor_synchronous.cpp +++ b/src/mongo/transport/service_executor_synchronous.cpp @@ -38,7 +38,6 @@ #include "mongo/transport/service_entry_point_utils.h" #include "mongo/transport/service_executor_gen.h" #include "mongo/transport/service_executor_task_names.h" -#include "mongo/util/log.h" #include "mongo/util/processinfo.h" namespace mongo { diff --git a/src/mongo/transport/service_executor_test.cpp b/src/mongo/transport/service_executor_test.cpp index af4e8ca7b49..3284ce1304a 100644 --- a/src/mongo/transport/service_executor_test.cpp +++ b/src/mongo/transport/service_executor_test.cpp @@ -39,7 +39,6 @@ #include "mongo/transport/service_executor_synchronous.h" #include "mongo/transport/service_executor_task_names.h" #include "mongo/unittest/unittest.h" -#include "mongo/util/log.h" #include "mongo/util/scopeguard.h" #include diff --git a/src/mongo/transport/service_state_machine.cpp b/src/mongo/transport/service_state_machine.cpp index 041d2fdb715..7e33191b98d 100644 --- a/src/mongo/transport/service_state_machine.cpp +++ b/src/mongo/transport/service_state_machine.cpp @@ -53,7 +53,6 @@ #include "mongo/util/concurrency/thread_name.h" #include "mongo/util/debug_util.h" #include "mongo/util/exit.h" -#include "mongo/util/log.h" #include "mongo/util/net/socket_exception.h" #include "mongo/util/quick_exit.h" diff --git a/src/mongo/transport/service_state_machine_test.cpp b/src/mongo/transport/service_state_machine_test.cpp index 3373f2ece2a..0b9d4eac5f3 100644 --- a/src/mongo/transport/service_state_machine_test.cpp +++ b/src/mongo/transport/service_state_machine_test.cpp @@ -50,7 +50,6 @@ #include "mongo/unittest/unittest.h" #include "mongo/util/assert_util.h" #include "mongo/util/clock_source_mock.h" -#include "mongo/util/log.h" #include "mongo/util/tick_source_mock.h" namespace mongo { diff --git a/src/mongo/transport/session_asio.h b/src/mongo/transport/session_asio.h index a7c9512b4b2..6efbd104b0a 100644 --- a/src/mongo/transport/session_asio.h +++ b/src/mongo/transport/session_asio.h @@ -145,7 +145,9 @@ public: std::error_code ec; getSocket().shutdown(GenericSocket::shutdown_both, ec); if ((ec) && (ec != asio::error::not_connected)) { - error() << "Error shutting down socket: " << ec.message(); + LOGV2_ERROR(23841, + "Error shutting down socket: {ec_message}", + "ec_message"_attr = ec.message()); } } } @@ -385,7 +387,7 @@ private: sb << "recv(): message msgLen " << msgLen << " is invalid. " << "Min " << kHeaderSize << " Max: " << MaxMessageSizeBytes; const auto str = sb.str(); - LOG(0) << str; + LOGV2(23837, "{str}", "str"_attr = str); return Future::makeReady(Status(ErrorCodes::ProtocolError, str)); } @@ -660,8 +662,11 @@ private: } else { if (!sslGlobalParams.disableNonSSLConnectionLogging && _tl->_sslMode() == SSLParams::SSLMode_preferSSL) { - LOG(0) << "SSL mode is set to 'preferred' and connection " << id() << " to " - << remote() << " is not using SSL."; + LOGV2(23838, + "SSL mode is set to 'preferred' and connection {id} to {remote} is not using " + "SSL.", + "id"_attr = id(), + "remote"_attr = remote()); } return Future::makeReady(false); } diff --git a/src/mongo/transport/transport_layer_asio.cpp b/src/mongo/transport/transport_layer_asio.cpp index 6c85e7ee8f5..a22ffdd7e2e 100644 --- a/src/mongo/transport/transport_layer_asio.cpp +++ b/src/mongo/transport/transport_layer_asio.cpp @@ -51,7 +51,6 @@ #include "mongo/transport/service_entry_point.h" #include "mongo/transport/transport_options_gen.h" #include "mongo/util/hierarchical_acquisition.h" -#include "mongo/util/log.h" #include "mongo/util/net/hostandport.h" #include "mongo/util/net/sockaddr.h" #include "mongo/util/net/ssl_manager.h" diff --git a/src/mongo/transport/transport_layer_asio_integration_test.cpp b/src/mongo/transport/transport_layer_asio_integration_test.cpp index ca8211af7b0..ec7981b615a 100644 --- a/src/mongo/transport/transport_layer_asio_integration_test.cpp +++ b/src/mongo/transport/transport_layer_asio_integration_test.cpp @@ -45,7 +45,6 @@ #include "mongo/unittest/integration_test.h" #include "mongo/unittest/unittest.h" #include "mongo/util/fail_point.h" -#include "mongo/util/log.h" #include "asio.hpp" diff --git a/src/mongo/transport/transport_layer_asio_test.cpp b/src/mongo/transport/transport_layer_asio_test.cpp index 9e23beb33fd..1cc7b04f53d 100644 --- a/src/mongo/transport/transport_layer_asio_test.cpp +++ b/src/mongo/transport/transport_layer_asio_test.cpp @@ -38,7 +38,6 @@ #include "mongo/transport/service_entry_point.h" #include "mongo/unittest/unittest.h" #include "mongo/util/assert_util.h" -#include "mongo/util/log.h" #include "mongo/util/net/sock.h" #include "asio.hpp" -- cgit v1.2.1