You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2015/07/09 00:38:38 UTC

trafficserver git commit: TS-3512: Add stats for HTTP/2

Repository: trafficserver
Updated Branches:
  refs/heads/master 31a3a0362 -> 2de96e8cd


TS-3512: Add stats for HTTP/2


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

Branch: refs/heads/master
Commit: 2de96e8cde48a8ea7edfafffc06bc7899c54226b
Parents: 31a3a03
Author: Bryan Call <bc...@apache.org>
Authored: Wed Jul 8 15:37:36 2015 -0700
Committer: Bryan Call <bc...@apache.org>
Committed: Wed Jul 8 15:37:36 2015 -0700

----------------------------------------------------------------------
 proxy/http2/HTTP2.cc               | 24 +++++++++++++++++++++++-
 proxy/http2/HTTP2.h                | 16 ++++++++++++++++
 proxy/http2/Http2ClientSession.cc  |  8 ++++++--
 proxy/http2/Http2ConnectionState.h |  8 ++++++++
 4 files changed, 53 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2de96e8c/proxy/http2/HTTP2.cc
----------------------------------------------------------------------
diff --git a/proxy/http2/HTTP2.cc b/proxy/http2/HTTP2.cc
index 5a6637b..76017b3 100644
--- a/proxy/http2/HTTP2.cc
+++ b/proxy/http2/HTTP2.cc
@@ -25,11 +25,20 @@
 #include "HPACK.h"
 #include "HuffmanCodec.h"
 #include "ink_assert.h"
-#include "I_RecCore.h"
+#include "P_RecCore.h"
+#include "P_RecProcess.h"
 
 const char *const HTTP2_CONNECTION_PREFACE = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n";
 static size_t HPACK_LEN_STATUS_VALUE_STR = 3;
 
+// Statistics
+RecRawStatBlock *http2_rsb;
+static char const *const HTTP2_STAT_CURRENT_CLIENT_SESSION_NAME = "proxy.process.http2.current_client_sessions";
+static char const *const HTTP2_STAT_CURRENT_CLIENT_STREAM_NAME = "proxy.process.http2.current_client_streams";
+static char const *const HTTP2_STAT_TOTAL_CLIENT_STREAM_NAME = "proxy.process.http2.total_client_streams";
+static char const *const HTTP2_STAT_TOTAL_TRANSACTIONS_TIME_NAME = "proxy.process.http2.total_transactions_time";
+static char const *const HTTP2_STAT_TOTAL_CLIENT_CONNECTION_NAME = "proxy.process.http2.total_client_connections";
+
 union byte_pointer {
   byte_pointer(void *p) : ptr(p) {}
 
@@ -764,6 +773,19 @@ Http2::init()
   REC_EstablishStaticConfigInt32U(max_frame_size, "proxy.config.http2.max_frame_size");
   REC_EstablishStaticConfigInt32U(header_table_size, "proxy.config.http2.header_table_size");
   REC_EstablishStaticConfigInt32U(max_header_list_size, "proxy.config.http2.max_header_list_size");
+
+  // Setup statistics
+  http2_rsb = RecAllocateRawStatBlock(static_cast<int>(HTTP2_N_STATS));
+  RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_CURRENT_CLIENT_SESSION_NAME, RECD_INT, RECP_NON_PERSISTENT,
+                     static_cast<int>(HTTP2_STAT_CURRENT_CLIENT_SESSION_COUNT), RecRawStatSyncSum);
+  RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_CURRENT_CLIENT_STREAM_NAME, RECD_INT, RECP_NON_PERSISTENT,
+                     static_cast<int>(HTTP2_STAT_CURRENT_CLIENT_STREAM_COUNT), RecRawStatSyncSum);
+  RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_TOTAL_CLIENT_STREAM_NAME, RECD_INT, RECP_PERSISTENT,
+                     static_cast<int>(HTTP2_STAT_TOTAL_TRANSACTIONS_TIME), RecRawStatSyncCount);
+  RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_TOTAL_TRANSACTIONS_TIME_NAME, RECD_INT, RECP_PERSISTENT,
+                     static_cast<int>(HTTP2_STAT_TOTAL_TRANSACTIONS_TIME), RecRawStatSyncSum);
+  RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_TOTAL_CLIENT_CONNECTION_NAME, RECD_INT, RECP_PERSISTENT,
+                     static_cast<int>(HTTP2_STAT_TOTAL_CLIENT_CONNECTION_COUNT), RecRawStatSyncSum);
 }
 
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2de96e8c/proxy/http2/HTTP2.h
----------------------------------------------------------------------
diff --git a/proxy/http2/HTTP2.h b/proxy/http2/HTTP2.h
index bbeffd3..97b187d 100644
--- a/proxy/http2/HTTP2.h
+++ b/proxy/http2/HTTP2.h
@@ -28,6 +28,7 @@
 #include "ink_memory.h"
 #include "HPACK.h"
 #include "MIME.h"
