You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2018/10/16 12:17:44 UTC

[mesos] 03/03: Logged request processing time for some endpoints.

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

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

commit 9203d099da60b3333fa2e2d2a7fcefe8065fa7e1
Author: Alexander Rukletsov <al...@apache.org>
AuthorDate: Thu Oct 11 15:58:41 2018 +0200

    Logged request processing time for some endpoints.
    
    This patch leverages `logResponse()` function to print response status
    code together with the request processing time for some endpoints on
    the master and agent. Not all endpoints are participating to avoid
    unnecessary log pollution; only these that are know to be "slow" in
    generating the response.
    
    Note that requests are still logged when they are fetched from the
    actor mailbox, i.e., affected endpoints now log twice per request:
    when the processing starts and when the response is ready to be sent.
    
    Review: https://reviews.apache.org/r/68994
---
 src/master/master.cpp | 25 ++++++++++++++++++++-----
 src/slave/slave.cpp   | 10 ++++++++--
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/src/master/master.cpp b/src/master/master.cpp
index 06d769a..868787b 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -909,7 +909,10 @@ void Master::initialize()
         [this](const process::http::Request& request,
                const Option<Principal>& principal) {
           logRequest(request);
-          return http.frameworks(request, principal);
+          return http.frameworks(request, principal)
+            .onReady([request](const process::http::Response& response) {
+              logResponse(request, response);
+            });
         });
   route("/flags",
         READONLY_HTTP_AUTHENTICATION_REALM,
@@ -959,7 +962,10 @@ void Master::initialize()
         [this](const process::http::Request& request,
                const Option<Principal>& principal) {
           logRequest(request);
-          return http.slaves(request, principal);
+          return http.slaves(request, principal)
+            .onReady([request](const process::http::Response& response) {
+              logResponse(request, response);
+            });
         });
   route("/state",
         READONLY_HTTP_AUTHENTICATION_REALM,
@@ -967,7 +973,10 @@ void Master::initialize()
         [this](const process::http::Request& request,
                const Option<Principal>& principal) {
           logRequest(request);
-          return http.state(request, principal);
+          return http.state(request, principal)
+            .onReady([request](const process::http::Response& response) {
+              logResponse(request, response);
+            });
         });
   route("/state-summary",
         READONLY_HTTP_AUTHENTICATION_REALM,
@@ -975,7 +984,10 @@ void Master::initialize()
         [this](const process::http::Request& request,
                const Option<Principal>& principal) {
           logRequest(request);
-          return http.stateSummary(request, principal);
+          return http.stateSummary(request, principal)
+            .onReady([request](const process::http::Response& response) {
+              logResponse(request, response);
+            });
         });
   route("/tasks",
         READONLY_HTTP_AUTHENTICATION_REALM,
@@ -983,7 +995,10 @@ void Master::initialize()
         [this](const process::http::Request& request,
                const Option<Principal>& principal) {
           logRequest(request);
-          return http.tasks(request, principal);
+          return http.tasks(request, principal)
+            .onReady([request](const process::http::Response& response) {
+              logResponse(request, response);
+            });
         });
   route("/maintenance/schedule",
         READWRITE_HTTP_AUTHENTICATION_REALM,
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 9d84dcb..7bb2b29 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -798,7 +798,10 @@ void Slave::initialize()
         [this](const http::Request& request,
                const Option<Principal>& principal) {
           logRequest(request);
-          return http.state(request, principal);
+          return http.state(request, principal)
+            .onReady([request](const process::http::Response& response) {
+              logResponse(request, response);
+            });
         });
   route("/flags",
         READONLY_HTTP_AUTHENTICATION_REALM,
@@ -827,7 +830,10 @@ void Slave::initialize()
         [this](const http::Request& request,
                const Option<Principal>& principal) {
           logRequest(request);
-          return http.containers(request, principal);
+          return http.containers(request, principal)
+            .onReady([request](const process::http::Response& response) {
+              logResponse(request, response);
+            });
         });
 
   const PID<Slave> slavePid = self();