mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [03/16] mesos git commit: Added per-framework metrics for scheduler calls.
Date Wed, 01 Aug 2018 20:24:20 GMT
Added per-framework metrics for scheduler calls.

Review: https://reviews.apache.org/r/67776/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/133669a9
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/133669a9
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/133669a9

Branch: refs/heads/master
Commit: 133669a9b0492be5a51af5f76808c6f932ca7714
Parents: 9b7b5e7
Author: Greg Mann <greg@mesosphere.io>
Authored: Wed Aug 1 07:58:14 2018 -0700
Committer: Greg Mann <gregorywmann@gmail.com>
Committed: Wed Aug 1 13:07:54 2018 -0700

----------------------------------------------------------------------
 src/master/http.cpp    |  2 ++
 src/master/master.cpp  |  6 ++++++
 src/master/metrics.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++-
 src/master/metrics.hpp |  7 +++++++
 4 files changed, 57 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/133669a9/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index 6947031..d43fbd6 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -1035,6 +1035,8 @@ Future<Response> Master::Http::scheduler(
     return BadRequest("Framework cannot be found");
   }
 
+  framework->metrics.incrementCall(call.type());
+
   // TODO(greggomann): Move this implicit scheduler authorization
   // into the authorizer. See MESOS-7399.
   if (principal.isSome() && principal != framework->info.principal()) {

http://git-wip-us.apache.org/repos/asf/mesos/blob/133669a9/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 8f76f30..3cb39d4 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -2416,6 +2416,8 @@ void Master::receive(
     return;
   }
 
+  framework->metrics.incrementCall(call.type());
+
   // This is possible when master --> framework link is broken (i.e., one
   // way network partition) and the framework is not aware of it. There
   // is no way for driver based frameworks to detect this in the absence
@@ -2733,6 +2735,8 @@ void Master::_subscribe(
 
     addFramework(framework, suppressedRoles);
 
+    framework->metrics.incrementCall(scheduler::Call::SUBSCRIBE);
+
     FrameworkRegisteredMessage message;
     message.mutable_framework_id()->MergeFrom(framework->id());
     message.mutable_master_info()->MergeFrom(info_);
@@ -2766,6 +2770,8 @@ void Master::_subscribe(
 
   CHECK_NOTNULL(framework);
 
+  framework->metrics.incrementCall(scheduler::Call::SUBSCRIBE);
+
   if (!framework->recovered()) {
     // The framework has previously been registered with this master;
     // it may or may not currently be connected.

http://git-wip-us.apache.org/repos/asf/mesos/blob/133669a9/src/master/metrics.cpp
----------------------------------------------------------------------
diff --git a/src/master/metrics.cpp b/src/master/metrics.cpp
index 70ac72d..c4252e0 100644
--- a/src/master/metrics.cpp
+++ b/src/master/metrics.cpp
@@ -16,6 +16,8 @@
 
 #include <string>
 
+#include <mesos/scheduler/scheduler.hpp>
+
 #include <process/http.hpp>
 
 #include <process/metrics/counter.hpp>
@@ -551,15 +553,54 @@ void Metrics::incrementTasksStates(
 FrameworkMetrics::FrameworkMetrics(const FrameworkInfo& _frameworkInfo)
   : frameworkInfo(_frameworkInfo),
     subscribed(
-        getFrameworkMetricPrefix(frameworkInfo) + "subscribed")
+        getFrameworkMetricPrefix(frameworkInfo) + "subscribed"),
+    calls(
+        getFrameworkMetricPrefix(frameworkInfo) + "calls")
 {
   process::metrics::add(subscribed);
+
+  // Add metrics for scheduler calls.
+  process::metrics::add(calls);
+  for (int index = 0;
+       index < scheduler::Call::Type_descriptor()->value_count();
+       index++) {
+    const google::protobuf::EnumValueDescriptor* descriptor =
+      scheduler::Call::Type_descriptor()->value(index);
+
+    const scheduler::Call::Type type =
+      static_cast<scheduler::Call::Type>(descriptor->number());
+
+    if (type == scheduler::Call::UNKNOWN) {
+      continue;
+    }
+
+    Counter counter = Counter(
+        getFrameworkMetricPrefix(frameworkInfo) + "calls/" +
+        strings::lower(descriptor->name()));
+
+    call_types.put(type, counter);
+    process::metrics::add(counter);
+  }
 }
 
 
 FrameworkMetrics::~FrameworkMetrics()
 {
   process::metrics::remove(subscribed);
+
+  process::metrics::remove(calls);
+  foreachvalue (const Counter& counter, call_types) {
+    process::metrics::remove(counter);
+  }
+}
+
+
+void FrameworkMetrics::incrementCall(const scheduler::Call::Type& callType)
+{
+  CHECK(call_types.contains(callType));
+
+  call_types.get(callType).get()++;
+  calls++;
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/133669a9/src/master/metrics.hpp
----------------------------------------------------------------------
diff --git a/src/master/metrics.hpp b/src/master/metrics.hpp
index 68bf415..ae4c703 100644
--- a/src/master/metrics.hpp
+++ b/src/master/metrics.hpp
@@ -20,6 +20,8 @@
 #include <string>
 #include <vector>
 
+#include <mesos/scheduler/scheduler.hpp>
+
 #include <process/metrics/counter.hpp>
 #include <process/metrics/pull_gauge.hpp>
 #include <process/metrics/push_gauge.hpp>
@@ -222,9 +224,14 @@ struct FrameworkMetrics
 
   ~FrameworkMetrics();
 
+  void incrementCall(const scheduler::Call::Type& callType);
+
   const FrameworkInfo frameworkInfo;
 
   process::metrics::PushGauge subscribed;
+
+  process::metrics::Counter calls;
+  hashmap<scheduler::Call::Type, process::metrics::Counter> call_types;
 };
 
 


Mime
View raw message