summaryrefslogtreecommitdiff
path: root/src/mongo/transport
diff options
context:
space:
mode:
authorJason Carey <jcarey@argv.me>2019-01-25 12:54:45 -0500
committerJason Carey <jcarey@argv.me>2019-02-04 14:49:52 -0500
commit8c157f05ea25f13595734b03b3c5b55cd16d7cd6 (patch)
tree27cbb691e3cf0dbc014be24eccbbae6f4f269280 /src/mongo/transport
parent1b1cf52e94c49ca4c6d8ba693e949c2b655e74b5 (diff)
downloadmongo-8c157f05ea25f13595734b03b3c5b55cd16d7cd6.tar.gz
SERVER-37823 Server Side Traffic Capture
Adds support for special commands which dump wire protocol traffic to disk.
Diffstat (limited to 'src/mongo/transport')
-rw-r--r--src/mongo/transport/SConscript1
-rw-r--r--src/mongo/transport/service_state_machine.cpp8
2 files changed, 9 insertions, 0 deletions
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 {