Bug 1944631 - Migrate histograms to use Glean APIs in dom/media/utils/TelemetryProbesReporter.cpp, r=TravisLong.

Differential Revision: https://phabricator.services.mozilla.com/D235954
This commit is contained in:
Florian Quèze
2025-02-03 16:08:33 +00:00
parent fcd3111e45
commit 65868fc7b2
3 changed files with 381 additions and 48 deletions

View File

@@ -129,12 +129,6 @@ CheckedInt64 UsecsToFrames(int64_t aUsecs, uint32_t aRate);
// Format TimeUnit as number of frames at given rate.
CheckedInt64 TimeUnitToFrames(const media::TimeUnit& aTime, uint32_t aRate);
// Converts milliseconds to seconds.
#define MS_TO_SECONDS(ms) ((double)(ms) / (PR_MSEC_PER_SEC))
// Converts seconds to milliseconds.
#define SECONDS_TO_MS(s) ((int)((s) * (PR_MSEC_PER_SEC)))
// Converts from seconds to microseconds. Returns failure if the resulting
// integer is too big to fit in an int64_t.
nsresult SecondsToUsecs(double aSeconds, int64_t& aOutUsecs);

View File

@@ -343,3 +343,346 @@ media:
will be null if the error is related to non-EME playback.
type : string
expires: never
video_play_time:
type: timing_distribution
description: >
Total time spent playing video in milliseconds.
This metric was generated to correspond to the Legacy Telemetry
exponential histogram VIDEO_PLAY_TIME_MS.
time_unit: millisecond
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1261955
- https://bugzilla.mozilla.org/show_bug.cgi?id=1127646
- https://bugzilla.mozilla.org/show_bug.cgi?id=1570634
- https://bugzilla.mozilla.org/show_bug.cgi?id=1567604
- https://bugzilla.mozilla.org/show_bug.cgi?id=1685399
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1261955
- https://bugzilla.mozilla.org/show_bug.cgi?id=1127646
- https://bugzilla.mozilla.org/show_bug.cgi?id=1570634
- https://bugzilla.mozilla.org/show_bug.cgi?id=1567604
- https://bugzilla.mozilla.org/show_bug.cgi?id=1685399
notification_emails:
- media-alerts@mozilla.com
expires: never
telemetry_mirror: VIDEO_PLAY_TIME_MS
media_play_time:
type: labeled_timing_distribution
description: >
Total time spent playing media in milliseconds, keyed by its content
(Audio and video, audio only, video only, audio and video but audio
inaudible, audio and video but audio muted).
This metric was generated to correspond to the Legacy Telemetry
exponential histogram MEDIA_PLAY_TIME_MS.
time_unit: millisecond
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1678373
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1678373
notification_emails:
- media-alerts@mozilla.com
expires: never
telemetry_mirror: MEDIA_PLAY_TIME_MS
audible_play_time_percent:
type: labeled_custom_distribution
description: >
Percentage of time spent playing media with an audible audio track,
regardless of the volume. Keyed by audio-only or video presence.
This metric was generated to correspond to the Legacy Telemetry linear
histogram AUDIBLE_PLAY_TIME_PERCENT.
range_min: 1
range_max: 100
bucket_count: 50
histogram_type: linear
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1678373
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1678373
notification_emails:
- media-alerts@mozilla.com
expires: never
telemetry_mirror: AUDIBLE_PLAY_TIME_PERCENT
muted_play_time_percent:
type: labeled_custom_distribution
description: >
Percentage of time spent playing media that has an audio track, with the
audio muted. Keyed by audio-only or video presence.
This metric was generated to correspond to the Legacy Telemetry linear
histogram MUTED_PLAY_TIME_PERCENT.
range_min: 1
range_max: 100
bucket_count: 50
histogram_type: linear
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1678373
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1678373
notification_emails:
- media-alerts@mozilla.com
expires: never
telemetry_mirror: MUTED_PLAY_TIME_PERCENT
video_visible_play_time:
type: labeled_timing_distribution
description: >
Total time spent playing visible video in milliseconds.
This metric was generated to correspond to the Legacy Telemetry
exponential histogram VIDEO_VISIBLE_PLAY_TIME_MS.
time_unit: millisecond
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1723799
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1723799
notification_emails:
- media-alerts@mozilla.com
expires: never
telemetry_mirror: VIDEO_VISIBLE_PLAY_TIME_MS
video_hidden_play_time:
type: timing_distribution
description: >
Total time spent playing video while element is hidden, in milliseconds.
This metric was generated to correspond to the Legacy Telemetry
exponential histogram VIDEO_HIDDEN_PLAY_TIME_MS.
time_unit: millisecond
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1285419
- https://bugzilla.mozilla.org/show_bug.cgi?id=1570634
- https://bugzilla.mozilla.org/show_bug.cgi?id=1685399
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1285419
- https://bugzilla.mozilla.org/show_bug.cgi?id=1570634
- https://bugzilla.mozilla.org/show_bug.cgi?id=1685399
notification_emails:
- media-alerts@mozilla.com
expires: never
telemetry_mirror: VIDEO_HIDDEN_PLAY_TIME_MS
video_hidden_play_time_percentage:
type: labeled_custom_distribution
description: >
Percentage of total time spent playing video while element is hidden.
Keyed by audio presence and by height ranges (boundaries: 240. 480, 576,
720, 1080, 2160), e.g.: 'V,0<h<=240', 'AV,h>2160'; and 'All' will
accumulate all percentages. This is reported whenever the decoder stops.
(eg. pausing media, encountering an error, changing to a new resource,
page goes to the bf-cached or page gets discarded)
This metric was generated to correspond to the Legacy Telemetry linear
histogram VIDEO_HIDDEN_PLAY_TIME_PERCENTAGE.
range_min: 1
range_max: 100
bucket_count: 50
histogram_type: linear
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1287987
- https://bugzilla.mozilla.org/show_bug.cgi?id=1570634
- https://bugzilla.mozilla.org/show_bug.cgi?id=1685399
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1287987
- https://bugzilla.mozilla.org/show_bug.cgi?id=1570634
- https://bugzilla.mozilla.org/show_bug.cgi?id=1685399
notification_emails:
- media-alerts@mozilla.com
expires: never
telemetry_mirror: VIDEO_HIDDEN_PLAY_TIME_PERCENTAGE
video_hdr_play_time:
type: timing_distribution
description: >
Total time spent playing HDR video in milliseconds.
This metric was generated to correspond to the Legacy Telemetry
exponential histogram VIDEO_HDR_PLAY_TIME_MS.
time_unit: millisecond
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1777264
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1777264
notification_emails:
- media-alerts@mozilla.com
- bwerth@mozilla.com
expires: never
telemetry_mirror: VIDEO_HDR_PLAY_TIME_MS
video_encrypted_play_time:
type: timing_distribution
description: >
Total time spent playing encrypted video in milliseconds.
This metric was generated to correspond to the Legacy Telemetry
exponential histogram VIDEO_ENCRYPTED_PLAY_TIME_MS.
time_unit: millisecond
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1662212
- https://bugzilla.mozilla.org/show_bug.cgi?id=1685399
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1662212
- https://bugzilla.mozilla.org/show_bug.cgi?id=1685399
notification_emails:
- media-alerts@mozilla.com
expires: never
telemetry_mirror: VIDEO_ENCRYPTED_PLAY_TIME_MS
video_clearkey_play_time:
type: timing_distribution
description: >
Total time spent playing Clearkey encrypted video in milliseconds.
This metric was generated to correspond to the Legacy Telemetry
exponential histogram VIDEO_CLEARKEY_PLAY_TIME_MS.
time_unit: millisecond
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1662212
- https://bugzilla.mozilla.org/show_bug.cgi?id=1685399
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1662212
- https://bugzilla.mozilla.org/show_bug.cgi?id=1685399
notification_emails:
- media-alerts@mozilla.com
expires: never
telemetry_mirror: VIDEO_CLEARKEY_PLAY_TIME_MS
video_widevine_play_time:
type: timing_distribution
description: >
Total time spent playing Widevine encrypted video in milliseconds.
This metric was generated to correspond to the Legacy Telemetry
exponential histogram VIDEO_WIDEVINE_PLAY_TIME_MS.
time_unit: millisecond
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1662212
- https://bugzilla.mozilla.org/show_bug.cgi?id=1685399
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1662212
- https://bugzilla.mozilla.org/show_bug.cgi?id=1685399
notification_emails:
- media-alerts@mozilla.com
expires: never
telemetry_mirror: VIDEO_WIDEVINE_PLAY_TIME_MS
video_dropped_frames_proportion:
type: custom_distribution
description: >
Percentage of frames decoded frames dropped between starting and stopping
a video
This metric was generated to correspond to the Legacy Telemetry linear
histogram VIDEO_DROPPED_FRAMES_PROPORTION.
range_min: 1
range_max: 100
bucket_count: 50
histogram_type: linear
unit: percentage
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1238433
- https://bugzilla.mozilla.org/show_bug.cgi?id=1570634
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1238433
- https://bugzilla.mozilla.org/show_bug.cgi?id=1570634
notification_emails:
- media-alerts@mozilla.com
expires: never
telemetry_mirror: VIDEO_DROPPED_FRAMES_PROPORTION
video_dropped_frames_proportion_exponential:
type: custom_distribution
description: >
Ratio of dropped frames per total decoded frames scaled by 10,000 between
starting and stopping a video
This metric was generated to correspond to the Legacy Telemetry
exponential histogram VIDEO_DROPPED_FRAMES_PROPORTION_EXPONENTIAL.
range_min: 1
range_max: 10000
bucket_count: 100
histogram_type: exponential
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1238433
- https://bugzilla.mozilla.org/show_bug.cgi?id=1570634
- https://bugzilla.mozilla.org/show_bug.cgi?id=1752207
- https://bugzilla.mozilla.org/show_bug.cgi?id=1755363
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1238433
- https://bugzilla.mozilla.org/show_bug.cgi?id=1570634
- https://bugzilla.mozilla.org/show_bug.cgi?id=1752207
- https://bugzilla.mozilla.org/show_bug.cgi?id=1755363
notification_emails:
- media-alerts@mozilla.com
expires: never
telemetry_mirror: VIDEO_DROPPED_FRAMES_PROPORTION_EXPONENTIAL
video_dropped_decoded_frames_proportion_exponential:
type: custom_distribution
description: >
Ratio of decoder dropped frames per total decoded frames scaled by 10,000
between starting and stopping a video
This metric was generated to correspond to the Legacy Telemetry
exponential histogram VIDEO_DROPPED_DECODED_FRAMES_PROPORTION_EXPONENTIAL.
range_min: 1
range_max: 10000
bucket_count: 100
histogram_type: exponential
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1761994
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1761994
notification_emails:
- media-alerts@mozilla.com
expires: never
telemetry_mirror: VIDEO_DROPPED_DECODED_FRAMES_PROPORTION_EXPONENTIAL
video_dropped_sink_frames_proportion_exponential:
type: custom_distribution
description: >
Ratio of sink dropped frames per total decoded frames scaled by 10,000
between starting and stopping a video
This metric was generated to correspond to the Legacy Telemetry
exponential histogram VIDEO_DROPPED_SINK_FRAMES_PROPORTION_EXPONENTIAL.
range_min: 1
range_max: 10000
bucket_count: 100
histogram_type: exponential
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1761994
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1761994
notification_emails:
- media-alerts@mozilla.com
expires: never
telemetry_mirror: VIDEO_DROPPED_SINK_FRAMES_PROPORTION_EXPONENTIAL
video_dropped_compositor_frames_proportion_exponential:
type: custom_distribution
description: >
Ratio of compositor dropped frames per total decoded frames scaled by
10,000 between starting and stopping a video
This metric was generated to correspond to the Legacy Telemetry
exponential histogram
VIDEO_DROPPED_COMPOSITOR_FRAMES_PROPORTION_EXPONENTIAL.
range_min: 1
range_max: 10000
bucket_count: 100
histogram_type: exponential
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1761994
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1761994
notification_emails:
- media-alerts@mozilla.com
expires: never
telemetry_mirror: VIDEO_DROPPED_COMPOSITOR_FRAMES_PROPORTION_EXPONENTIAL

