From 8c157f05ea25f13595734b03b3c5b55cd16d7cd6 Mon Sep 17 00:00:00 2001 From: Jason Carey Date: Fri, 25 Jan 2019 12:54:45 -0500 Subject: SERVER-37823 Server Side Traffic Capture Adds support for special commands which dump wire protocol traffic to disk. --- src/mongo/transport/SConscript | 1 + src/mongo/transport/service_state_machine.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) (limited to 'src/mongo/transport') diff --git a/src/mongo/transport/SConscript b/src/mongo/transport/SConscript index 6ca36ed7916..43032ccb1b7 100644 --- a/src/mongo/transport/SConscript +++ b/src/mongo/transport/SConscript @@ -174,6 +174,7 @@ env.Library( 'transport_layer_common', ], LIBDEPS_PRIVATE=[ + '$BUILD_DIR/mongo/db/traffic_recorder', '$BUILD_DIR/mongo/transport/message_compressor', ], ) diff --git a/src/mongo/transport/service_state_machine.cpp b/src/mongo/transport/service_state_machine.cpp index 6ecf18384d9..09d3a8b00f0 100644 --- a/src/mongo/transport/service_state_machine.cpp +++ b/src/mongo/transport/service_state_machine.cpp @@ -38,6 +38,7 @@ #include "mongo/db/client.h" #include "mongo/db/dbmessage.h" #include "mongo/db/stats/counters.h" +#include "mongo/db/traffic_recorder.h" #include "mongo/rpc/message.h" #include "mongo/rpc/op_msg.h" #include "mongo/stdx/memory.h" @@ -423,6 +424,9 @@ void ServiceStateMachine::_sinkCallback(Status status) { void ServiceStateMachine::_processMessage(ThreadGuard guard) { invariant(!_inMessage.empty()); + TrafficRecorder::get(_serviceContext) + .observe(_sessionHandle, _serviceContext->getPreciseClockSource()->now(), _inMessage); + auto& compressorMgr = MessageCompressorManager::forSession(_session()); _compressorId = boost::none; @@ -472,6 +476,10 @@ void ServiceStateMachine::_processMessage(ThreadGuard guard) { uassertStatusOK(swm.getStatus()); toSink = swm.getValue(); } + + TrafficRecorder::get(_serviceContext) + .observe(_sessionHandle, _serviceContext->getPreciseClockSource()->now(), toSink); + _sinkMessage(std::move(guard), std::move(toSink)); } else { -- cgit v1.2.1