From 88a9211951f8c0beb2245bd81c6cc9ad8d46a57e Mon Sep 17 00:00:00 2001 From: Jose Antonio Olivera Ortega Date: Fri, 5 Jun 2015 08:11:18 +0200 Subject: [PATCH] Bug 1115820 - Add telemetry to ServiceWorkers. r=nsm, r=vladan --HG-- extra : rebase_source : 69547573525bcea989d24e0a0293f6df9e7f90e1 --- dom/workers/RuntimeService.cpp | 6 ++++ dom/workers/ServiceWorkerManager.cpp | 8 +++++ toolkit/components/telemetry/Histograms.json | 32 +++++++++++++++++--- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index 6050b8a9b001..cb746d8a6415 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -1667,6 +1667,12 @@ RuntimeService::UnregisterWorker(JSContext* aCx, WorkerPrivate* aWorkerPrivate) } } + if (aWorkerPrivate->IsServiceWorker()) { + AssertIsOnMainThread(); + Telemetry::AccumulateTimeDelta(Telemetry::SERVICE_WORKER_LIFE_TIME, + aWorkerPrivate->CreationTimeStamp()); + } + if (aWorkerPrivate->IsSharedWorker()) { AssertIsOnMainThread(); diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp index 0172f4f7161c..fd1be0c72e83 100644 --- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -28,6 +28,7 @@ #include "mozilla/ClearOnShutdown.h" #include "mozilla/ErrorNames.h" #include "mozilla/LoadContext.h" +#include "mozilla/Telemetry.h" #include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/ContentParent.h" #include "mozilla/dom/DOMError.h" @@ -814,6 +815,9 @@ public: return; } + AssertIsOnMainThread(); + Telemetry::Accumulate(Telemetry::SERVICE_WORKER_UPDATED, 1); + nsRefPtr swm = ServiceWorkerManager::GetInstance(); nsCOMPtr scriptURI; @@ -1322,6 +1326,9 @@ ServiceWorkerManager::Register(nsIDOMWindow* aWindow, new ServiceWorkerRegisterJob(queue, cleanedScope, spec, cb, documentPrincipal); queue->Append(job); + AssertIsOnMainThread(); + Telemetry::Accumulate(Telemetry::SERVICE_WORKER_REGISTRATIONS, 1); + promise.forget(aPromise); return NS_OK; } @@ -2790,6 +2797,7 @@ ServiceWorkerManager::StartControllingADocument(ServiceWorkerRegistrationInfo* a aRegistration->StartControllingADocument(); mControlledDocuments.Put(aDoc, aRegistration); + Telemetry::Accumulate(Telemetry::SERVICE_WORKER_CONTROLLED_DOCUMENTS, 1); } void diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 6cb9d7915ab9..d57f87b54f51 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -7493,12 +7493,12 @@ "kind": "exponential", "high": "5000", "n_buckets": 20, - "description": "Tracking how ServiceWorkerRegistrar loads data before the first content is shown" + "description": "Tracking how ServiceWorkerRegistrar loads data before the first content is shown. File bugs in Core::DOM in case of a Telemetry regression." }, "SERVICE_WORKER_REQUEST_PASSTHROUGH": { "expires_in_version": "50", "kind": "boolean", - "description": "Intercepted fetch sending back same Request object." + "description": "Intercepted fetch sending back same Request object. File bugs in Core::DOM in case of a Telemetry regression." }, "LOOP_CLIENT_CALL_URL_REQUESTS_SUCCESS": { "expires_in_version": "never", @@ -8007,17 +8007,39 @@ "SERVICE_WORKER_SPAWN_ATTEMPTS": { "expires_in_version": "50", "kind": "count", - "description": "Count attempts to spawn a ServiceWorker for a domain" + "description": "Count attempts to spawn a ServiceWorker for a domain. File bugs in Core::DOM in case of a Telemetry regression." }, "SERVICE_WORKER_WAS_SPAWNED": { "expires_in_version": "50", "kind": "count", - "description": "Count ServiceWorkers that really did get a thread created for them" + "description": "Count ServiceWorkers that really did get a thread created for them. File bugs in Core::DOM in case of a Telemetry regression." }, "SERVICE_WORKER_SPAWN_GETS_QUEUED": { "expires_in_version": "50", "kind": "count", - "description": "Tracking whether a ServiceWorker spawn gets queued due to hitting max workers per domain limit" + "description": "Tracking whether a ServiceWorker spawn gets queued due to hitting max workers per domain limit. File bugs in Core::DOM in case of a Telemetry regression." + }, + "SERVICE_WORKER_REGISTRATIONS": { + "expires_in_version": "50", + "kind": "count", + "description": "Count how many registrations occurs. File bugs in Core::DOM in case of a Telemetry regression." + }, + "SERVICE_WORKER_CONTROLLED_DOCUMENTS": { + "expires_in_version": "50", + "kind": "count", + "description": "Count whenever a document is controlled. File bugs in Core::DOM in case of a Telemetry regression." + }, + "SERVICE_WORKER_UPDATED": { + "expires_in_version": "50", + "kind": "count", + "description": "Count ServiceWorkers scripts that are updated. File bugs in Core::DOM in case of a Telemetry regression." + }, + "SERVICE_WORKER_LIFE_TIME": { + "expires_in_version": "50", + "kind": "exponential", + "high": "120000", + "n_buckets": 20, + "description": "Tracking how long a ServiceWorker stays alive after it is spawned. File bugs in Core::DOM in case of a Telemetry regression." }, "GRAPHICS_SANITY_TEST": { "expires_in_version": "never",