You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gr...@apache.org on 2018/08/01 20:24:23 UTC
[06/16] mesos git commit: Enabled per-framework metrics in the master.
Enabled per-framework metrics in the master.
The `FrameworkMetrics` struct will be used to track per-framework
metrics in the master.
Review: https://reviews.apache.org/r/67962/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/45fa0593
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/45fa0593
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/45fa0593
Branch: refs/heads/master
Commit: 45fa0593790632a5c1231b350921281dded1c1aa
Parents: 58cd544
Author: Greg Mann <gr...@mesosphere.io>
Authored: Wed Aug 1 07:57:56 2018 -0700
Committer: Greg Mann <gr...@gmail.com>
Committed: Wed Aug 1 13:07:54 2018 -0700
----------------------------------------------------------------------
src/master/master.hpp | 8 +++++++-
src/master/metrics.cpp | 16 ++++++++++++++++
src/master/metrics.hpp | 13 +++++++++++++
3 files changed, 36 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/45fa0593/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 0353d55..4bb64ca 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -3013,6 +3013,9 @@ struct Framework
Option<process::Owned<Heartbeater<scheduler::Event, v1::scheduler::Event>>>
heartbeater;
+ // This is used for per-framwork metrics.
+ FrameworkMetrics metrics;
+
private:
Framework(Master* const _master,
const Flags& masterFlags,
@@ -3027,8 +3030,11 @@ private:
registeredTime(time),
reregisteredTime(time),
completedTasks(masterFlags.max_completed_tasks_per_framework),
- unreachableTasks(masterFlags.max_unreachable_tasks_per_framework)
+ unreachableTasks(masterFlags.max_unreachable_tasks_per_framework),
+ metrics(_info)
{
+ CHECK(_info.has_id());
+
foreach (const std::string& role, roles) {
// NOTE: It's possible that we're already being tracked under the role
// because a framework can unsubscribe from a role while it still has
http://git-wip-us.apache.org/repos/asf/mesos/blob/45fa0593/src/master/metrics.cpp
----------------------------------------------------------------------
diff --git a/src/master/metrics.cpp b/src/master/metrics.cpp
index e46ead7..a778322 100644
--- a/src/master/metrics.cpp
+++ b/src/master/metrics.cpp
@@ -16,6 +16,8 @@
#include <string>
+#include <process/http.hpp>
+
#include <process/metrics/counter.hpp>
#include <process/metrics/pull_gauge.hpp>
#include <process/metrics/metrics.hpp>
@@ -546,6 +548,20 @@ void Metrics::incrementTasksStates(
}
+FrameworkMetrics::FrameworkMetrics(const FrameworkInfo& _frameworkInfo)
+ : frameworkInfo(_frameworkInfo) {}
+
+
+FrameworkMetrics::~FrameworkMetrics() {}
+
+
+string getFrameworkMetricPrefix(const FrameworkInfo& frameworkInfo)
+{
+ // Percent-encode the framework name to avoid characters like '/' and ' '.
+ return "master/frameworks/" + process::http::encode(frameworkInfo.name()) +
+ "/" + stringify(frameworkInfo.id()) + "/";
+}
+
} // namespace master {
} // namespace internal {
} // namespace mesos {
http://git-wip-us.apache.org/repos/asf/mesos/blob/45fa0593/src/master/metrics.hpp
----------------------------------------------------------------------
diff --git a/src/master/metrics.hpp b/src/master/metrics.hpp
index ec76dbc..4765e07 100644
--- a/src/master/metrics.hpp
+++ b/src/master/metrics.hpp
@@ -214,6 +214,19 @@ struct Metrics
const TaskStatus::Reason& reason);
};
+
+struct FrameworkMetrics
+{
+ explicit FrameworkMetrics(const FrameworkInfo& _frameworkInfo);
+
+ ~FrameworkMetrics();
+
+ const FrameworkInfo frameworkInfo;
+};
+
+
+std::string getFrameworkMetricPrefix(const FrameworkInfo& frameworkInfo);
+
} // namespace master {
} // namespace internal {
} // namespace mesos {