From 70b6a3456b4e63ebb7975c4bb3d489e86af10468 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 20 Aug 2018 15:11:14 +0000 Subject: [PATCH] bug 1470853 - Add Telemetry::DNS_TRR_REQUEST_PER_CONN r=nwgh Count number of requests/streams per connection done when the connection was used for TRR. MozReview-Commit-ID: H7X06h8gVZY Differential Revision: https://phabricator.services.mozilla.com/D3589 --HG-- extra : moz-landing-system : lando --- netwerk/protocol/http/Http2Session.cpp | 11 +++++++++++ netwerk/protocol/http/Http2Session.h | 1 + netwerk/protocol/http/nsHttpChannel.cpp | 1 + netwerk/protocol/http/nsHttpConnection.cpp | 13 +++++++++++++ netwerk/protocol/http/nsHttpConnectionInfo.cpp | 2 ++ netwerk/protocol/http/nsHttpConnectionInfo.h | 4 ++++ toolkit/components/telemetry/Histograms.json | 10 ++++++++++ 7 files changed, 42 insertions(+) diff --git a/netwerk/protocol/http/Http2Session.cpp b/netwerk/protocol/http/Http2Session.cpp index 2ad359c11a9a..3627dd919470 100644 --- a/netwerk/protocol/http/Http2Session.cpp +++ b/netwerk/protocol/http/Http2Session.cpp @@ -121,6 +121,7 @@ Http2Session::Http2Session(nsISocketTransport *aSocketTransport, enum SpdyVersio , mTlsHandshakeFinished(false) , mCheckNetworkStallsWithTFO(false) , mLastRequestBytesSentTime(0) + , mTrrStreams(0) { MOZ_ASSERT(OnSocketThread(), "not on socket thread"); @@ -179,6 +180,9 @@ Http2Session::~Http2Session() Shutdown(); + if (mTrrStreams) { + Telemetry::Accumulate(Telemetry::DNS_TRR_REQUEST_PER_CONN, mTrrStreams); + } Telemetry::Accumulate(Telemetry::SPDY_PARALLEL_STREAMS, mConcurrentHighWater); Telemetry::Accumulate(Telemetry::SPDY_REQUEST_PER_CONN, (mNextStreamID - 1) / 2); Telemetry::Accumulate(Telemetry::SPDY_SERVER_INITIATED_STREAMS, @@ -400,6 +404,13 @@ Http2Session::RegisterStreamID(Http2Stream *stream, uint32_t aNewID) mLastRequestBytesSentTime = PR_IntervalNow(); } } + + MOZ_ASSERT(stream->Transaction(), "no transation for the stream!"); + RefPtr ci(stream->Transaction()->ConnectionInfo()); + if (ci && ci->GetTrrUsed()) { + mTrrStreams++; + } + return aNewID; } diff --git a/netwerk/protocol/http/Http2Session.h b/netwerk/protocol/http/Http2Session.h index 84d633cd2604..980b91750440 100644 --- a/netwerk/protocol/http/Http2Session.h +++ b/netwerk/protocol/http/Http2Session.h @@ -574,6 +574,7 @@ private: void UnRegisterTunnel(Http2Stream *); uint32_t FindTunnelCount(nsHttpConnectionInfo *); nsDataHashtable mTunnelHash; + uint32_t mTrrStreams; }; } // namespace net diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 37081eaff7f4..214d7b62b9d2 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -571,6 +571,7 @@ nsHttpChannel::OnBeforeConnect() mConnectionInfo->SetNoSpdy(mCaps & NS_HTTP_DISALLOW_SPDY); mConnectionInfo->SetBeConservative((mCaps & NS_HTTP_BE_CONSERVATIVE) || mBeConservative); mConnectionInfo->SetTlsFlags(mTlsFlags); + mConnectionInfo->SetTrrUsed(mTRR); // notify "http-on-before-connect" observers gHttpHandler->OnBeforeConnect(this); diff --git a/netwerk/protocol/http/nsHttpConnection.cpp b/netwerk/protocol/http/nsHttpConnection.cpp index 31543812fbdf..3ac0f60c74b8 100644 --- a/netwerk/protocol/http/nsHttpConnection.cpp +++ b/netwerk/protocol/http/nsHttpConnection.cpp @@ -123,6 +123,19 @@ nsHttpConnection::~nsHttpConnection() this, mHttp1xTransactionCount)); Telemetry::Accumulate(Telemetry::HTTP_REQUEST_PER_CONN, mHttp1xTransactionCount); + nsHttpConnectionInfo *ci = nullptr; + if (mTransaction) { + ci = mTransaction->ConnectionInfo(); + } + if (!ci) { + ci = mConnInfo; + } + + MOZ_ASSERT(ci); + if (ci->GetTrrUsed()) { + Telemetry::Accumulate(Telemetry::DNS_TRR_REQUEST_PER_CONN, + mHttp1xTransactionCount); + } } if (mTotalBytesRead) { diff --git a/netwerk/protocol/http/nsHttpConnectionInfo.cpp b/netwerk/protocol/http/nsHttpConnectionInfo.cpp index ab246bc22e6c..8e05c4eece64 100644 --- a/netwerk/protocol/http/nsHttpConnectionInfo.cpp +++ b/netwerk/protocol/http/nsHttpConnectionInfo.cpp @@ -89,6 +89,7 @@ nsHttpConnectionInfo::Init(const nsACString &host, int32_t port, mNPNToken = npnToken; mOriginAttributes = originAttributes; mTlsFlags = 0x0; + mTrrUsed = false; mUsingHttpsProxy = (proxyInfo && proxyInfo->IsHTTPS()); mUsingHttpProxy = mUsingHttpsProxy || (proxyInfo && proxyInfo->IsHTTP()); @@ -242,6 +243,7 @@ nsHttpConnectionInfo::Clone() const clone->SetNoSpdy(GetNoSpdy()); clone->SetBeConservative(GetBeConservative()); clone->SetTlsFlags(GetTlsFlags()); + clone->SetTrrUsed(GetTrrUsed()); MOZ_ASSERT(clone->Equals(this)); return clone; diff --git a/netwerk/protocol/http/nsHttpConnectionInfo.h b/netwerk/protocol/http/nsHttpConnectionInfo.h index e0c2c9c24a01..a2c5e255c79e 100644 --- a/netwerk/protocol/http/nsHttpConnectionInfo.h +++ b/netwerk/protocol/http/nsHttpConnectionInfo.h @@ -120,6 +120,9 @@ public: void SetTlsFlags(uint32_t aTlsFlags); uint32_t GetTlsFlags() const { return mTlsFlags; } + void SetTrrUsed(bool aUsed) { mTrrUsed = aUsed; } + bool GetTrrUsed() const { return mTrrUsed; } + const nsCString &GetNPNToken() { return mNPNToken; } const nsCString &GetUsername() { return mUsername; } @@ -172,6 +175,7 @@ private: OriginAttributes mOriginAttributes; uint32_t mTlsFlags; + uint16_t mTrrUsed : 1; // for RefPtr NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsHttpConnectionInfo, override) diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index f3153daa3258..507d6e6b039d 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -3330,6 +3330,16 @@ "bug_numbers": [1453825], "alert_emails": ["necko@mozilla.com", "dstenberg@mozilla.com"] }, + "DNS_TRR_REQUEST_PER_CONN": { + "record_in_processes": ["main", "content"], + "alert_emails": ["necko@mozilla.com", "dstenberg@mozilla.com"], + "expires_in_version": "never", + "kind": "exponential", + "high": 5000, + "n_buckets": 100, + "bug_numbers": [1470853], + "description": "Number of DOH requests per connection" + }, "DNS_LOOKUP_ALGORITHM": { "record_in_processes": ["main"], "alert_emails": ["necko@mozilla.com", "dstenberg@mozilla.com"],