+#include "P_RecDefs.h"
 
 class HTTPHdr;
 
@@ -59,6 +60,21 @@ const uint32_t HTTP2_MAX_FRAME_SIZE = 16384;
 const uint32_t HTTP2_HEADER_TABLE_SIZE = 4096;
 const uint32_t HTTP2_MAX_HEADER_LIST_SIZE = UINT_MAX;
 
+// Statistics
+enum {
+  HTTP2_STAT_CURRENT_CLIENT_SESSION_COUNT,  // Current # of active HTTP2 sessions.
+  HTTP2_STAT_CURRENT_CLIENT_STREAM_COUNT,   // Current # of active HTTP2 streams.
+  HTTP2_STAT_TOTAL_TRANSACTIONS_TIME,       // Total stream time and streams
+  HTTP2_STAT_TOTAL_CLIENT_CONNECTION_COUNT, // Total connections running http2
+
+  HTTP2_N_STATS // Terminal counter, NOT A STAT INDEX.
+};
+
+#define HTTP2_INCREMENT_THREAD_DYN_STAT(_s, _t) RecIncrRawStat(http2_rsb, _t, (int)_s, 1);
+#define HTTP2_DECREMENT_THREAD_DYN_STAT(_s, _t) RecIncrRawStat(http2_rsb, _t, (int)_s, -1);
+#define HTTP2_SUM_THREAD_DYN_STAT(_s, _t, _v) RecIncrRawStat(http2_rsb, _t, (int)_s, _v);
+extern RecRawStatBlock *http2_rsb; // Container for statistics.
+
 // 6.9.1 The Flow Control Window
 static const Http2WindowSize HTTP2_MAX_WINDOW_SIZE = 0x7FFFFFFF;
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2de96e8c/proxy/http2/Http2ClientSession.cc
----------------------------------------------------------------------
diff --git a/proxy/http2/Http2ClientSession.cc b/proxy/http2/Http2ClientSession.cc
index 40c4a50..93c7e3c 100644
--- a/proxy/http2/Http2ClientSession.cc
+++ b/proxy/http2/Http2ClientSession.cc
@@ -104,6 +104,10 @@ Http2ClientSession::start()
 void
 Http2ClientSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOBufferReader *reader, bool backdoor)
 {
+  ink_assert(new_vc->mutex->thread_holding == this_ethread());
+  HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_CLIENT_SESSION_COUNT, new_vc->mutex->thread_holding);
+  HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_TOTAL_CLIENT_CONNECTION_COUNT, new_vc->mutex->thread_holding);
+
   // HTTP/2 for the backdoor connections? Let's not deal woth that yet.
   ink_release_assert(backdoor == false);
 
@@ -189,9 +193,9 @@ Http2ClientSession::do_io_close(int alerrno)
 {
   DebugHttp2Ssn0("session closed");
 
+  ink_assert(this->mutex->thread_holding == this_ethread());
+  HTTP2_DECREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_CLIENT_SESSION_COUNT, this->mutex->thread_holding);
   send_connection_event(&this->connection_state, HTTP2_SESSION_EVENT_FINI, this);
-
-
   do_api_callout(TS_HTTP_SSN_CLOSE_HOOK);
 }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2de96e8c/proxy/http2/Http2ConnectionState.h
----------------------------------------------------------------------
diff --git a/proxy/http2/Http2ConnectionState.h b/proxy/http2/Http2ConnectionState.h
index 61526f0..9c05ab4 100644
--- a/proxy/http2/Http2ConnectionState.h
+++ b/proxy/http2/Http2ConnectionState.h
@@ -102,11 +102,17 @@ public:
     : client_rwnd(initial_rwnd), server_rwnd(initial_rwnd), _id(sid), _state(HTTP2_STREAM_STATE_IDLE), _fetch_sm(NULL),
       body_done(false), data_length(0)
   {
+    _thread = this_ethread();
+    HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_CLIENT_STREAM_COUNT, _thread);
+    _start_time = ink_hrtime();
     _req_header.create(HTTP_TYPE_REQUEST);
   }
 
   ~Http2Stream()
   {
+    HTTP2_DECREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_CLIENT_STREAM_COUNT, _thread);
+    ink_hrtime end_time = ink_hrtime();
+    HTTP2_SUM_THREAD_DYN_STAT(HTTP2_STAT_TOTAL_TRANSACTIONS_TIME, _thread, end_time - _start_time);
     _req_header.destroy();
 
     if (_fetch_sm) {
@@ -171,6 +177,8 @@ public:
   LINK(Http2Stream, link);
 
 private:
+  ink_hrtime _start_time;
+  EThread *_thread;
   Http2StreamId _id;
   Http2StreamState _state;