bug 805457 telemetry for proxy and websocket connections r=jduell

This commit is contained in:
Patrick McManus 2012-10-27 15:24:19 -04:00
parent 4b539187c5
commit d72702ebef
5 changed files with 69 additions and 7 deletions

View File

@ -1670,6 +1670,19 @@ nsHttpConnectionMgr::BuildPipeline(nsConnectionEntry *ent,
return NS_OK;
}
void
nsHttpConnectionMgr::ReportProxyTelemetry(nsConnectionEntry *ent)
{
enum { PROXY_NONE = 1, PROXY_HTTP = 2, PROXY_SOCKS = 3 };
if (!ent->mConnInfo->UsingProxy())
Telemetry::Accumulate(Telemetry::HTTP_PROXY_TYPE, PROXY_NONE);
else if (ent->mConnInfo->UsingHttpProxy())
Telemetry::Accumulate(Telemetry::HTTP_PROXY_TYPE, PROXY_HTTP);
else
Telemetry::Accumulate(Telemetry::HTTP_PROXY_TYPE, PROXY_SOCKS);
}
nsresult
nsHttpConnectionMgr::ProcessNewTransaction(nsHttpTransaction *trans)
{
@ -1703,6 +1716,8 @@ nsHttpConnectionMgr::ProcessNewTransaction(nsHttpTransaction *trans)
ent = preferredEntry;
}
ReportProxyTelemetry(ent);
// If we are doing a force reload then close out any existing conns
// to this host so that changes in DNS, LBs, etc.. are reflected
if (trans->Caps() & NS_HTTP_CLEAR_KEEPALIVES)

View File

@ -481,6 +481,7 @@ private:
nsresult ProcessNewTransaction(nsHttpTransaction *);
nsresult EnsureSocketThreadTarget();
void ClosePersistentConnections(nsConnectionEntry *ent);
void ReportProxyTelemetry(nsConnectionEntry *ent);
nsresult CreateTransport(nsConnectionEntry *, nsAHttpTransaction *,
uint8_t, bool);
void AddActiveConn(nsHttpConnection *, nsConnectionEntry *);

View File

