diff options
author | James M Snell <jasnell@gmail.com> | 2018-01-06 11:50:58 -0800 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2018-01-09 12:33:13 -0800 |
commit | a02fcd2716b6d35123396e1fe73ef2439fa1192a (patch) | |
tree | 6e3e03c2ed35a99f1a6c7de287ef3a4ef715c12b /src/node_http2.h | |
parent | ececdd316766998ca3309ccb01f5618d44d0d91e (diff) | |
download | android-node-v8-a02fcd2716b6d35123396e1fe73ef2439fa1192a.tar.gz android-node-v8-a02fcd2716b6d35123396e1fe73ef2439fa1192a.tar.bz2 android-node-v8-a02fcd2716b6d35123396e1fe73ef2439fa1192a.zip |
http2: use aliased buffer for perf stats, add stats
Add an aliased buffer for session and stream statistics,
add a few more metrics
PR-URL: https://github.com/nodejs/node/pull/18020
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Diffstat (limited to 'src/node_http2.h')
-rw-r--r-- | src/node_http2.h | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/src/node_http2.h b/src/node_http2.h index 4fc98f0c68..765f729476 100644 --- a/src/node_http2.h +++ b/src/node_http2.h @@ -715,8 +715,11 @@ class Http2Stream : public AsyncWrap, struct Statistics { uint64_t start_time; uint64_t end_time; - uint64_t first_header; // Time first header was received - uint64_t first_byte; // Time first data frame byte was received + uint64_t first_header; // Time first header was received + uint64_t first_byte; // Time first DATA frame byte was received + uint64_t first_byte_sent; // Time first DATA frame byte was sent + uint64_t sent_bytes; + uint64_t received_bytes; }; Statistics statistics_ = {}; @@ -949,8 +952,12 @@ class Http2Session : public AsyncWrap { uint64_t start_time; uint64_t end_time; uint64_t ping_rtt; + uint64_t data_sent; + uint64_t data_received; uint32_t frame_count; + uint32_t frame_sent; int32_t stream_count; + size_t max_concurrent_streams; double stream_average_duration; }; @@ -995,6 +1002,10 @@ class Http2Session : public AsyncWrap { const nghttp2_frame* frame, int error_code, void* user_data); + static inline int OnFrameSent( + nghttp2_session* session, + const nghttp2_frame* frame, + void* user_data); static inline int OnStreamClose( nghttp2_session* session, int32_t id, @@ -1115,21 +1126,29 @@ class Http2SessionPerformanceEntry : public PerformanceEntry { Http2SessionPerformanceEntry( Environment* env, const Http2Session::Statistics& stats, - const char* kind) : + nghttp2_session_type type) : PerformanceEntry(env, "Http2Session", "http2", stats.start_time, stats.end_time), ping_rtt_(stats.ping_rtt), + data_sent_(stats.data_sent), + data_received_(stats.data_received), frame_count_(stats.frame_count), + frame_sent_(stats.frame_sent), stream_count_(stats.stream_count), + max_concurrent_streams_(stats.max_concurrent_streams), stream_average_duration_(stats.stream_average_duration), - kind_(kind) { } + session_type_(type) { } uint64_t ping_rtt() const { return ping_rtt_; } + uint64_t data_sent() const { return data_sent_; } + uint64_t data_received() const { return data_received_; } uint32_t frame_count() const { return frame_count_; } + uint32_t frame_sent() const { return frame_sent_; } int32_t stream_count() const { return stream_count_; } + size_t max_concurrent_streams() const { return max_concurrent_streams_; } double stream_average_duration() const { return stream_average_duration_; } - const char* typeName() const { return kind_; } + nghttp2_session_type type() const { return session_type_; } void Notify(Local<Value> obj) { PerformanceEntry::Notify(env(), kind(), obj); @@ -1137,33 +1156,50 @@ class Http2SessionPerformanceEntry : public PerformanceEntry { private: uint64_t ping_rtt_; + uint64_t data_sent_; + uint64_t data_received_; uint32_t frame_count_; + uint32_t frame_sent_; int32_t stream_count_; + size_t max_concurrent_streams_; double stream_average_duration_; - const char* kind_; + nghttp2_session_type session_type_; }; class Http2StreamPerformanceEntry : public PerformanceEntry { public: Http2StreamPerformanceEntry( Environment* env, + int32_t id, const Http2Stream::Statistics& stats) : PerformanceEntry(env, "Http2Stream", "http2", stats.start_time, stats.end_time), + id_(id), first_header_(stats.first_header), - first_byte_(stats.first_byte) { } + first_byte_(stats.first_byte), + first_byte_sent_(stats.first_byte_sent), + sent_bytes_(stats.sent_bytes), + received_bytes_(stats.received_bytes) { } + int32_t id() const { return id_; } uint64_t first_header() const { return first_header_; } uint64_t first_byte() const { return first_byte_; } + uint64_t first_byte_sent() const { return first_byte_sent_; } + uint64_t sent_bytes() const { return sent_bytes_; } + uint64_t received_bytes() const { return received_bytes_; } void Notify(Local<Value> obj) { PerformanceEntry::Notify(env(), kind(), obj); } private: + int32_t id_; uint64_t first_header_; uint64_t first_byte_; + uint64_t first_byte_sent_; + uint64_t sent_bytes_; + uint64_t received_bytes_; }; class Http2Session::Http2Ping : public AsyncWrap { |