diff options
Diffstat (limited to 'src/mongo/db/stats/top.h')
-rw-r--r-- | src/mongo/db/stats/top.h | 121 |
1 files changed, 60 insertions, 61 deletions
diff --git a/src/mongo/db/stats/top.h b/src/mongo/db/stats/top.h index d71605e8ef4..56090b5c408 100644 --- a/src/mongo/db/stats/top.h +++ b/src/mongo/db/stats/top.h @@ -36,66 +36,65 @@ namespace mongo { - class ServiceContext; - - /** - * tracks usage by collection - */ - class Top { - - public: - static Top& get(ServiceContext* service); - - Top() = default; - - struct UsageData { - UsageData() : time(0), count(0) {} - UsageData( const UsageData& older, const UsageData& newer ); - long long time; - long long count; - - void inc( long long micros ) { - count++; - time += micros; - } - }; - - struct CollectionData { - /** - * constructs a diff - */ - CollectionData() {} - CollectionData( const CollectionData& older, const CollectionData& newer ); - - UsageData total; - - UsageData readLock; - UsageData writeLock; - - UsageData queries; - UsageData getmore; - UsageData insert; - UsageData update; - UsageData remove; - UsageData commands; - }; - - typedef StringMap<CollectionData> UsageMap; - - public: - void record( StringData ns, int op, int lockType, long long micros, bool command ); - void append( BSONObjBuilder& b ); - void cloneMap(UsageMap& out) const; - void collectionDropped( StringData ns ); - - private: - void _appendToUsageMap( BSONObjBuilder& b, const UsageMap& map ) const; - void _appendStatsEntry( BSONObjBuilder& b, const char * statsName, const UsageData& map ) const; - void _record( CollectionData& c, int op, int lockType, long long micros, bool command ); - - mutable SimpleMutex _lock; - UsageMap _usage; - std::string _lastDropped; +class ServiceContext; + +/** + * tracks usage by collection + */ +class Top { +public: + static Top& get(ServiceContext* service); + + Top() = default; + + struct UsageData { + UsageData() : time(0), count(0) {} + UsageData(const UsageData& older, const UsageData& newer); + long long time; + long long count; + + void inc(long long micros) { + count++; + time += micros; + } }; -} // namespace mongo + struct CollectionData { + /** + * constructs a diff + */ + CollectionData() {} + CollectionData(const CollectionData& older, const CollectionData& newer); + + UsageData total; + + UsageData readLock; + UsageData writeLock; + + UsageData queries; + UsageData getmore; + UsageData insert; + UsageData update; + UsageData remove; + UsageData commands; + }; + + typedef StringMap<CollectionData> UsageMap; + +public: + void record(StringData ns, int op, int lockType, long long micros, bool command); + void append(BSONObjBuilder& b); + void cloneMap(UsageMap& out) const; + void collectionDropped(StringData ns); + +private: + void _appendToUsageMap(BSONObjBuilder& b, const UsageMap& map) const; + void _appendStatsEntry(BSONObjBuilder& b, const char* statsName, const UsageData& map) const; + void _record(CollectionData& c, int op, int lockType, long long micros, bool command); + + mutable SimpleMutex _lock; + UsageMap _usage; + std::string _lastDropped; +}; + +} // namespace mongo |