summaryrefslogtreecommitdiff
path: root/src/mongo/db/stats/top.cpp
diff options
context:
space:
mode:
authorKevin Albertson <kevin.albertson@10gen.com>2016-08-29 13:45:05 -0400
committerKyle Suarez <kyle.suarez@mongodb.com>2016-08-29 13:48:10 -0400
commitbe09d7bf0a72f44f8909221f178a70a2cb0a6b68 (patch)
treed220f4b5a00005e9d20332efa4711f960a466546 /src/mongo/db/stats/top.cpp
parent0739882bb06e09936a9285cf385c80948fe2a619 (diff)
downloadmongo-be09d7bf0a72f44f8909221f178a70a2cb0a6b68.tar.gz
SERVER-25180 make full histogram output optional
For full per-collection histograms, use the aggregation stage { $collStats: { latencyStats: { histograms: true } } } For the full global histogram, invoke serverStatus with db.serverStatus( { opLatencies: { histograms: true } } )
Diffstat (limited to 'src/mongo/db/stats/top.cpp')
-rw-r--r--src/mongo/db/stats/top.cpp22
1 files changed, 4 insertions, 18 deletions
diff --git a/src/mongo/db/stats/top.cpp b/src/mongo/db/stats/top.cpp
index 8bfe3431f6d..413c5f1c015 100644
--- a/src/mongo/db/stats/top.cpp
+++ b/src/mongo/db/stats/top.cpp
@@ -33,7 +33,6 @@
#include "mongo/db/stats/top.h"
-#include "mongo/db/commands/server_status_metric.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/service_context.h"
#include "mongo/util/log.h"
@@ -198,11 +197,11 @@ void Top::_appendStatsEntry(BSONObjBuilder& b, const char* statsName, const Usag
bb.done();
}
-void Top::appendLatencyStats(StringData ns, BSONObjBuilder* builder) {
+void Top::appendLatencyStats(StringData ns, bool includeHistograms, BSONObjBuilder* builder) {
auto hashedNs = UsageMap::HashedKey(ns);
stdx::lock_guard<SimpleMutex> lk(_lock);
BSONObjBuilder latencyStatsBuilder;
- _usage[hashedNs].opLatencyHistogram.append(&latencyStatsBuilder);
+ _usage[hashedNs].opLatencyHistogram.append(includeHistograms, &latencyStatsBuilder);
builder->append("ns", ns);
builder->append("latencyStats", latencyStatsBuilder.obj());
}
@@ -214,9 +213,9 @@ void Top::incrementGlobalLatencyStats(OperationContext* txn,
_incrementHistogram(txn, latency, &_globalHistogramStats, readWriteType);
}
-void Top::appendGlobalLatencyStats(BSONObjBuilder* builder) {
+void Top::appendGlobalLatencyStats(bool includeHistograms, BSONObjBuilder* builder) {
stdx::lock_guard<SimpleMutex> guard(_lock);
- _globalHistogramStats.append(builder);
+ _globalHistogramStats.append(includeHistograms, builder);
}
void Top::_incrementHistogram(OperationContext* txn,
@@ -229,17 +228,4 @@ void Top::_incrementHistogram(OperationContext* txn,
histogram->increment(latency, readWriteType);
}
}
-
-/**
- * Appends the global histogram to the server status.
- */
-class GlobalHistogramServerStatusMetric : public ServerStatusMetric {
-public:
- GlobalHistogramServerStatusMetric() : ServerStatusMetric(".metrics.latency") {}
- virtual void appendAtLeaf(BSONObjBuilder& builder) const {
- BSONObjBuilder latencyBuilder;
- Top::get(getGlobalServiceContext()).appendGlobalLatencyStats(&latencyBuilder);
- builder.append("latency", latencyBuilder.obj());
- }
-} globalHistogramServerStatusMetric;
} // namespace mongo