diff options
| author | Kevin Albertson <kevin.albertson@10gen.com> | 2016-08-29 13:45:05 -0400 |
|---|---|---|
| committer | Kyle Suarez <kyle.suarez@mongodb.com> | 2016-08-29 13:48:10 -0400 |
| commit | be09d7bf0a72f44f8909221f178a70a2cb0a6b68 (patch) | |
| tree | d220f4b5a00005e9d20332efa4711f960a466546 /src/mongo/db/stats/operation_latency_histogram.cpp | |
| parent | 0739882bb06e09936a9285cf385c80948fe2a619 (diff) | |
| download | mongo-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/operation_latency_histogram.cpp')
| -rw-r--r-- | src/mongo/db/stats/operation_latency_histogram.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/mongo/db/stats/operation_latency_histogram.cpp b/src/mongo/db/stats/operation_latency_histogram.cpp index 3b55b18af5a..74a1f462760 100644 --- a/src/mongo/db/stats/operation_latency_histogram.cpp +++ b/src/mongo/db/stats/operation_latency_histogram.cpp @@ -93,29 +93,31 @@ const std::array<uint64_t, OperationLatencyHistogram::kMaxBuckets> void OperationLatencyHistogram::_append(const HistogramData& data, const char* key, + bool includeHistograms, BSONObjBuilder* builder) const { BSONObjBuilder histogramBuilder(builder->subobjStart(key)); - BSONArrayBuilder arrayBuilder(histogramBuilder.subarrayStart("histogram")); - for (int i = 0; i < kMaxBuckets; i++) { - if (data.buckets[i] == 0) - continue; - BSONObjBuilder entryBuilder(arrayBuilder.subobjStart()); - entryBuilder.append("micros", static_cast<long long>(kLowerBounds[i])); - entryBuilder.append("count", static_cast<long long>(data.buckets[i])); - entryBuilder.doneFast(); + if (includeHistograms) { + BSONArrayBuilder arrayBuilder(histogramBuilder.subarrayStart("histogram")); + for (int i = 0; i < kMaxBuckets; i++) { + if (data.buckets[i] == 0) + continue; + BSONObjBuilder entryBuilder(arrayBuilder.subobjStart()); + entryBuilder.append("micros", static_cast<long long>(kLowerBounds[i])); + entryBuilder.append("count", static_cast<long long>(data.buckets[i])); + entryBuilder.doneFast(); + } + arrayBuilder.doneFast(); } - - arrayBuilder.doneFast(); histogramBuilder.append("latency", static_cast<long long>(data.sum)); histogramBuilder.append("ops", static_cast<long long>(data.entryCount)); histogramBuilder.doneFast(); } -void OperationLatencyHistogram::append(BSONObjBuilder* builder) const { - _append(_reads, "reads", builder); - _append(_writes, "writes", builder); - _append(_commands, "commands", builder); +void OperationLatencyHistogram::append(bool includeHistograms, BSONObjBuilder* builder) const { + _append(_reads, "reads", includeHistograms, builder); + _append(_writes, "writes", includeHistograms, builder); + _append(_commands, "commands", includeHistograms, builder); } // Computes the log base 2 of value, and checks for cases of split buckets. |
