mesos-commits mailing list archives

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

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


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

Branch: refs/heads/master
Commit: e27a729cbe3d9d13d4f9f2763bcfb86b54b1a300
Parents: 96dea36
Author: Greg Mann <greg@mesosphere.io>
Authored: Wed Aug 1 07:58:25 2018 -0700
Committer: Greg Mann <gregorywmann@gmail.com>
Committed: Wed Aug 1 13:07:54 2018 -0700

----------------------------------------------------------------------
 src/master/master.cpp  | 14 ++++++++++++++
 src/master/metrics.cpp | 20 +++++++++++++++++++-
 src/master/metrics.hpp |  5 +++++
 3 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e27a729c/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 3cb39d4..c107e94 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -4133,6 +4133,8 @@ void Master::accept(
     // Validate the offers.
     error = validation::offer::validate(accept.offer_ids(), this, framework);
 
+    size_t offersAccepted = 0;
+
     // Compute offered resources and remove the offers. If the
     // validation failed, return resources to the allocator.
     foreach (const OfferID& offerId, accept.offer_ids()) {
@@ -4150,6 +4152,8 @@ void Master::accept(
           slaveId = offer->slave_id();
           allocationInfo = offer->allocation_info();
           offeredResources += offer->resources();
+
+          offersAccepted++;
         }
 
         removeOffer(offer);
@@ -4161,6 +4165,8 @@ void Master::accept(
       LOG(WARNING) << "Ignoring accept of offer " << offerId
                    << " since it is no longer valid";
     }
+
+    framework->metrics.offers_accepted += offersAccepted;
   }
 
   // If invalid, send TASK_DROPPED for the launch attempts. If the
@@ -5881,6 +5887,8 @@ void Master::decline(
 
   ++metrics->messages_decline_offers;
 
+  size_t offersDeclined = 0;
+
   //  Return resources to the allocator.
   foreach (const OfferID& offerId, decline.offer_ids()) {
     Offer* offer = getOffer(offerId);
@@ -5892,6 +5900,8 @@ void Master::decline(
           decline.filters());
 
       removeOffer(offer);
+
+      offersDeclined++;
       continue;
     }
 
@@ -5900,6 +5910,8 @@ void Master::decline(
     LOG(WARNING) << "Ignoring decline of offer " << offerId
                  << " since it is no longer valid";
   }
+
+  framework->metrics.offers_declined += offersDeclined;
 }
 
 
@@ -9480,6 +9492,7 @@ void Master::offer(
 
   LOG(INFO) << "Sending offers " << offerIds << " to framework " <<
*framework;
 
+  framework->metrics.offers_sent += message.offers().size();
   framework->send(message);
 }
 
@@ -11440,6 +11453,7 @@ void Master::removeOffer(Offer* offer, bool rescind)
   if (rescind) {
     RescindResourceOfferMessage message;
     message.mutable_offer_id()->MergeFrom(offer->id());
+    framework->metrics.offers_rescinded++;
     framework->send(message);
   }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/e27a729c/src/master/metrics.cpp
----------------------------------------------------------------------
diff --git a/src/master/metrics.cpp b/src/master/metrics.cpp
index 8dbe1e9..ec7afb8 100644
--- a/src/master/metrics.cpp
+++ b/src/master/metrics.cpp
@@ -557,10 +557,23 @@ FrameworkMetrics::FrameworkMetrics(const FrameworkInfo& _frameworkInfo)
     calls(
         getFrameworkMetricPrefix(frameworkInfo) + "calls"),
     events(
-        getFrameworkMetricPrefix(frameworkInfo) + "events")
+        getFrameworkMetricPrefix(frameworkInfo) + "events"),
+    offers_sent(
+        getFrameworkMetricPrefix(frameworkInfo) + "offers/sent"),
+    offers_accepted(
+        getFrameworkMetricPrefix(frameworkInfo) + "offers/accepted"),
+    offers_declined(
+        getFrameworkMetricPrefix(frameworkInfo) + "offers/declined"),
+    offers_rescinded(
+        getFrameworkMetricPrefix(frameworkInfo) + "offers/rescinded")
 {
   process::metrics::add(subscribed);
 
+  process::metrics::add(offers_sent);
+  process::metrics::add(offers_accepted);
+  process::metrics::add(offers_declined);
+  process::metrics::add(offers_rescinded);
+
   // Add metrics for scheduler calls.
   process::metrics::add(calls);
   for (int index = 0;
@@ -622,6 +635,11 @@ FrameworkMetrics::~FrameworkMetrics()
   foreachvalue (const Counter& counter, event_types) {
     process::metrics::remove(counter);
   }
+
+  process::metrics::remove(offers_sent);
+  process::metrics::remove(offers_accepted);
+  process::metrics::remove(offers_declined);
+  process::metrics::remove(offers_rescinded);
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/e27a729c/src/master/metrics.hpp
----------------------------------------------------------------------
diff --git a/src/master/metrics.hpp b/src/master/metrics.hpp
index abc6a7c..319645e 100644
--- a/src/master/metrics.hpp
+++ b/src/master/metrics.hpp
@@ -237,6 +237,11 @@ struct FrameworkMetrics
 
   process::metrics::Counter events;
   hashmap<scheduler::Event::Type, process::metrics::Counter> event_types;
+
+  process::metrics::Counter offers_sent;
+  process::metrics::Counter offers_accepted;
+  process::metrics::Counter offers_declined;
+  process::metrics::Counter offers_rescinded;
 };
 
 


Mime
View raw message