diff options
author | Louis Williams <louis.williams@mongodb.com> | 2020-11-02 16:36:20 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-11-02 22:02:31 +0000 |
commit | 12646ec5380bcc0dc10c66069a6583c653683922 (patch) | |
tree | 364c06ade130e8e386ea41fb88cfa90647fb7daa /src/mongo/db/index_builds_coordinator_mongod.cpp | |
parent | bccb5dc1eb8f7b731f4e20a292abea2193182cfd (diff) | |
download | mongo-12646ec5380bcc0dc10c66069a6583c653683922.tar.gz |
SERVER-50865 Collect resource consumption metrics for index builds
Diffstat (limited to 'src/mongo/db/index_builds_coordinator_mongod.cpp')
-rw-r--r-- | src/mongo/db/index_builds_coordinator_mongod.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mongo/db/index_builds_coordinator_mongod.cpp b/src/mongo/db/index_builds_coordinator_mongod.cpp index eef382c66de..e73cbc97c1c 100644 --- a/src/mongo/db/index_builds_coordinator_mongod.cpp +++ b/src/mongo/db/index_builds_coordinator_mongod.cpp @@ -45,6 +45,7 @@ #include "mongo/db/operation_context.h" #include "mongo/db/s/operation_sharding_state.h" #include "mongo/db/service_context.h" +#include "mongo/db/stats/resource_consumption_metrics.h" #include "mongo/db/storage/two_phase_index_build_knobs_gen.h" #include "mongo/executor/task_executor.h" #include "mongo/logv2/log.h" @@ -319,6 +320,14 @@ IndexBuildsCoordinatorMongod::_startIndexBuild(OperationContext* opCtx, sleepmillis(100); } + // Start collecting metrics for the index build. The metrics for this operation will only be + // aggregated globally if the node commits or aborts while it is primary. + auto& metricsCollector = ResourceConsumption::MetricsCollector::get(opCtx.get()); + if (ResourceConsumption::shouldCollectMetricsForDatabase(dbName) && + ResourceConsumption::isMetricsCollectionEnabled()) { + metricsCollector.beginScopedCollecting(dbName); + } + // Index builds should never take the PBWM lock, even on a primary. This allows the // index build to continue running after the node steps down to a secondary. ShouldNotConflictWithSecondaryBatchApplicationBlock shouldNotConflictBlock( |