mirror of https://github.com/mongodb/mongo
SERVER-112103: Record start time only on start (#42346)
GitOrigin-RevId: 9d290e656ae8b700fae52b5bdd1ce40e0e76a0d4
This commit is contained in:
parent
99c7a90c36
commit
4ff409eee6
|
|
@ -92,22 +92,22 @@ void appendPacketHeader(DataBuilder& db, const TrafficRecordingPacket& packet) {
|
|||
|
||||
TrafficRecorder::Recording::Recording(const StartTrafficRecording& options, TickSource* tickSource)
|
||||
: _path(_getPath(std::string{options.getDestination()})),
|
||||
_maxLogSize(options.getMaxFileSize()) {
|
||||
_maxLogSize(options.getMaxFileSize()),
|
||||
_tickSource(tickSource) {
|
||||
|
||||
MultiProducerSingleConsumerQueue<TrafficRecordingPacket, CostFunction>::Options queueOptions;
|
||||
queueOptions.maxQueueDepth = options.getMaxMemUsage();
|
||||
_pcqPipe =
|
||||
MultiProducerSingleConsumerQueue<TrafficRecordingPacket, CostFunction>::Pipe(queueOptions);
|
||||
|
||||
_trafficStats.setRunning(true);
|
||||
_trafficStats.setBufferSize(options.getMaxMemUsage());
|
||||
_trafficStats.setRecordingDir(_path);
|
||||
_trafficStats.setMaxFileSize(_maxLogSize);
|
||||
|
||||
startTime.store(tickSource->ticksTo<Microseconds>(tickSource->getTicks()));
|
||||
}
|
||||
|
||||
void TrafficRecorder::Recording::run() {
|
||||
void TrafficRecorder::Recording::start() {
|
||||
_trafficStats.setRunning(true);
|
||||
startTime.store(_tickSource->ticksTo<Microseconds>(_tickSource->getTicks()));
|
||||
_thread = stdx::thread([consumer = std::move(_pcqPipe.consumer), this] {
|
||||
if (!boost::filesystem::is_directory(boost::filesystem::absolute(_path))) {
|
||||
boost::filesystem::create_directory(boost::filesystem::absolute(_path));
|
||||
|
|
@ -302,7 +302,7 @@ void TrafficRecorder::start(const StartTrafficRecording& options, ServiceContext
|
|||
uassert(ErrorCodes::BadValue, "Traffic recording already active", !*rec);
|
||||
*rec = _makeRecording(options, svcCtx->getTickSource());
|
||||
|
||||
(*rec)->run();
|
||||
(*rec)->start();
|
||||
}
|
||||
|
||||
_shouldRecord.store(true);
|
||||
|
|
@ -436,7 +436,7 @@ TrafficRecorderForTest::RecordingForTest::getPcqPipe() {
|
|||
return _pcqPipe;
|
||||
}
|
||||
|
||||
void TrafficRecorderForTest::RecordingForTest::run() {
|
||||
void TrafficRecorderForTest::RecordingForTest::start() {
|
||||
// No-op for tests
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ protected:
|
|||
Recording(const StartTrafficRecording& options, TickSource* tickSource);
|
||||
virtual ~Recording() = default;
|
||||
|
||||
virtual void run();
|
||||
virtual void start();
|
||||
virtual Status shutdown();
|
||||
|
||||
/**
|
||||
|
|
@ -154,6 +154,8 @@ protected:
|
|||
const std::string _path;
|
||||
const int64_t _maxLogSize;
|
||||
|
||||
TickSource* _tickSource;
|
||||
|
||||
stdx::thread _thread;
|
||||
|
||||
stdx::mutex _mutex;
|
||||
|
|
@ -189,7 +191,7 @@ public:
|
|||
TrafficRecorder::Recording::CostFunction>::Pipe&
|
||||
getPcqPipe();
|
||||
|
||||
void run() override;
|
||||
void start() override;
|
||||
|
||||
Status shutdown() override;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue