diff options
author | Eric Milkie <milkie@10gen.com> | 2021-05-03 14:22:15 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-05-03 20:30:23 +0000 |
commit | 960f5deb14520af3076c9164fbf8b3cbcca0560f (patch) | |
tree | c36a300cc4060449974eab032d197813034defb5 /src/mongo/db/stats/resource_consumption_metrics.h | |
parent | 20b86d14a58f5862fa0eeec1f2bfac3161797730 (diff) | |
download | mongo-960f5deb14520af3076c9164fbf8b3cbcca0560f.tar.gz |
SERVER-55556 add new totalUnitsWritten metric; add new localTime field to operationMetrics output
totalUnitsWritten is a metric that represents the number of bytes written to a document plus any index entries that follow, prior to writing another document; these bytes are then translated into Units as per the totalUnitWriteSizeBytes parameter.
Additionally, a new field localTime will now appear in every BSONArray (per database) included in the $operationMetrics aggregation stage
Diffstat (limited to 'src/mongo/db/stats/resource_consumption_metrics.h')
-rw-r--r-- | src/mongo/db/stats/resource_consumption_metrics.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/mongo/db/stats/resource_consumption_metrics.h b/src/mongo/db/stats/resource_consumption_metrics.h index 5e098b5c730..4aef396e6b6 100644 --- a/src/mongo/db/stats/resource_consumption_metrics.h +++ b/src/mongo/db/stats/resource_consumption_metrics.h @@ -113,6 +113,35 @@ public: int unitSize() const final; }; + /** TotalUnitWriteCounter records the number of units of document plus associated indexes + * observed. */ + class TotalUnitWriteCounter { + public: + void observeOneDocument(size_t datumBytes); + void observeOneIndexEntry(size_t datumBytes); + + TotalUnitWriteCounter& operator+=(TotalUnitWriteCounter other) { + // Flush the accumulators, in case there is anything still pending. + other.observeOneDocument(0); + observeOneDocument(0); + _units += other._units; + return *this; + } + + long long units() const { + // Flush the accumulators, in case there is anything still pending. + TotalUnitWriteCounter copy(*this); + copy.observeOneDocument(0); + return copy._units; + } + + private: + int unitSize() const; + long long _accumulatedDocumentBytes = 0; + long long _accumulatedIndexBytes = 0; + long long _units = 0; + }; + /** ReadMetrics maintains metrics for read operations. */ class ReadMetrics { public: @@ -158,6 +187,7 @@ public: void add(const WriteMetrics& other) { docsWritten += other.docsWritten; idxEntriesWritten += other.idxEntriesWritten; + totalWritten += other.totalWritten; } WriteMetrics& operator+=(const WriteMetrics& other) { @@ -174,6 +204,8 @@ public: DocumentUnitCounter docsWritten; // Number of index entries written IdxEntryUnitCounter idxEntriesWritten; + // Number of total units written + TotalUnitWriteCounter totalWritten; }; /** |