@ -20,6 +20,8 @@
#include "nsIStreamConverterService.h"
#include "nsIIOService2.h"
#include "nsIProtocolProxyService.h"
#include "nsIProxyInfo.h"
#include "nsIProxiedChannel.h"
#include "nsAutoPtr.h"
#include "nsStandardURL.h"
@ -35,6 +37,7 @@
#include "nsNetUtil.h"
#include "mozilla/Attributes.h"
#include "TimeStamp.h"
#include "mozilla/Telemetry.h"
#include "plbase64.h"
#include "prmem.h"
@ -917,7 +920,7 @@ WebSocketChannel::WebSocketChannel() :
mPingTimeout(0),
mPingResponseTimeout(10000),
mMaxConcurrentConnections(200),
mRecvdHttpOnStartRequest(0),
mGotUpgradeOK(0),
mRecvdHttpUpgradeTransport(0),
mRequestedClose(0),
mClientClosed(0),
@ -2187,6 +2190,36 @@ WebSocketChannel::StartWebsocketData()
return mSocketIn->AsyncWait(this, 0, 0, mSocketThread);
}
void
WebSocketChannel::ReportConnectionTelemetry()
{
// 3 bits are used. high bit is for wss, middle bit for failed,
// and low bit for proxy..
// 0 - 7 : ws-ok-plain, ws-ok-proxy, ws-failed-plain, ws-failed-proxy,
// wss-ok-plain, wss-ok-proxy, wss-failed-plain, wss-failed-proxy
bool didProxy = false;
nsCOMPtr<nsIProxyInfo> pi;
nsCOMPtr<nsIProxiedChannel> pc = do_QueryInterface(mChannel);
if (pc)
pc->GetProxyInfo(getter_AddRefs(pi));
if (pi) {
nsAutoCString proxyType;
pi->GetType(proxyType);
if (!proxyType.IsEmpty() &&
!proxyType.Equals(NS_LITERAL_CSTRING("direct")))
didProxy = true;
}
uint8_t value = (mEncrypted ? (1 << 2) : 0) |
(!mGotUpgradeOK ? (1 << 1) : 0) |
(didProxy ? (1 << 0) : 0);
LOG(("WebSocketChannel::ReportConnectionTelemetry() %p %d", this, value));
Telemetry::Accumulate(Telemetry::WEBSOCKETS_HANDSHAKE_TYPE, value);
}
// nsIDNSListener
NS_IMETHODIMP
@ -2380,7 +2413,7 @@ WebSocketChannel::Notify(nsITimer *timer)
LOG(("WebSocketChannel:: Expecting Server Close - Timed Out\n"));
AbortSession(NS_ERROR_NET_TIMEOUT);
} else if (timer == mOpenTimer) {
NS_ABORT_IF_FALSE(!mRecvdHttpOnStartRequest,
NS_ABORT_IF_FALSE(!mGotUpgradeOK,
"Open Timer after open complete");
NS_ABORT_IF_FALSE(NS_IsMainThread(), "not main thread");
@ -2717,7 +2750,7 @@ WebSocketChannel::OnTransportAvailable(nsISocketTransport *aTransport,
}
LOG(("WebSocketChannel::OnTransportAvailable %p [%p %p %p] rcvdonstart=%d\n",
this, aTransport, aSocketIn, aSocketOut, mRecvdHttpOnStartRequest));
this, aTransport, aSocketIn, aSocketOut, mGotUpgradeOK));
NS_ABORT_IF_FALSE(NS_IsMainThread(), "not main thread");
NS_ABORT_IF_FALSE(!mRecvdHttpUpgradeTransport, "OTA duplicated");
@ -2734,7 +2767,7 @@ WebSocketChannel::OnTransportAvailable(nsISocketTransport *aTransport,
if (NS_FAILED(rv)) return rv;
mRecvdHttpUpgradeTransport = 1;
if (mRecvdHttpOnStartRequest)
if (mGotUpgradeOK)
return StartWebsocketData();
return NS_OK;
}
@ -2748,7 +2781,7 @@ WebSocketChannel::OnStartRequest(nsIRequest *aRequest,
LOG(("WebSocketChannel::OnStartRequest(): %p [%p %p] recvdhttpupgrade=%d\n",
this, aRequest, aContext, mRecvdHttpUpgradeTransport));
NS_ABORT_IF_FALSE(NS_IsMainThread(), "not main thread");
NS_ABORT_IF_FALSE(!mRecvdHttpOnStartRequest, "OTA duplicated");
NS_ABORT_IF_FALSE(!mGotUpgradeOK, "OTA duplicated");
if (mOpenTimer) {
mOpenTimer->Cancel();
@ -2881,7 +2914,7 @@ WebSocketChannel::OnStartRequest(nsIRequest *aRequest,
if (NS_FAILED(rv))
return rv;
mRecvdHttpOnStartRequest = 1;
mGotUpgradeOK = 1;
if (mRecvdHttpUpgradeTransport)
return StartWebsocketData();
@ -2897,6 +2930,8 @@ WebSocketChannel::OnStopRequest(nsIRequest *aRequest,
this, aRequest, aContext, aStatusCode));
NS_ABORT_IF_FALSE(NS_IsMainThread(), "not main thread");
ReportConnectionTelemetry();
// This is the end of the HTTP upgrade transaction, the
// upgraded streams live on

View File

@ -132,6 +132,7 @@ private:
nsresult ApplyForAdmission();
nsresult StartWebsocketData();
uint16_t ResultToCloseCode(nsresult resultCode);
void ReportConnectionTelemetry();
void StopSession(nsresult reason);
void AbortSession(nsresult reason);
@ -186,7 +187,7 @@ private:
int32_t mMaxConcurrentConnections;
uint32_t mRecvdHttpOnStartRequest : 1;
uint32_t mGotUpgradeOK : 1;
uint32_t mRecvdHttpUpgradeTransport : 1;
uint32_t mRequestedClose : 1;
uint32_t mClientClosed : 1;

View File

@ -701,6 +701,16 @@
"n_buckets": 50,
"description": "HTTP subitem: Overall load time - network (ms)"
},
"HTTP_PROXY_TYPE": {
"kind": "enumerated",
"n_values": 8,
"description": "HTTP Proxy Type (none, http, socks)"
},
"WEBSOCKETS_HANDSHAKE_TYPE": {
"kind": "enumerated",
"n_values": 16,
"description": "Websockets Handshake Results (ws-ok-plain, ws-ok-proxy, ws-failed-plain, ws-failed-proxy, wss-ok-plain, wss-ok-proxy, wss-failed-plain, wss-failed-proxy)"
},
"SPDY_VERSION2": {
"kind": "enumerated",
"n_values": 48,