From a09a1afbe18353ac5c865a643c97029e5cba4925 Mon Sep 17 00:00:00 2001 From: Louis Williams Date: Mon, 9 Nov 2020 09:17:07 -0500 Subject: SERVER-51668 Report total CPU time spent by operations in serverStatus --- src/mongo/db/stats/resource_consumption_metrics.h | 26 ++++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/mongo/db/stats/resource_consumption_metrics.h') diff --git a/src/mongo/db/stats/resource_consumption_metrics.h b/src/mongo/db/stats/resource_consumption_metrics.h index a4c8e02b247..2f7855dd870 100644 --- a/src/mongo/db/stats/resource_consumption_metrics.h +++ b/src/mongo/db/stats/resource_consumption_metrics.h @@ -350,21 +350,31 @@ public: void merge(OperationContext* opCtx, const std::string& dbName, const OperationMetrics& metrics); /** - * Returns a copy of the Metrics map. + * Returns a copy of the per-database metrics map. */ using MetricsMap = std::map; - MetricsMap getMetrics() const; + MetricsMap getDbMetrics() const; /** - * Returns the Metrics map and then clears the contents. This attempts to swap and return the - * metrics map rather than making a full copy like getMetrics. + * Returns the per-database metrics map and then clears the contents. This attempts to swap and + * return the metrics map rather than making a full copy like getDbMetrics. */ - MetricsMap getAndClearMetrics(); + MetricsMap getAndClearDbMetrics(); + + /** + * Returns the globally-aggregated CPU time. + */ + Nanoseconds getCpuTime() const; + + /** + * Clears the existing CPU time. + */ + Nanoseconds getAndClearCpuTime(); private: - // Protects _metrics + // Protects _dbMetrics and _cpuTime mutable Mutex _mutex = MONGO_MAKE_LATCH("ResourceConsumption::_mutex"); - MetricsMap _metrics; + MetricsMap _dbMetrics; + Nanoseconds _cpuTime; }; - } // namespace mongo -- cgit v1.2.1