Bug 1611185 - Make HTTP_CACHE_DISPOSITION_2_V2 probe keyed by content type r=valentin

HTTP_CACHE_DISPOSITION_3 is now keyed by content type. Note that probe HTTP_CACHE_DISPOSITION_2 was removed along with the old cache code, so suffix V2 isn't needed anymore.

Differential Revision: https://phabricator.services.mozilla.com/D61676

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Michal Novotny 2020-02-07 08:35:18 +00:00
Родитель b1e51ad561
Коммит d50cfdb119
3 изменённых файлов: 78 добавлений и 13 удалений

Просмотреть файл

@ -169,8 +169,62 @@ static uint32_t sRCWNMaxWaitMs = 500;
static NS_DEFINE_CID(kStreamListenerTeeCID, NS_STREAMLISTENERTEE_CID);
void AccumulateCacheHitTelemetry(CacheDisposition hitOrMiss) {
Telemetry::Accumulate(Telemetry::HTTP_CACHE_DISPOSITION_2_V2, hitOrMiss);
void AccumulateCacheHitTelemetry(CacheDisposition hitOrMiss,
nsIChannel* aChannel) {
nsCString key("UNKNOWN");
nsCOMPtr<nsILoadInfo> loadInfo;
Unused << aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
nsAutoCString contentType;
if (NS_SUCCEEDED(aChannel->GetContentType(contentType))) {
if (nsContentUtils::IsJavascriptMIMEType(
NS_ConvertUTF8toUTF16(contentType))) {
key.AssignLiteral("JAVASCRIPT");
} else if (StringBeginsWith(contentType, NS_LITERAL_CSTRING("text/css")) ||
(loadInfo && loadInfo->GetExternalContentPolicyType() ==
nsIContentPolicy::TYPE_STYLESHEET)) {
key.AssignLiteral("STYLESHEET");
} else if (StringBeginsWith(contentType,
NS_LITERAL_CSTRING("application/wasm"))) {
key.AssignLiteral("WASM");
} else if (StringBeginsWith(contentType, NS_LITERAL_CSTRING("image/"))) {
key.AssignLiteral("IMAGE");
} else if (StringBeginsWith(contentType, NS_LITERAL_CSTRING("video/"))) {
key.AssignLiteral("MEDIA");
} else if (StringBeginsWith(contentType, NS_LITERAL_CSTRING("audio/"))) {
key.AssignLiteral("MEDIA");
} else if (!StringBeginsWith(contentType,
NS_LITERAL_CSTRING(UNKNOWN_CONTENT_TYPE))) {
key.AssignLiteral("OTHER");
}
}
Telemetry::LABELS_HTTP_CACHE_DISPOSITION_3 label =
Telemetry::LABELS_HTTP_CACHE_DISPOSITION_3::Unresolved;
switch (hitOrMiss) {
case kCacheUnresolved:
label = Telemetry::LABELS_HTTP_CACHE_DISPOSITION_3::Unresolved;
break;
case kCacheHit:
label = Telemetry::LABELS_HTTP_CACHE_DISPOSITION_3::Hit;
break;
case kCacheHitViaReval:
label = Telemetry::LABELS_HTTP_CACHE_DISPOSITION_3::HitViaReval;
break;
case kCacheMissedViaReval:
label = Telemetry::LABELS_HTTP_CACHE_DISPOSITION_3::MissedViaReval;
break;
case kCacheMissed:
label = Telemetry::LABELS_HTTP_CACHE_DISPOSITION_3::Missed;
break;
case kCacheUnknown:
label = Telemetry::LABELS_HTTP_CACHE_DISPOSITION_3::Unknown;
break;
}
Telemetry::AccumulateCategoricalKeyed(key, label);
Telemetry::AccumulateCategoricalKeyed(NS_LITERAL_CSTRING("ALL"), label);
}
// Computes and returns a SHA1 hash of the input buffer. The input buffer
@ -800,7 +854,7 @@ nsresult nsHttpChannel::ContinueConnect() {
event->Revoke();
}
AccumulateCacheHitTelemetry(kCacheHit);
AccumulateCacheHitTelemetry(kCacheHit, this);
mCacheDisposition = kCacheHit;
return rv;
@ -1761,8 +1815,8 @@ void nsHttpChannel::SetCachedContentType() {
NS_ConvertUTF8toUTF16(contentTypeStr))) {
contentType = nsICacheEntry::CONTENT_TYPE_JAVASCRIPT;
} else if (StringBeginsWith(contentTypeStr, NS_LITERAL_CSTRING("text/css")) ||
mLoadInfo->GetExternalContentPolicyType() ==
nsIContentPolicy::TYPE_STYLESHEET) {
(mLoadInfo && mLoadInfo->GetExternalContentPolicyType() ==
nsIContentPolicy::TYPE_STYLESHEET)) {
contentType = nsICacheEntry::CONTENT_TYPE_STYLESHEET;
} else if (StringBeginsWith(contentTypeStr,
NS_LITERAL_CSTRING("application/wasm"))) {
@ -2926,7 +2980,7 @@ void nsHttpChannel::UpdateCacheDisposition(bool aSuccessfulReval,
} else {
cacheDisposition = kCacheMissedViaReval;
}
AccumulateCacheHitTelemetry(cacheDisposition);
AccumulateCacheHitTelemetry(cacheDisposition, this);
mCacheDisposition = cacheDisposition;
Telemetry::Accumulate(Telemetry::HTTP_RESPONSE_VERSION,

Просмотреть файл

@ -3110,13 +3110,26 @@
"kind": "boolean",
"description": "Fraction of sockets that used a nsConnectionEntry with history - size 300."
},
"HTTP_CACHE_DISPOSITION_2_V2": {
"HTTP_CACHE_DISPOSITION_3": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec", "geckoview"],
"products": ["firefox", "geckoview"],
"alert_emails": ["necko@mozilla.com", "mnovotny@mozilla.com"],
"bug_numbers": [1611185],
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 5,
"description": "HTTP Cache v2 Hit, Reval, Failed-Reval, Miss"
"kind": "categorical",
"labels": ["Unresolved", "Hit", "HitViaReval", "MissedViaReval", "Missed", "Unknown"],
"keyed": true,
"keys": [
"ALL",
"UNKNOWN",
"OTHER",
"JAVASCRIPT",
"IMAGE",
"MEDIA",
"STYLESHEET",
"WASM"
],
"description": "HTTP Cache v2 hit/miss stats keyed by content type."
},
"HTTP_CACHE_ENTRY_RELOAD_TIME": {
"record_in_processes": ["main", "content"],

Просмотреть файл

@ -137,7 +137,6 @@
"HTTPCONNMGR_TOTAL_SPECULATIVE_CONN",
"HTTPCONNMGR_UNUSED_SPECULATIVE_CONN",
"HTTPCONNMGR_USED_SPECULATIVE_CONN",
"HTTP_CACHE_DISPOSITION_2_V2",
"HTTP_CACHE_ENTRY_ALIVE_TIME",
"HTTP_CACHE_ENTRY_RELOAD_TIME",
"HTTP_CACHE_ENTRY_REUSE_COUNT",
@ -597,7 +596,6 @@
"HTTPCONNMGR_TOTAL_SPECULATIVE_CONN",
"HTTPCONNMGR_UNUSED_SPECULATIVE_CONN",
"HTTPCONNMGR_USED_SPECULATIVE_CONN",
"HTTP_CACHE_DISPOSITION_2_V2",
"HTTP_CACHE_ENTRY_ALIVE_TIME",
"HTTP_CACHE_ENTRY_RELOAD_TIME",
"HTTP_CACHE_ENTRY_REUSE_COUNT",