View File

@@ -12,7 +12,6 @@
#include "mozilla/EMEUtils.h"
#include "mozilla/Logging.h"
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/DomMediaEmeMetrics.h"
#include "mozilla/glean/DomMediaMetrics.h"
#include "mozilla/glean/DomMediaPlatformsWmfMetrics.h"
@@ -428,26 +427,26 @@ void TelemetryProbesReporter::ReportResultForVideo() {
MOZ_ASSERT(totalVideoPlayTimeS >= invisiblePlayTimeS);
LOG("VIDEO_PLAY_TIME_S = %f", totalVideoPlayTimeS);
Telemetry::Accumulate(Telemetry::VIDEO_PLAY_TIME_MS,
SECONDS_TO_MS(totalVideoPlayTimeS));
glean::media::video_play_time.AccumulateRawDuration(
TimeDuration::FromSeconds(totalVideoPlayTimeS));
LOG("VIDEO_HIDDEN_PLAY_TIME_S = %f", invisiblePlayTimeS);
Telemetry::Accumulate(Telemetry::VIDEO_HIDDEN_PLAY_TIME_MS,
SECONDS_TO_MS(invisiblePlayTimeS));
glean::media::video_hidden_play_time.AccumulateRawDuration(
TimeDuration::FromSeconds(invisiblePlayTimeS));
// We only want to accumulate non-zero samples for HDR playback.
// This is different from the other timings tracked here, but
// we don't need 0-length play times to do our calculations.
if (totalVideoHDRPlayTimeS > 0.0) {
LOG("VIDEO_HDR_PLAY_TIME_S = %f", totalVideoHDRPlayTimeS);
Telemetry::Accumulate(Telemetry::VIDEO_HDR_PLAY_TIME_MS,
SECONDS_TO_MS(totalVideoHDRPlayTimeS));
glean::media::video_hdr_play_time.AccumulateRawDuration(
TimeDuration::FromSeconds(totalVideoHDRPlayTimeS));
}
if (mOwner->IsEncrypted()) {
LOG("VIDEO_ENCRYPTED_PLAY_TIME_S = %f", totalVideoPlayTimeS);
Telemetry::Accumulate(Telemetry::VIDEO_ENCRYPTED_PLAY_TIME_MS,
SECONDS_TO_MS(totalVideoPlayTimeS));
glean::media::video_encrypted_play_time.AccumulateRawDuration(
TimeDuration::FromSeconds(totalVideoPlayTimeS));
}
// TODO: deprecate the old probes.
@@ -456,13 +455,13 @@ void TelemetryProbesReporter::ReportResultForVideo() {
if (keySystem) {
if (IsClearkeyKeySystem(*keySystem)) {
LOG("VIDEO_CLEARKEY_PLAY_TIME_S = %f", totalVideoPlayTimeS);
Telemetry::Accumulate(Telemetry::VIDEO_CLEARKEY_PLAY_TIME_MS,
SECONDS_TO_MS(totalVideoPlayTimeS));
glean::media::video_clearkey_play_time.AccumulateRawDuration(
TimeDuration::FromSeconds(totalVideoPlayTimeS));
} else if (IsWidevineKeySystem(*keySystem)) {
LOG("VIDEO_WIDEVINE_PLAY_TIME_S = %f", totalVideoPlayTimeS);
Telemetry::Accumulate(Telemetry::VIDEO_WIDEVINE_PLAY_TIME_MS,
SECONDS_TO_MS(totalVideoPlayTimeS));
glean::media::video_widevine_play_time.AccumulateRawDuration(
TimeDuration::FromSeconds(totalVideoPlayTimeS));
}
}
@@ -474,19 +473,19 @@ void TelemetryProbesReporter::ReportResultForVideo() {
auto visiblePlayTimeS = totalVideoPlayTimeS - invisiblePlayTimeS;
LOG("VIDEO_VISIBLE_PLAY_TIME = %f, keys: '%s' and 'All'", visiblePlayTimeS,
key.get());
Telemetry::Accumulate(Telemetry::VIDEO_VISIBLE_PLAY_TIME_MS, key,
SECONDS_TO_MS(visiblePlayTimeS));
glean::media::video_visible_play_time.Get(key).AccumulateRawDuration(
TimeDuration::FromSeconds(visiblePlayTimeS));
// Also accumulate result in an "All" key.
Telemetry::Accumulate(Telemetry::VIDEO_VISIBLE_PLAY_TIME_MS, "All"_ns,
SECONDS_TO_MS(visiblePlayTimeS));
glean::media::video_visible_play_time.Get("All"_ns).AccumulateRawDuration(
TimeDuration::FromSeconds(visiblePlayTimeS));
const uint32_t hiddenPercentage =
lround(invisiblePlayTimeS / totalVideoPlayTimeS * 100.0);
Telemetry::Accumulate(Telemetry::VIDEO_HIDDEN_PLAY_TIME_PERCENTAGE, key,
hiddenPercentage);
glean::media::video_hidden_play_time_percentage.Get(key)
.AccumulateSingleSample(hiddenPercentage);
// Also accumulate all percentages in an "All" key.
Telemetry::Accumulate(Telemetry::VIDEO_HIDDEN_PLAY_TIME_PERCENTAGE, "All"_ns,
hiddenPercentage);
glean::media::video_hidden_play_time_percentage.Get("All"_ns)
.AccumulateSingleSample(hiddenPercentage);
LOG("VIDEO_HIDDEN_PLAY_TIME_PERCENTAGE = %u, keys: '%s' and 'All'",
hiddenPercentage, key.get());
@@ -609,16 +608,16 @@ void TelemetryProbesReporter::ReportResultForAudio() {
"%u\npercentage unmuted: %u\n",
totalAudioPlayTimeS, audiblePlayTimeS, inaudiblePlayTimeS,
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);
glean::media::media_play_time.Get(key).AccumulateRawDuration(
TimeDuration::FromSeconds(totalAudioPlayTimeS));
glean::media::muted_play_time_percent.Get(avKey).AccumulateSingleSample(
100 - unmutedPercentage);
glean::media::audible_play_time_percent.Get(avKey).AccumulateSingleSample(
audiblePercentage);
} else {
MOZ_ASSERT(mMediaContent & MediaContent::MEDIA_HAS_VIDEO);
Telemetry::Accumulate(Telemetry::MEDIA_PLAY_TIME_MS, key,
SECONDS_TO_MS(totalVideoPlayTimeS));
glean::media::media_play_time.Get(key).AccumulateRawDuration(
TimeDuration::FromSeconds(totalVideoPlayTimeS));
}
}
@@ -637,32 +636,29 @@ void TelemetryProbesReporter::ReportResultForVideoFrameStatistics(
// 100 and therefore can fit in a uint32_t (that Telemetry takes).
const uint32_t percentage = 100 * droppedFrames / parsedFrames;
LOG("DROPPED_FRAMES_IN_VIDEO_PLAYBACK = %u", percentage);
Telemetry::Accumulate(Telemetry::VIDEO_DROPPED_FRAMES_PROPORTION,
percentage);
glean::media::video_dropped_frames_proportion.AccumulateSingleSample(
percentage);
const uint32_t proportion = 10000 * droppedFrames / parsedFrames;
Telemetry::Accumulate(
Telemetry::VIDEO_DROPPED_FRAMES_PROPORTION_EXPONENTIAL, proportion);
glean::media::video_dropped_frames_proportion_exponential
.AccumulateSingleSample(proportion);
{
const uint64_t droppedFrames = stats->GetDroppedDecodedFrames();
const uint32_t proportion = 10000 * droppedFrames / parsedFrames;
Telemetry::Accumulate(
Telemetry::VIDEO_DROPPED_DECODED_FRAMES_PROPORTION_EXPONENTIAL,
proportion);
glean::media::video_dropped_decoded_frames_proportion_exponential
.AccumulateSingleSample(proportion);
}
{
const uint64_t droppedFrames = stats->GetDroppedSinkFrames();
const uint32_t proportion = 10000 * droppedFrames / parsedFrames;
Telemetry::Accumulate(
Telemetry::VIDEO_DROPPED_SINK_FRAMES_PROPORTION_EXPONENTIAL,
proportion);
glean::media::video_dropped_sink_frames_proportion_exponential
.AccumulateSingleSample(proportion);
}
{
const uint64_t droppedFrames = stats->GetDroppedCompositorFrames();
const uint32_t proportion = 10000 * droppedFrames / parsedFrames;
Telemetry::Accumulate(
Telemetry::VIDEO_DROPPED_COMPOSITOR_FRAMES_PROPORTION_EXPONENTIAL,
proportion);
glean::media::video_dropped_compositor_frames_proportion_exponential
.AccumulateSingleSample(proportion);
}
}
}