Bug 1890582 - Collect telemetry for time spent on purging bounce tracker storage r=pbz,anti-tracking-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D207876
This commit is contained in:
@@ -660,6 +660,26 @@ nsresult BounceTrackingProtection::ClearExpiredUserInteractions(
|
|||||||
NS_IMPL_ISUPPORTS(BounceTrackingProtection::ClearDataCallback,
|
NS_IMPL_ISUPPORTS(BounceTrackingProtection::ClearDataCallback,
|
||||||
nsIClearDataCallback);
|
nsIClearDataCallback);
|
||||||
|
|
||||||
|
BounceTrackingProtection::ClearDataCallback::ClearDataCallback(
|
||||||
|
ClearDataMozPromise::Private* aPromise, const nsACString& aHost)
|
||||||
|
: mHost(aHost), mClearDurationTimer(0), mPromise(aPromise) {
|
||||||
|
MOZ_ASSERT(!aHost.IsEmpty(), "Host must not be empty");
|
||||||
|
if (!StaticPrefs::privacy_bounceTrackingProtection_enableDryRunMode()) {
|
||||||
|
// Only collect timing information when actually performing the deletion
|
||||||
|
mClearDurationTimer =
|
||||||
|
glean::bounce_tracking_protection::purge_duration.Start();
|
||||||
|
MOZ_ASSERT(mClearDurationTimer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BounceTrackingProtection::ClearDataCallback::~ClearDataCallback() {
|
||||||
|
mPromise->Reject(0, __func__);
|
||||||
|
if (mClearDurationTimer) {
|
||||||
|
glean::bounce_tracking_protection::purge_duration.Cancel(
|
||||||
|
std::move(mClearDurationTimer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// nsIClearDataCallback implementation
|
// nsIClearDataCallback implementation
|
||||||
NS_IMETHODIMP BounceTrackingProtection::ClearDataCallback::OnDataDeleted(
|
NS_IMETHODIMP BounceTrackingProtection::ClearDataCallback::OnDataDeleted(
|
||||||
uint32_t aFailedFlags) {
|
uint32_t aFailedFlags) {
|
||||||
@@ -670,7 +690,17 @@ NS_IMETHODIMP BounceTrackingProtection::ClearDataCallback::OnDataDeleted(
|
|||||||
("%s: Cleared %s", __FUNCTION__, mHost.get()));
|
("%s: Cleared %s", __FUNCTION__, mHost.get()));
|
||||||
mPromise->Resolve(std::move(mHost), __func__);
|
mPromise->Resolve(std::move(mHost), __func__);
|
||||||
}
|
}
|
||||||
|
RecordClearDurationTelemetry();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BounceTrackingProtection::ClearDataCallback::
|
||||||
|
RecordClearDurationTelemetry() {
|
||||||
|
if (mClearDurationTimer) {
|
||||||
|
glean::bounce_tracking_protection::purge_duration.StopAndAccumulate(
|
||||||
|
std::move(mClearDurationTimer));
|
||||||
|
mClearDurationTimer = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "mozilla/Logging.h"
|
#include "mozilla/Logging.h"
|
||||||
#include "mozilla/MozPromise.h"
|
#include "mozilla/MozPromise.h"
|
||||||
|
#include "mozilla/glean/GleanMetrics.h"
|
||||||
#include "nsIBounceTrackingProtection.h"
|
#include "nsIBounceTrackingProtection.h"
|
||||||
#include "nsIClearDataService.h"
|
#include "nsIClearDataService.h"
|
||||||
|
|
||||||
@@ -82,13 +83,16 @@ class BounceTrackingProtection final : public nsIBounceTrackingProtection {
|
|||||||
NS_DECL_NSICLEARDATACALLBACK
|
NS_DECL_NSICLEARDATACALLBACK
|
||||||
|
|
||||||
explicit ClearDataCallback(ClearDataMozPromise::Private* aPromise,
|
explicit ClearDataCallback(ClearDataMozPromise::Private* aPromise,
|
||||||
const nsACString& aHost)
|
const nsACString& aHost);
|
||||||
: mHost(aHost), mPromise(aPromise){};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual ~ClearDataCallback() { mPromise->Reject(0, __func__); }
|
virtual ~ClearDataCallback();
|
||||||
|
|
||||||
nsCString mHost;
|
nsCString mHost;
|
||||||
|
|
||||||
|
void RecordClearDurationTelemetry();
|
||||||
|
|
||||||
|
glean::TimerId mClearDurationTimer;
|
||||||
RefPtr<ClearDataMozPromise::Private> mPromise;
|
RefPtr<ClearDataMozPromise::Private> mPromise;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
# Adding a new metric? We have docs for that!
|
||||||
|
# https://firefox-source-docs.mozilla.org/toolkit/components/glean/user/new_definitions_file.html
|
||||||
|
|
||||||
|
---
|
||||||
|
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0
|
||||||
|
$tags:
|
||||||
|
- 'Core :: Privacy: Anti-Tracking'
|
||||||
|
|
||||||
|
bounce.tracking.protection:
|
||||||
|
purge_duration:
|
||||||
|
type: timing_distribution
|
||||||
|
description: >
|
||||||
|
For every purge that is scheduled, we call the ClearDataService to
|
||||||
|
purge persistent storage for each detected bounce tracker. This may
|
||||||
|
do some blocking work on main thread and dispatch some cleanups to
|
||||||
|
other threads.
|
||||||
|
Collect telemetry on how long it takes to clear in the wild to
|
||||||
|
determine whether we need to improve performance here.
|
||||||
|
bugs:
|
||||||
|
- https://bugzilla.mozilla.org/show_bug.cgi?id=1890582
|
||||||
|
data_reviews:
|
||||||
|
- https://bugzilla.mozilla.org/show_bug.cgi?id=1890582#c4
|
||||||
|
data_sensitivity:
|
||||||
|
- technical
|
||||||
|
notification_emails:
|
||||||
|
- pbz@mozilla.com
|
||||||
|
- bvandersloot@mozilla.com
|
||||||
|
- manuel@mozilla.com
|
||||||
|
expires: 130
|
||||||
@@ -30,3 +30,5 @@ support-files = [
|
|||||||
["browser_bouncetracking_stateful_storage.js"]
|
["browser_bouncetracking_stateful_storage.js"]
|
||||||
|
|
||||||
["browser_bouncetracking_stateful_web_worker.js"]
|
["browser_bouncetracking_stateful_web_worker.js"]
|
||||||
|
|
||||||
|
["browser_bouncetracking_telemetry_purge_duration.js"]
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
https://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
let bounceTrackingProtection;
|
||||||
|
|
||||||
|
async function test_purge_duration(isDryRunMode) {
|
||||||
|
await SpecialPowers.pushPrefEnv({
|
||||||
|
set: [["privacy.bounceTrackingProtection.enableDryRunMode", isDryRunMode]],
|
||||||
|
});
|
||||||
|
|
||||||
|
is(
|
||||||
|
Glean.bounceTrackingProtection.purgeDuration.testGetValue(),
|
||||||
|
null,
|
||||||
|
"Histogram should not exist initially."
|
||||||
|
);
|
||||||
|
|
||||||
|
info("Run server bounce with cookie.");
|
||||||
|
await runTestBounce({
|
||||||
|
bounceType: "server",
|
||||||
|
setState: "cookie-server",
|
||||||
|
postBounceCallback: () => {
|
||||||
|
is(
|
||||||
|
Glean.bounceTrackingProtection.purgeDuration.testGetValue(),
|
||||||
|
null,
|
||||||
|
"Histogram should still be empty after bounce, because we haven't purged yet."
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
let events = Glean.bounceTrackingProtection.purgeDuration.testGetValue();
|
||||||
|
if (isDryRunMode) {
|
||||||
|
is(events, null, "Should not collect purge timining in dry mode");
|
||||||
|
} else {
|
||||||
|
is(events.count, 1, "Histogram should contain one value.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
Services.fog.testResetFOG();
|
||||||
|
await SpecialPowers.popPrefEnv();
|
||||||
|
bounceTrackingProtection.clearAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
add_setup(async function () {
|
||||||
|
await SpecialPowers.pushPrefEnv({
|
||||||
|
set: [
|
||||||
|
["privacy.bounceTrackingProtection.requireStatefulBounces", true],
|
||||||
|
["privacy.bounceTrackingProtection.bounceTrackingGracePeriodSec", 0],
|
||||||
|
],
|
||||||
|
});
|
||||||
|
bounceTrackingProtection = Cc[
|
||||||
|
"@mozilla.org/bounce-tracking-protection;1"
|
||||||
|
].getService(Ci.nsIBounceTrackingProtection);
|
||||||
|
|
||||||
|
// Clear telemetry before test.
|
||||||
|
Services.fog.testResetFOG();
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function test_purge_duration_dry_mode() {
|
||||||
|
await test_purge_duration(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function test_purge_duration_enabled() {
|
||||||
|
await test_purge_duration(false);
|
||||||
|
});
|
||||||
@@ -35,6 +35,7 @@ gecko_metrics = [
|
|||||||
"netwerk/protocol/http/metrics.yaml",
|
"netwerk/protocol/http/metrics.yaml",
|
||||||
"security/certverifier/metrics.yaml",
|
"security/certverifier/metrics.yaml",
|
||||||
"security/manager/ssl/metrics.yaml",
|
"security/manager/ssl/metrics.yaml",
|
||||||
|
"toolkit/components/antitracking/bouncetrackingprotection/metrics.yaml",
|
||||||
"toolkit/components/cookiebanners/metrics.yaml",
|
"toolkit/components/cookiebanners/metrics.yaml",
|
||||||
"toolkit/components/extensions/metrics.yaml",
|
"toolkit/components/extensions/metrics.yaml",
|
||||||
"toolkit/components/formautofill/metrics.yaml",
|
"toolkit/components/formautofill/metrics.yaml",
|
||||||
|
|||||||
Reference in New Issue
Block a user