mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1423623 - Add telemetry for alternate data stream on service worker synthesized channels. r=bkelly, data-r=francois
1. Create a new telemetry scalar SW_ALTERNATIVE_BODY_USED_COUNT to count the number of the alternative body used in service worker synthesized channels. 2. To report values of fetching related time of InterceptChannel according to the detail subresource type. Now subresource/script, subresource/other, subresource/image and subresource/stylesheet are provided, and keep using subresource for other types.
This commit is contained in:
parent
4a3769fa44
commit
3fd3115e94
@ -358,6 +358,8 @@ public:
|
||||
}
|
||||
if (!body) {
|
||||
mInternalResponse->GetUnfilteredBody(getter_AddRefs(body));
|
||||
} else {
|
||||
Telemetry::ScalarAdd(Telemetry::ScalarID::SW_ALTERNATIVE_BODY_USED_COUNT, 1);
|
||||
}
|
||||
|
||||
RefPtr<BodyCopyHandle> copyHandle;
|
||||
|
@ -14,7 +14,10 @@ interface nsIOutputStream;
|
||||
interface nsIURI;
|
||||
|
||||
%{C++
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIConsoleReportCollector.h"
|
||||
#include "nsILoadInfo.h"
|
||||
namespace mozilla {
|
||||
class TimeStamp;
|
||||
|
||||
@ -184,6 +187,42 @@ interface nsIInterceptedChannel : nsISupports
|
||||
GetConsoleReportCollector(getter_AddRefs(reporter));
|
||||
return reporter.forget();
|
||||
}
|
||||
|
||||
void
|
||||
GetSubresourceTimeStampKey(nsIChannel* aChannel, nsACString& aKey)
|
||||
{
|
||||
if (!nsContentUtils::IsNonSubresourceRequest(aChannel)) {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
|
||||
if (loadInfo) {
|
||||
switch(loadInfo->InternalContentPolicyType()) {
|
||||
case nsIContentPolicy::TYPE_SCRIPT:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_SCRIPT:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_SCRIPT_PRELOAD:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_WORKER_IMPORT_SCRIPTS: {
|
||||
aKey = NS_LITERAL_CSTRING("subresource-script");
|
||||
break;
|
||||
}
|
||||
case nsIContentPolicy::TYPE_IMAGE:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_IMAGE:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_IMAGE_PRELOAD:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON: {
|
||||
aKey = NS_LITERAL_CSTRING("subresource-image");
|
||||
break;
|
||||
}
|
||||
case nsIContentPolicy::TYPE_STYLESHEET:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_STYLESHEET:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD: {
|
||||
aKey = NS_LITERAL_CSTRING("subresource-stylesheet");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
aKey = NS_LITERAL_CSTRING("subresource-other");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
/**
|
||||
|
@ -169,9 +169,13 @@ InterceptedChannelBase::SaveTimeStamps()
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCString navigationOrSubresource = nsContentUtils::IsNonSubresourceRequest(channel) ?
|
||||
bool isNonSubresourceRequest = nsContentUtils::IsNonSubresourceRequest(channel);
|
||||
nsCString navigationOrSubresource = isNonSubresourceRequest ?
|
||||
NS_LITERAL_CSTRING("navigation") : NS_LITERAL_CSTRING("subresource");
|
||||
|
||||
nsAutoCString subresourceKey(EmptyCString());
|
||||
GetSubresourceTimeStampKey(channel, subresourceKey);
|
||||
|
||||
// We may have null timestamps if the fetch dispatch runnable was cancelled
|
||||
// and we defaulted to resuming the request.
|
||||
if (!mFinishResponseStart.IsNull() && !mFinishResponseEnd.IsNull()) {
|
||||
@ -182,16 +186,31 @@ InterceptedChannelBase::SaveTimeStamps()
|
||||
Telemetry::SERVICE_WORKER_FETCH_EVENT_CHANNEL_RESET_MS;
|
||||
Telemetry::Accumulate(id, navigationOrSubresource,
|
||||
static_cast<uint32_t>((mFinishResponseEnd - mFinishResponseStart).ToMilliseconds()));
|
||||
if (!isNonSubresourceRequest && !subresourceKey.IsEmpty()) {
|
||||
Telemetry::Accumulate(id, subresourceKey,
|
||||
static_cast<uint32_t>((mFinishResponseEnd - mFinishResponseStart).ToMilliseconds()));
|
||||
}
|
||||
}
|
||||
|
||||
Telemetry::Accumulate(Telemetry::SERVICE_WORKER_FETCH_EVENT_DISPATCH_MS,
|
||||
navigationOrSubresource,
|
||||
static_cast<uint32_t>((mHandleFetchEventStart - mDispatchFetchEventStart).ToMilliseconds()));
|
||||
|
||||
if (!isNonSubresourceRequest && !subresourceKey.IsEmpty()) {
|
||||
Telemetry::Accumulate(Telemetry::SERVICE_WORKER_FETCH_EVENT_DISPATCH_MS,
|
||||
subresourceKey,
|
||||
static_cast<uint32_t>((mHandleFetchEventStart - mDispatchFetchEventStart).ToMilliseconds()));
|
||||
}
|
||||
|
||||
if (!mFinishResponseEnd.IsNull()) {
|
||||
Telemetry::Accumulate(Telemetry::SERVICE_WORKER_FETCH_INTERCEPTION_DURATION_MS,
|
||||
navigationOrSubresource,
|
||||
static_cast<uint32_t>((mFinishResponseEnd - mDispatchFetchEventStart).ToMilliseconds()));
|
||||
if (!isNonSubresourceRequest && !subresourceKey.IsEmpty()) {
|
||||
Telemetry::Accumulate(Telemetry::SERVICE_WORKER_FETCH_INTERCEPTION_DURATION_MS,
|
||||
subresourceKey,
|
||||
static_cast<uint32_t>((mFinishResponseEnd - mDispatchFetchEventStart).ToMilliseconds()));
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -944,9 +944,13 @@ InterceptedHttpChannel::SetChannelResetEnd(mozilla::TimeStamp aTimeStamp)
|
||||
NS_IMETHODIMP
|
||||
InterceptedHttpChannel::SaveTimeStamps(void)
|
||||
{
|
||||
nsCString navigationOrSubresource = nsContentUtils::IsNonSubresourceRequest(this) ?
|
||||
bool isNonSubresourceRequest = nsContentUtils::IsNonSubresourceRequest(this);
|
||||
nsCString navigationOrSubresource = isNonSubresourceRequest ?
|
||||
NS_LITERAL_CSTRING("navigation") : NS_LITERAL_CSTRING("subresource");
|
||||
|
||||
nsAutoCString subresourceKey(EmptyCString());
|
||||
GetSubresourceTimeStampKey(this, subresourceKey);
|
||||
|
||||
// We may have null timestamps if the fetch dispatch runnable was cancelled
|
||||
// and we defaulted to resuming the request.
|
||||
if (!mFinishResponseStart.IsNull() && !mFinishResponseEnd.IsNull()) {
|
||||
@ -955,16 +959,31 @@ InterceptedHttpChannel::SaveTimeStamps(void)
|
||||
Telemetry::SERVICE_WORKER_FETCH_EVENT_CHANNEL_RESET_MS;
|
||||
Telemetry::Accumulate(id, navigationOrSubresource,
|
||||
static_cast<uint32_t>((mFinishResponseEnd - mFinishResponseStart).ToMilliseconds()));
|
||||
if (!isNonSubresourceRequest && !subresourceKey.IsEmpty()) {
|
||||
Telemetry::Accumulate(id, subresourceKey,
|
||||
static_cast<uint32_t>((mFinishResponseEnd - mFinishResponseStart).ToMilliseconds()));
|
||||
}
|
||||
}
|
||||
|
||||
Telemetry::Accumulate(Telemetry::SERVICE_WORKER_FETCH_EVENT_DISPATCH_MS,
|
||||
navigationOrSubresource,
|
||||
static_cast<uint32_t>((mHandleFetchEventStart - mDispatchFetchEventStart).ToMilliseconds()));
|
||||
|
||||
if (!isNonSubresourceRequest && !subresourceKey.IsEmpty()) {
|
||||
Telemetry::Accumulate(Telemetry::SERVICE_WORKER_FETCH_EVENT_DISPATCH_MS,
|
||||
subresourceKey,
|
||||
static_cast<uint32_t>((mHandleFetchEventStart - mDispatchFetchEventStart).ToMilliseconds()));
|
||||
}
|
||||
|
||||
if (!mFinishResponseEnd.IsNull()) {
|
||||
Telemetry::Accumulate(Telemetry::SERVICE_WORKER_FETCH_INTERCEPTION_DURATION_MS,
|
||||
navigationOrSubresource,
|
||||
static_cast<uint32_t>((mFinishResponseEnd - mDispatchFetchEventStart).ToMilliseconds()));
|
||||
if (!isNonSubresourceRequest && !subresourceKey.IsEmpty()) {
|
||||
Telemetry::Accumulate(Telemetry::SERVICE_WORKER_FETCH_INTERCEPTION_DURATION_MS,
|
||||
subresourceKey,
|
||||
static_cast<uint32_t>((mFinishResponseEnd - mDispatchFetchEventStart).ToMilliseconds()));
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1359,6 +1359,21 @@ sw:
|
||||
- 'main'
|
||||
- 'content'
|
||||
|
||||
alternative_body_used_count:
|
||||
bug_numbers:
|
||||
- 1423623
|
||||
description: >
|
||||
The count of number of synthesize response using alternative body.
|
||||
expires: "61"
|
||||
kind: uint
|
||||
notification_emails:
|
||||
- sw-telemetry@mozilla.com
|
||||
- echuang@mozilla.com
|
||||
release_channel_collection: opt-out
|
||||
record_in_processes:
|
||||
- 'main'
|
||||
- 'content'
|
||||
|
||||
# The following section is for probes testing the Telemetry system. They will not be
|
||||
# submitted in pings and are only used for testing.
|
||||
telemetry.test:
|
||||
|
Loading…
Reference in New Issue
Block a user