Skip to content

Commit

Permalink
Bug 1879848 - Record telemetry for which Proxy types are used r=necko…
Browse files Browse the repository at this point in the history
…-reviewers,jesup

Differential Revision: https://phabricator.services.mozilla.com/D201384
  • Loading branch information
mb committed Feb 21, 2024
1 parent bacaa32 commit 789fbdb
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
31 changes: 31 additions & 0 deletions netwerk/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,37 @@ networking:
- [email protected]
expires: never

proxy_info_type:
type: labeled_counter
description: >
The proxies configurations created in the browser session (SOCKSv4, SOCKSv5, HTTP, HTTPS)
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1879848
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1879848
data_sensitivity:
- technical
notification_emails:
- [email protected]
- [email protected]
expires: 129
labels:
- http
- https
# SOCKS4 Proxy
- socks4
# SOCKS4a Proxy. Proxy resolves URL hostname
- socks4a
# SOCKS5 Proxy
- socks5
# SOCKS5 Proxy. Proxy resolves URL hostname
# Use convention from curl for socks5 proxies that resolve the hostname
# https://curl.se/libcurl/c/CURLOPT_PROXY.html
- socks5h
# No proxy
- direct
- unknown

transaction_wait_time:
type: timing_distribution
time_unit: millisecond
Expand Down
49 changes: 48 additions & 1 deletion netwerk/protocol/http/nsHttpChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6953,7 +6953,54 @@ nsHttpChannel::OnProxyAvailable(nsICancelable* request, nsIChannel* channel,
// request was canceled. We just failover to DIRECT when proxy resolution
// fails (failure can mean that the PAC URL could not be loaded).

if (NS_SUCCEEDED(status)) mProxyInfo = pi;
if (NS_SUCCEEDED(status)) {
mProxyInfo = pi;

if (mProxyInfo) {
nsAutoCStringN<8> type;
mProxyInfo->GetType(type);
uint32_t flags = 0;
mProxyInfo->GetFlags(&flags);
printf("type=%s, flags=%i\n", type.get(), flags);
if (type.EqualsLiteral("socks")) {
if (flags & nsIProxyInfo::TRANSPARENT_PROXY_RESOLVES_HOST) {
glean::networking::proxy_info_type
.EnumGet(glean::networking::ProxyInfoTypeLabel::eSocks5h)
.Add(1);
} else {
glean::networking::proxy_info_type
.EnumGet(glean::networking::ProxyInfoTypeLabel::eSocks5)
.Add(1);
}
} else if (type.EqualsLiteral("socks4")) {
if (flags & nsIProxyInfo::TRANSPARENT_PROXY_RESOLVES_HOST) {
glean::networking::proxy_info_type
.EnumGet(glean::networking::ProxyInfoTypeLabel::eSocks4a)
.Add(1);
} else {
glean::networking::proxy_info_type
.EnumGet(glean::networking::ProxyInfoTypeLabel::eSocks4)
.Add(1);
}
} else if (type.EqualsLiteral("http")) {
glean::networking::proxy_info_type
.EnumGet(glean::networking::ProxyInfoTypeLabel::eHttp)
.Add(1);
} else if (type.EqualsLiteral("https")) {
glean::networking::proxy_info_type
.EnumGet(glean::networking::ProxyInfoTypeLabel::eHttps)
.Add(1);
} else if (type.EqualsLiteral("direct")) {
glean::networking::proxy_info_type
.EnumGet(glean::networking::ProxyInfoTypeLabel::eDirect)
.Add(1);
} else {
glean::networking::proxy_info_type
.EnumGet(glean::networking::ProxyInfoTypeLabel::eUnknown)
.Add(1);
}
}
}

if (!gHttpHandler->Active()) {
LOG(
Expand Down

0 comments on commit 789fbdb

Please sign in to comment.