diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2020-06-05 15:13:14 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-06-05 20:04:47 +0000 |
commit | 84033d0077d507491a6a80c2e1140bf6fd4055dc (patch) | |
tree | 4bb6c0b0b39ba8c402320a49ffa14e26ab44feca /src/mongo/db | |
parent | 274b30c62675eb3f04f22e90f76f7891041d9147 (diff) | |
download | mongo-84033d0077d507491a6a80c2e1140bf6fd4055dc.tar.gz |
SERVER-48393 Exclude awaitable isMaster from serverStatus latency metrics
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/operation_context.h | 15 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_info.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/stats/top.cpp | 3 |
3 files changed, 21 insertions, 0 deletions
diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h index c5116e805b2..46626d843b7 100644 --- a/src/mongo/db/operation_context.h +++ b/src/mongo/db/operation_context.h @@ -267,6 +267,20 @@ public: return _writesAreReplicated; } + /** + * Returns true if operations' durations should be added to serverStatus latency metrics. + */ + bool shouldIncrementLatencyStats() const { + return _shouldIncrementLatencyStats; + } + + /** + * Sets the shouldIncrementLatencyStats flag. + */ + void setShouldIncrementLatencyStats(bool shouldIncrementLatencyStats) { + _shouldIncrementLatencyStats = shouldIncrementLatencyStats; + } + void markKillOnClientDisconnect(); /** @@ -568,6 +582,7 @@ private: Timer _elapsedTime; bool _writesAreReplicated = true; + bool _shouldIncrementLatencyStats = true; bool _shouldParticipateInFlowControl = true; bool _inMultiDocumentTransaction = false; bool _isStartingMultiDocumentTransaction = false; diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp index b4eaf053b60..d9f0d7d6602 100644 --- a/src/mongo/db/repl/replication_info.cpp +++ b/src/mongo/db/repl/replication_info.cpp @@ -460,6 +460,9 @@ public: uassert(31373, "maxAwaitTimeMS must be a non-negative integer", *maxAwaitTimeMS >= 0); LOGV2_DEBUG(23904, 3, "Using maxAwaitTimeMS for awaitable isMaster protocol."); + + // Awaitable isMaster commands have high latency by design. + opCtx->setShouldIncrementLatencyStats(false); } else { uassert(31368, (topologyVersionElement diff --git a/src/mongo/db/stats/top.cpp b/src/mongo/db/stats/top.cpp index e445515cf4b..1674fe394d6 100644 --- a/src/mongo/db/stats/top.cpp +++ b/src/mongo/db/stats/top.cpp @@ -200,6 +200,9 @@ void Top::appendLatencyStats(const NamespaceString& nss, void Top::incrementGlobalLatencyStats(OperationContext* opCtx, uint64_t latency, Command::ReadWriteType readWriteType) { + if (!opCtx->shouldIncrementLatencyStats()) + return; + stdx::lock_guard<SimpleMutex> guard(_lock); _incrementHistogram(opCtx, latency, &_globalHistogramStats, readWriteType); } |