You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2016/03/17 17:34:55 UTC
mesos git commit: Updated `/metrics/snapshot` endpoint to use
`jsonify`.
Repository: mesos
Updated Branches:
refs/heads/master c97b79a50 -> 8be869aba
Updated `/metrics/snapshot` endpoint to use `jsonify`.
Review: https://reviews.apache.org/r/44675/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8be869ab
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8be869ab
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8be869ab
Branch: refs/heads/master
Commit: 8be869abab468706274e435247e8e22eef0dd0a0
Parents: c97b79a
Author: Cong Wang <xi...@gmail.com>
Authored: Thu Mar 17 12:14:00 2016 -0400
Committer: Michael Park <mp...@apache.org>
Committed: Thu Mar 17 12:14:00 2016 -0400
----------------------------------------------------------------------
3rdparty/libprocess/src/metrics/metrics.cpp | 54 ++++++++++++------------
1 file changed, 28 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/8be869ab/3rdparty/libprocess/src/metrics/metrics.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/metrics/metrics.cpp b/3rdparty/libprocess/src/metrics/metrics.cpp
index f1e6774..7677dff 100644
--- a/3rdparty/libprocess/src/metrics/metrics.cpp
+++ b/3rdparty/libprocess/src/metrics/metrics.cpp
@@ -231,35 +231,37 @@ Future<http::Response> MetricsProcess::__snapshot(
const hashmap<string, Future<double> >& metrics,
const hashmap<string, Option<Statistics<double> > >& statistics)
{
- JSON::Object object;
-
- foreachpair (const string& key, const Future<double>& value, metrics) {
- // TODO(dhamon): Maybe add the failure message for this metric to the
- // response if value.isFailed().
- if (value.isPending()) {
- CHECK_SOME(timeout);
- VLOG(1) << "Exceeded timeout of " << timeout.get() << " when attempting "
- << "to get metric '" << key << "'";
- } else if (value.isReady()) {
- object.values[key] = value.get();
- }
+ auto snapshot = [&timeout,
+ &metrics,
+ &statistics](JSON::ObjectWriter* writer) {
+ foreachpair (const string& key, const Future<double>& value, metrics) {
+ // TODO(dhamon): Maybe add the failure message for this metric to the
+ // response if value.isFailed().
+ if (value.isPending()) {
+ CHECK_SOME(timeout);
+ VLOG(1) << "Exceeded timeout of " << timeout.get()
+ << " when attempting to get metric '" << key << "'";
+ } else if (value.isReady()) {
+ writer->field(key, value.get());
+ }
- Option<Statistics<double> > statistics_ = statistics.get(key).get();
-
- if (statistics_.isSome()) {
- object.values[key + "/count"] = statistics_.get().count;
- object.values[key + "/min"] = statistics_.get().min;
- object.values[key + "/max"] = statistics_.get().max;
- object.values[key + "/p50"] = statistics_.get().p50;
- object.values[key + "/p90"] = statistics_.get().p90;
- object.values[key + "/p95"] = statistics_.get().p95;
- object.values[key + "/p99"] = statistics_.get().p99;
- object.values[key + "/p999"] = statistics_.get().p999;
- object.values[key + "/p9999"] = statistics_.get().p9999;
+ Option<Statistics<double> > statistics_ = statistics.get(key).get();
+
+ if (statistics_.isSome()) {
+ writer->field(key + "/count", statistics_.get().count);
+ writer->field(key + "/min", statistics_.get().min);
+ writer->field(key + "/max", statistics_.get().max);
+ writer->field(key + "/p50", statistics_.get().p50);
+ writer->field(key + "/p90", statistics_.get().p90);
+ writer->field(key + "/p95", statistics_.get().p95);
+ writer->field(key + "/p99", statistics_.get().p99);
+ writer->field(key + "/p999", statistics_.get().p999);
+ writer->field(key + "/p9999", statistics_.get().p9999);
+ }
}
- }
+ };
- return http::OK(object, request.url.query.get("jsonp"));
+ return http::OK(jsonify(snapshot), request.url.query.get("jsonp"));
}
} // namespace internal {