diff options
author | Gabriel Russell <gabriel.russell@mongodb.com> | 2020-02-13 11:49:46 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-13 18:16:35 +0000 |
commit | a84c09a19720b73cedb2e8ef7c5cfeedfa1c9761 (patch) | |
tree | 85ac46cd5f4ea6d5134560bf764fb9e6cf11fe4e /src/mongo/transport/service_state_machine.cpp | |
parent | 6df40e01f7b6899affc4536e7e73a35802cabf98 (diff) | |
download | mongo-a84c09a19720b73cedb2e8ef7c5cfeedfa1c9761.tar.gz |
SERVER-45869 automatically converted structured logging
Diffstat (limited to 'src/mongo/transport/service_state_machine.cpp')
-rw-r--r-- | src/mongo/transport/service_state_machine.cpp | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/src/mongo/transport/service_state_machine.cpp b/src/mongo/transport/service_state_machine.cpp index 4ca997d96ed..041d2fdb715 100644 --- a/src/mongo/transport/service_state_machine.cpp +++ b/src/mongo/transport/service_state_machine.cpp @@ -40,6 +40,7 @@ #include "mongo/db/dbmessage.h" #include "mongo/db/stats/counters.h" #include "mongo/db/traffic_recorder.h" +#include "mongo/logv2/log.h" #include "mongo/rpc/message.h" #include "mongo/rpc/op_msg.h" #include "mongo/transport/message_compressor_manager.h" @@ -375,16 +376,27 @@ void ServiceStateMachine::_sourceCallback(Status status) { transport::ServiceExecutorTaskName::kSSMProcessMessage); } else if (ErrorCodes::isInterruption(status.code()) || ErrorCodes::isNetworkError(status.code())) { - LOG(2) << "Session from " << remote - << " encountered a network error during SourceMessage: " << status; + LOGV2_DEBUG( + 22986, + 2, + "Session from {remote} encountered a network error during SourceMessage: {status}", + "remote"_attr = remote, + "status"_attr = status); _state.store(State::EndSession); } else if (status == TransportLayer::TicketSessionClosedStatus) { // Our session may have been closed internally. - LOG(2) << "Session from " << remote << " was closed internally during SourceMessage"; + LOGV2_DEBUG(22987, + 2, + "Session from {remote} was closed internally during SourceMessage", + "remote"_attr = remote); _state.store(State::EndSession); } else { - log() << "Error receiving request from client: " << status << ". Ending connection from " - << remote << " (connection id: " << _session()->id() << ")"; + LOGV2(22988, + "Error receiving request from client: {status}. Ending connection from {remote} " + "(connection id: {session_id})", + "status"_attr = status, + "remote"_attr = remote, + "session_id"_attr = _session()->id()); _state.store(State::EndSession); } @@ -406,8 +418,12 @@ void ServiceStateMachine::_sinkCallback(Status status) { // Otherwise, update the current state depending on whether we're in exhaust or not, and call // scheduleNext() to unwind the stack and do the next step. if (!status.isOK()) { - log() << "Error sending response to client: " << status << ". Ending connection from " - << _session()->remote() << " (connection id: " << _session()->id() << ")"; + LOGV2(22989, + "Error sending response to client: {status}. Ending connection from {session_remote} " + "(connection id: {session_id})", + "status"_attr = status, + "session_remote"_attr = _session()->remote(), + "session_id"_attr = _session()->id()); _state.store(State::EndSession); return _runNextInGuard(std::move(guard)); } else if (_inExhaust) { @@ -540,7 +556,9 @@ void ServiceStateMachine::_runNextInGuard(ThreadGuard guard) { return; } catch (const DBException& e) { - log() << "DBException handling request, closing client connection: " << redact(e); + LOGV2(22990, + "DBException handling request, closing client connection: {e}", + "e"_attr = redact(e)); } // No need to catch std::exception, as std::terminate will be called when the exception bubbles // to the top of the stack @@ -604,7 +622,9 @@ void ServiceStateMachine::terminateIfTagsDontMatch(transport::Session::TagMask t // If terminateIfTagsDontMatch gets called when we still are 'pending' where no tags have been // set, then skip the termination check. if ((sessionTags & tags) || (sessionTags & transport::Session::kPending)) { - log() << "Skip closing connection for connection # " << _session()->id(); + LOGV2(22991, + "Skip closing connection for connection # {session_id}", + "session_id"_attr = _session()->id()); return; } @@ -622,7 +642,10 @@ ServiceStateMachine::State ServiceStateMachine::state() { void ServiceStateMachine::_terminateAndLogIfError(Status status) { if (!status.isOK()) { - warning(logger::LogComponent::kExecutor) << "Terminating session due to error: " << status; + LOGV2_WARNING_OPTIONS(22993, + {logComponentV1toV2(logger::LogComponent::kExecutor)}, + "Terminating session due to error: {status}", + "status"_attr = status); terminate(); } } @@ -642,7 +665,9 @@ void ServiceStateMachine::_cleanupExhaustResources() noexcept try { _sep->handleRequest(opCtx.get(), makeKillCursorsMessage(cursorId)); } } catch (const DBException& e) { - log() << "Error cleaning up resources for exhaust requests: " << e.toStatus(); + LOGV2(22992, + "Error cleaning up resources for exhaust requests: {e_toStatus}", + "e_toStatus"_attr = e.toStatus()); } void ServiceStateMachine::_cleanupSession(ThreadGuard guard) { |