diff options
author | Amirsaman Memaripour <amirsaman.memaripour@mongodb.com> | 2021-02-08 17:08:48 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-02-09 01:16:35 +0000 |
commit | 4d72470b050c348ad5fae2cf46c01e09943f5070 (patch) | |
tree | 46b2365867a9e1d19a8d2162cab4e3e196c8d6b5 /src | |
parent | f9cc115ef03eef4e8a018585c73d0c86751217f7 (diff) | |
download | mongo-4d72470b050c348ad5fae2cf46c01e09943f5070.tar.gz |
SERVER-53842 Count the number of resharding attempts in resharding metrics
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/s/resharding/resharding_metrics.cpp | 9 | ||||
-rw-r--r-- | src/mongo/db/s/resharding/resharding_metrics.h | 5 | ||||
-rw-r--r-- | src/mongo/db/s/resharding/resharding_metrics_test.cpp | 11 |
3 files changed, 17 insertions, 8 deletions
diff --git a/src/mongo/db/s/resharding/resharding_metrics.cpp b/src/mongo/db/s/resharding/resharding_metrics.cpp index f8f21814d23..5fabcb00e9e 100644 --- a/src/mongo/db/s/resharding/resharding_metrics.cpp +++ b/src/mongo/db/s/resharding/resharding_metrics.cpp @@ -39,9 +39,10 @@ namespace { constexpr auto kAnotherOperationInProgress = "Another operation is in progress"; constexpr auto kNoOperationInProgress = "No operation is in progress"; -constexpr auto kSuccessfulOps = "successfulOperations"; -constexpr auto kFailedOps = "failedOperations"; -constexpr auto kCanceledOps = "canceledOperations"; +constexpr auto kTotalOps = "countReshardingOperations"; +constexpr auto kSuccessfulOps = "countReshardingSuccessful"; +constexpr auto kFailedOps = "countReshardingFailures"; +constexpr auto kCanceledOps = "countReshardingCanceled"; constexpr auto kOpTimeElapsed = "totalOperationTimeElapsed"; constexpr auto kOpTimeRemaining = "remainingOperationTimeEstimated"; constexpr auto kDocumentsToCopy = "approxDocumentsToCopy"; @@ -79,6 +80,7 @@ void ReshardingMetrics::onStart() noexcept { // Create a new operation and record the time it started. _currentOp.emplace(_svcCtx->getFastClockSource()); _currentOp->runningOperation.start(); + _started++; } void ReshardingMetrics::onCompletion(ReshardingMetrics::OperationStatus status) noexcept { @@ -310,6 +312,7 @@ void ReshardingMetrics::serialize(BSONObjBuilder* bob, ReporterOptions::Role rol stdx::lock_guard<Latch> lk(_mutex); if (role == ReporterOptions::Role::kAll) { + bob->append(kTotalOps, _started); bob->append(kSuccessfulOps, _succeeded); bob->append(kFailedOps, _failed); bob->append(kCanceledOps, _canceled); diff --git a/src/mongo/db/s/resharding/resharding_metrics.h b/src/mongo/db/s/resharding/resharding_metrics.h index 2f0ce2fbc16..2f5f1190f11 100644 --- a/src/mongo/db/s/resharding/resharding_metrics.h +++ b/src/mongo/db/s/resharding/resharding_metrics.h @@ -105,8 +105,9 @@ private: mutable Mutex _mutex = MONGO_MAKE_LATCH("ReshardingMetrics::_mutex"); - // The following maintain the number of operations that succeeded, failed with an unrecoverable - // error, and canceled by the user, respectively. + // The following maintain the number of resharding operations that have started, succeeded, + // failed with an unrecoverable error, and canceled by the user, respectively. + int64_t _started = 0; int64_t _succeeded = 0; int64_t _failed = 0; int64_t _canceled = 0; diff --git a/src/mongo/db/s/resharding/resharding_metrics_test.cpp b/src/mongo/db/s/resharding/resharding_metrics_test.cpp index 909634240f8..798e7c2a103 100644 --- a/src/mongo/db/s/resharding/resharding_metrics_test.cpp +++ b/src/mongo/db/s/resharding/resharding_metrics_test.cpp @@ -129,9 +129,14 @@ TEST_F(ReshardingMetricsTest, TestOperationStatus) { getMetrics()->onCompletion(ReshardingMetrics::OperationStatus::kCanceled); } - checkMetrics("successfulOperations", kNumSuccessfulOps); - checkMetrics("failedOperations", kNumFailedOps); - checkMetrics("canceledOperations", kNumCanceledOps); + checkMetrics("countReshardingSuccessful", kNumSuccessfulOps); + checkMetrics("countReshardingFailures", kNumFailedOps); + checkMetrics("countReshardingCanceled", kNumCanceledOps); + + const auto total = kNumSuccessfulOps + kNumFailedOps + kNumCanceledOps; + checkMetrics("countReshardingOperations", total); + getMetrics()->onStart(); + checkMetrics("countReshardingOperations", total + 1); } TEST_F(ReshardingMetricsTest, TestElapsedTime) { |