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:27 UTC
[10/16] mesos git commit: Added per-framework metrics for offer
operations.
Added per-framework metrics for offer operations.
Review: https://reviews.apache.org/r/67814/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d309258f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d309258f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d309258f
Branch: refs/heads/master
Commit: d309258f03e4290134276b65dc975396cb3ccd77
Parents: ac4c989
Author: Greg Mann <gr...@mesosphere.io>
Authored: Wed Aug 1 07:58:39 2018 -0700
Committer: Greg Mann <gr...@gmail.com>
Committed: Wed Aug 1 13:07:55 2018 -0700
----------------------------------------------------------------------
src/master/master.cpp | 14 ++++++++++++++
src/master/metrics.cpp | 41 ++++++++++++++++++++++++++++++++++++++++-
src/master/metrics.hpp | 5 +++++
3 files changed, 59 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/d309258f/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index fa6bece..b46f717 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -5485,6 +5485,10 @@ void Master::_accept(
<< (launchExecutor ?
" new executor" : " existing executor");
+ // Increment this metric here for LAUNCH since it
+ // does not make use of the `_apply()` function.
+ framework->metrics.incrementOperation(operation);
+
send(slave->pid, message);
}
}
@@ -5705,6 +5709,10 @@ void Master::_accept(
<< *slave << " on "
<< (launchExecutor ? " new executor" : " existing executor");
+ // Increment this metric here for LAUNCH_GROUP since it
+ // does not make use of the `_apply()` function.
+ framework->metrics.incrementOperation(operation);
+
send(slave->pid, message);
break;
@@ -11425,6 +11433,12 @@ void Master::_apply(
send(slave->pid, message);
}
+
+ if (framework != nullptr) {
+ // We increment per-framework operation metrics for all operations except
+ // LAUNCH and LAUNCH_GROUP here.
+ framework->metrics.incrementOperation(operationInfo);
+ }
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/d309258f/src/master/metrics.cpp
----------------------------------------------------------------------
diff --git a/src/master/metrics.cpp b/src/master/metrics.cpp
index 0a9b499..655c75a 100644
--- a/src/master/metrics.cpp
+++ b/src/master/metrics.cpp
@@ -567,7 +567,9 @@ FrameworkMetrics::FrameworkMetrics(const FrameworkInfo& _frameworkInfo)
offers_declined(
getFrameworkMetricPrefix(frameworkInfo) + "offers/declined"),
offers_rescinded(
- getFrameworkMetricPrefix(frameworkInfo) + "offers/rescinded")
+ getFrameworkMetricPrefix(frameworkInfo) + "offers/rescinded"),
+ operations(
+ getFrameworkMetricPrefix(frameworkInfo) + "operations")
{
process::metrics::add(subscribed);
@@ -645,6 +647,29 @@ FrameworkMetrics::FrameworkMetrics(const FrameworkInfo& _frameworkInfo)
process::metrics::add(gauge);
}
}
+
+ // Add metrics for offer operations.
+ process::metrics::add(operations);
+ for (int index = 0;
+ index < Offer::Operation::Type_descriptor()->value_count();
+ index++) {
+ const google::protobuf::EnumValueDescriptor* descriptor =
+ Offer::Operation::Type_descriptor()->value(index);
+
+ const Offer::Operation::Type type =
+ static_cast<Offer::Operation::Type>(descriptor->number());
+
+ if (type == Offer::Operation::UNKNOWN) {
+ continue;
+ }
+
+ Counter counter =
+ Counter(getFrameworkMetricPrefix(frameworkInfo) +
+ "operations/" + strings::lower(descriptor->name()));
+
+ operation_types.put(type, counter);
+ process::metrics::add(counter);
+ }
}
@@ -674,6 +699,11 @@ FrameworkMetrics::~FrameworkMetrics()
foreachvalue (const PushGauge& gauge, active_task_states) {
process::metrics::remove(gauge);
}
+
+ process::metrics::remove(operations);
+ foreachvalue (const Counter& counter, operation_types) {
+ process::metrics::remove(counter);
+ }
}
@@ -706,6 +736,15 @@ void FrameworkMetrics::decrementActiveTaskState(const TaskState& state)
}
+void FrameworkMetrics::incrementOperation(const Offer::Operation& operation)
+{
+ CHECK(operation_types.contains(operation.type()));
+
+ operation_types.get(operation.type()).get()++;
+ operations++;
+}
+
+
string getFrameworkMetricPrefix(const FrameworkInfo& frameworkInfo)
{
// Percent-encode the framework name to avoid characters like '/' and ' '.
http://git-wip-us.apache.org/repos/asf/mesos/blob/d309258f/src/master/metrics.hpp
----------------------------------------------------------------------
diff --git a/src/master/metrics.hpp b/src/master/metrics.hpp
index c4b620e..df28a48 100644
--- a/src/master/metrics.hpp
+++ b/src/master/metrics.hpp
@@ -231,6 +231,8 @@ struct FrameworkMetrics
void incrementTaskState(const TaskState& state);
void decrementActiveTaskState(const TaskState& state);
+ void incrementOperation(const Offer::Operation& operation);
+
const FrameworkInfo frameworkInfo;
process::metrics::PushGauge subscribed;
@@ -249,6 +251,9 @@ struct FrameworkMetrics
hashmap<TaskState, process::metrics::Counter> terminal_task_states;
hashmap<TaskState, process::metrics::PushGauge> active_task_states;
+
+ process::metrics::Counter operations;
+ hashmap<Offer::Operation::Type, process::metrics::Counter> operation_types;
};