Bug 1678373 - Add telemetry probes for audible and muted media. r=alwu data-review=chutten

Differential Revision: https://phabricator.services.mozilla.com/D125694
This commit is contained in:
Paul Adenot 2021-10-12 09:03:56 +00:00
Родитель d0bade8b71
Коммит 21e320dce3
3 изменённых файлов: 69 добавлений и 5 удалений

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

@ -16,9 +16,22 @@
* - VIDEO_INFERRED_DECODE_SUSPEND_PERCENTAGE
* - VIDEO_VISIBLE_PLAY_TIME_MS
* - MEDIA_PLAY_TIME_MS
* - MUTED_PLAY_TIME_PERCENT
* - AUDIBLE_PLAY_TIME_PERCENT
*/
const videoHistNames = ["VIDEO_PLAY_TIME_MS", "VIDEO_HIDDEN_PLAY_TIME_MS"];
const videoKeyedHistNames = ["VIDEO_HIDDEN_PLAY_TIME_PERCENTAGE", "VIDEO_INFERRED_DECODE_SUSPEND_PERCENTAGE", "VIDEO_VISIBLE_PLAY_TIME_MS"];
const videoHistNames = [
"VIDEO_PLAY_TIME_MS",
"VIDEO_HIDDEN_PLAY_TIME_MS"
];
const videoKeyedHistNames = [
"VIDEO_HIDDEN_PLAY_TIME_PERCENTAGE",
"VIDEO_INFERRED_DECODE_SUSPEND_PERCENTAGE",
"VIDEO_VISIBLE_PLAY_TIME_MS"
];
const audioKeyedHistNames = [
"MUTED_PLAY_TIME_PERCENT",
"AUDIBLE_PLAY_TIME_PERCENT"
];
add_task(async function setTestPref() {
await SpecialPowers.pushPrefEnv({
@ -466,6 +479,25 @@ async function checkReportedTelemetry(media, reportExpected, hasVideo) {
ok(!reportExpected, "MEDIA_PLAY_TIME_MS should always be reported if a report is expected");
}
}
for (const name of audioKeyedHistNames) {
try {
const hist = SpecialPowers.Services.telemetry.getKeyedHistogramById(name);
const items = Object.entries(hist.snapshot());
if (items.length > 0) {
for (const [key, value] of items) {
const entriesNums = Object.entries(value.values).length;
ok(reportExpected && entriesNums > 0, `Reported ${key} for ${name}`);
}
} else {
ok(!reportExpected, `No audio telemetry expected, none reported`);
}
// Avoid to pollute next test task.
hist.clear();
} catch (e) {
ok(false , `keyed histogram '${name}' doesn't exist`);
}
}
}
function once(target, name) {

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

@ -439,13 +439,13 @@ void TelemetryProbesReporter::ReportResultForVideo() {
void TelemetryProbesReporter::ReportResultForAudio() {
// Don't record telemetry for a media that didn't have a valid audio or video
// to play, or hasn't played.
if (!HasOwnerHadValidMedia() ||
(mTotalAudioPlayTime.PeekTotal() == 0.0 &&
mTotalVideoPlayTime.PeekTotal() == 0.0)) {
if (!HasOwnerHadValidMedia() || (mTotalAudioPlayTime.PeekTotal() == 0.0 &&
mTotalVideoPlayTime.PeekTotal() == 0.0)) {
return;
}
nsCString key;
nsCString avKey;
const double totalAudioPlayTimeS = mTotalAudioPlayTime.GetAndClearTotal();
const double inaudiblePlayTimeS = mInaudibleAudioPlayTime.GetAndClearTotal();
const double mutedPlayTimeS = mMutedAudioPlayTime.GetAndClearTotal();
@ -476,9 +476,11 @@ void TelemetryProbesReporter::ReportResultForAudio() {
// Media element had an audible audio track
key.AppendASCII("A");
}
avKey.AppendASCII("A");
}
if (mMediaContent & MediaContent::MEDIA_HAS_VIDEO) {
key.AppendASCII("V");
avKey.AppendASCII("V");
}
LOG("Key: %s", key.get());
@ -491,6 +493,10 @@ void TelemetryProbesReporter::ReportResultForAudio() {
mutedPlayTimeS, audiblePercentage, unmutedPercentage);
Telemetry::Accumulate(Telemetry::MEDIA_PLAY_TIME_MS, key,
SECONDS_TO_MS(totalAudioPlayTimeS));
Telemetry::Accumulate(Telemetry::MUTED_PLAY_TIME_PERCENT, avKey,
100 - unmutedPercentage);
Telemetry::Accumulate(Telemetry::AUDIBLE_PLAY_TIME_PERCENT, avKey,
audiblePercentage);
} else {
MOZ_ASSERT(mMediaContent & MediaContent::MEDIA_HAS_VIDEO);
Telemetry::Accumulate(Telemetry::MEDIA_PLAY_TIME_MS, key,

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

@ -13322,6 +13322,32 @@
"bug_numbers": [1678373],
"releaseChannelCollection": "opt-out"
},
"AUDIBLE_PLAY_TIME_PERCENT": {
"record_in_processes": ["main", "content"],
"products": ["firefox"],
"alert_emails": ["alwu@mozilla.com", "padenot@mozilla.com"],
"expires_in_version": "never",
"description": "Percentage of time spent playing media with an audible audio track, regardless of the volume. Keyed by audio-only or video presence.",
"keyed": true,
"kind": "linear",
"high": 100,
"n_buckets": 50,
"bug_numbers": [1678373],
"releaseChannelCollection": "opt-out"
},
"MUTED_PLAY_TIME_PERCENT": {
"record_in_processes": ["main", "content"],
"products": ["firefox"],
"alert_emails": ["alwu@mozilla.com", "padenot@mozilla.com"],
"expires_in_version": "never",
"description": "Percentage of time spent playing media that has an audio track, with the audio muted. Keyed by audio-only or video presence.",
"keyed": true,
"kind": "linear",
"high": 100,
"n_buckets": 50,
"bug_numbers": [1678373],
"releaseChannelCollection": "opt-out"
},
"VIDEO_VISIBLE_PLAY_TIME_MS" : {
"record_in_processes": ["main", "content"],
"products": ["firefox"],