summaryrefslogtreecommitdiff
path: root/src/mongo/db/server_transactions_metrics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/server_transactions_metrics.cpp')
-rw-r--r--src/mongo/db/server_transactions_metrics.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mongo/db/server_transactions_metrics.cpp b/src/mongo/db/server_transactions_metrics.cpp
index a51ecc0345c..411e898dbe3 100644
--- a/src/mongo/db/server_transactions_metrics.cpp
+++ b/src/mongo/db/server_transactions_metrics.cpp
@@ -161,7 +161,7 @@ void ServerTransactionsMetrics::updateLastTransaction(size_t operationCount,
_lastCommittedTransaction->setWriteConcern(std::move(writeConcern));
}
-void ServerTransactionsMetrics::updateStats(TransactionsStats* stats) {
+void ServerTransactionsMetrics::updateStats(TransactionsStats* stats, bool includeLastCommitted) {
stats->setCurrentActive(_currentActive.load());
stats->setCurrentInactive(_currentInactive.load());
stats->setCurrentOpen(_currentOpen.load());
@@ -174,7 +174,7 @@ void ServerTransactionsMetrics::updateStats(TransactionsStats* stats) {
stats->setCurrentPrepared(_currentPrepared.load());
stdx::lock_guard<Latch> lg(_mutex);
- if (_lastCommittedTransaction) {
+ if (_lastCommittedTransaction && includeLastCommitted) {
stats->setLastCommittedTransaction(*_lastCommittedTransaction);
}
}
@@ -194,12 +194,17 @@ public:
const BSONElement& configElement) const override {
TransactionsStats stats;
+ bool includeLastCommitted = true;
+ if (configElement.type() == BSONType::Object) {
+ includeLastCommitted = configElement.Obj()["includeLastCommitted"].trueValue();
+ }
+
// Retryable writes and multi-document transactions metrics are both included in the same
// serverStatus section because both utilize similar internal machinery for tracking their
// lifecycle within a session. Both are assigned transaction numbers, and so both are often
// referred to as “transactions”.
RetryableWritesStats::get(opCtx)->updateStats(&stats);
- ServerTransactionsMetrics::get(opCtx)->updateStats(&stats);
+ ServerTransactionsMetrics::get(opCtx)->updateStats(&stats, includeLastCommitted);
return stats.toBSON();
}