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 2019/01/10 18:36:01 UTC

[mesos] 03/08: Added new metric for cache hits.

This is an automated email from the ASF dual-hosted git repository.

grag pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit b4d8e7f23be3e0b182207f7573aca707bce82093
Author: Benno Evers <be...@mesosphere.com>
AuthorDate: Wed Jan 9 14:29:47 2019 -0800

    Added new metric for cache hits.
    
    This new metric counts the total number of cache
    hits in the newly-added request batching mechanism
    of the Mesos master.
    
    Review: https://reviews.apache.org/r/69422/
---
 src/master/http.cpp        | 1 +
 src/master/metrics.cpp     | 4 ++++
 src/master/metrics.hpp     | 5 +++++
 src/tests/master_tests.cpp | 2 ++
 4 files changed, 12 insertions(+)

diff --git a/src/master/http.cpp b/src/master/http.cpp
index 758946c..012ee4f 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -2406,6 +2406,7 @@ Future<Response> Master::Http::deferBatchedRequest(
     // On heavily-loaded masters, this could lead to a delay of several seconds
     // before permission changes for a principal take effect.
     future = it->promise.future();
+    ++master->metrics->http_cache_hits;
   } else {
     // Add an element to the batched state requests.
     Promise<Response> promise;
diff --git a/src/master/metrics.cpp b/src/master/metrics.cpp
index bb029d3..4dd73fb 100644
--- a/src/master/metrics.cpp
+++ b/src/master/metrics.cpp
@@ -115,6 +115,8 @@ Metrics::Metrics(const Master& master)
         "master/tasks_gone_by_operator"),
     dropped_messages(
         "master/dropped_messages"),
+    http_cache_hits(
+        "master/http_cache_hits"),
     messages_register_framework(
         "master/messages_register_framework"),
     messages_reregister_framework(
@@ -251,6 +253,7 @@ Metrics::Metrics(const Master& master)
   process::metrics::add(tasks_gone_by_operator);
 
   process::metrics::add(dropped_messages);
+  process::metrics::add(http_cache_hits);
 
   // Messages from schedulers.
   process::metrics::add(messages_register_framework);
@@ -404,6 +407,7 @@ Metrics::~Metrics()
   process::metrics::remove(tasks_gone_by_operator);
 
   process::metrics::remove(dropped_messages);
+  process::metrics::remove(http_cache_hits);
 
   // Messages from schedulers.
   process::metrics::remove(messages_register_framework);
diff --git a/src/master/metrics.hpp b/src/master/metrics.hpp
index eca48e6..4495e65 100644
--- a/src/master/metrics.hpp
+++ b/src/master/metrics.hpp
@@ -86,6 +86,11 @@ struct Metrics
   // Message counters.
   process::metrics::Counter dropped_messages;
 
+  // HTTP cache hits.
+  // TODO(bevers): Collect these per endpoint once per-endpoint
+  // metrics get merged.
+  process::metrics::Counter http_cache_hits;
+
   // Metrics specific to frameworks of a common principal.
   // These metrics have names prefixed by "frameworks/<principal>/".
   struct Frameworks
diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp
index 80642f4..67713c8 100644
--- a/src/tests/master_tests.cpp
+++ b/src/tests/master_tests.cpp
@@ -2285,6 +2285,8 @@ TEST_F(MasterTest, MetricsInMetricsEndpoint)
 
   EXPECT_EQ(1u, snapshot.values.count("master/dropped_messages"));
 
+  EXPECT_EQ(1u, snapshot.values.count("master/http_cache_hits"));
+
   // Messages from schedulers.
   EXPECT_EQ(1u, snapshot.values.count("master/messages_register_framework"));
   EXPECT_EQ(1u, snapshot.values.count("master/messages_reregister_framework"));