Bug 1956726 - Migrate histograms to use Glean APIs for WEBFONT_*, r=chutten.

Differential Revision: https://phabricator.services.mozilla.com/D242767
This commit is contained in:
Florian Quèze
2025-04-03 13:42:52 +00:00
parent e8696f257b
commit 6afb2c9c36
5 changed files with 169 additions and 22 deletions

View File

@@ -1745,3 +1745,151 @@ apz_zoom:
- botond@mozilla.com
expires: never
telemetry_mirror: APZ_ZOOM_PINCHSOURCE
webfont:
download_time:
type: timing_distribution
description: >
Time to download a webfont (ms)
This metric was generated to correspond to the Legacy Telemetry
exponential histogram WEBFONT_DOWNLOAD_TIME.
time_unit: millisecond
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
notification_emails:
- jkew@mozilla.com
expires: never
telemetry_mirror: WEBFONT_DOWNLOAD_TIME
fonttype:
type: custom_distribution
description: >
Font format type (woff/woff2/ttf/...)
This metric was generated to correspond to the Legacy Telemetry enumerated
histogram WEBFONT_FONTTYPE.
range_min: 0
range_max: 10
bucket_count: 11
histogram_type: linear
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
notification_emails:
- jkew@mozilla.com
expires: never
telemetry_mirror: WEBFONT_FONTTYPE
srctype:
type: custom_distribution
description: >
Font src type loaded (1 = local, 2 = url, 3 = data)
This metric was generated to correspond to the Legacy Telemetry enumerated
histogram WEBFONT_SRCTYPE.
range_min: 0
range_max: 5
bucket_count: 6
histogram_type: linear
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
notification_emails:
- jkew@mozilla.com
expires: never
telemetry_mirror: WEBFONT_SRCTYPE
per_page:
type: counter
description: >
Number of fonts loaded at page load
This metric was generated to correspond to the Legacy Telemetry count
histogram WEBFONT_PER_PAGE.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
notification_emails:
- jkew@mozilla.com
expires: never
telemetry_mirror: h#WEBFONT_PER_PAGE
size_per_page:
type: memory_distribution
description: >
Size of all fonts loaded at page load (kb)
This metric was generated to correspond to the Legacy Telemetry
exponential histogram WEBFONT_SIZE_PER_PAGE.
memory_unit: kilobyte
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
notification_emails:
- jkew@mozilla.com
expires: never
telemetry_mirror: WEBFONT_SIZE_PER_PAGE
size:
type: memory_distribution
description: >
Size of font loaded (kb)
This metric was generated to correspond to the Legacy Telemetry
exponential histogram WEBFONT_SIZE.
memory_unit: kilobyte
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
notification_emails:
- jkew@mozilla.com
expires: never
telemetry_mirror: WEBFONT_SIZE
compression_woff:
type: custom_distribution
description: >
Compression ratio of WOFF data (%)
This metric was generated to correspond to the Legacy Telemetry enumerated
histogram WEBFONT_COMPRESSION_WOFF.
range_min: 0
range_max: 50
bucket_count: 51
histogram_type: linear
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
notification_emails:
- jkew@mozilla.com
expires: never
telemetry_mirror: WEBFONT_COMPRESSION_WOFF
compression_woff2:
type: custom_distribution
description: >
Compression ratio of WOFF2 data (%)
This metric was generated to correspond to the Legacy Telemetry enumerated
histogram WEBFONT_COMPRESSION_WOFF2.
range_min: 0
range_max: 50
bucket_count: 51
histogram_type: linear
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
notification_emails:
- jkew@mozilla.com
expires: never
telemetry_mirror: WEBFONT_COMPRESSION_WOFF2

View File

@@ -12,6 +12,7 @@
#include "mozilla/ProfilerLabels.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPrefs_gfx.h"
#include "mozilla/glean/GfxMetrics.h"
#include "mozilla/Telemetry.h"
#include "mozilla/gfx/2D.h"
#include "gfxPlatformFontList.h"
@@ -197,7 +198,7 @@ const uint8_t* gfxUserFontEntry::SanitizeOpenTypeData(
const uint8_t* aData, uint32_t aLength, uint32_t& aSanitaryLength,
gfxUserFontType& aFontType, nsTArray<OTSMessage>& aMessages) {
aFontType = gfxFontUtils::DetermineFontDataType(aData, aLength);
Telemetry::Accumulate(Telemetry::WEBFONT_FONTTYPE, uint32_t(aFontType));
glean::webfont::fonttype.AccumulateSingleSample(uint32_t(aFontType));
size_t lengthHint = gfxOTSContext::GuessSanitizedFontSize(aLength, aFontType);
if (!lengthHint) {
@@ -492,8 +493,7 @@ void gfxUserFontEntry::DoLoadNextSrc(bool aIsContinue) {
gfxUserFontData::kUnknownCompression);
mPlatformFontEntry = fe;
SetLoadState(STATUS_LOADED);
Telemetry::Accumulate(Telemetry::WEBFONT_SRCTYPE,
currSrc.mSourceType + 1);
glean::webfont::srctype.AccumulateSingleSample(currSrc.mSourceType + 1);
return;
}
LOG(("userfonts (%p) [src %d] failed local: (%s) for (%s)\n",
@@ -573,8 +573,8 @@ void gfxUserFontEntry::DoLoadNextSrc(bool aIsContinue) {
if (NS_SUCCEEDED(rv) &&
LoadPlatformFontSync(mCurrentSrcIndex, buffer, bufferLength)) {
SetLoadState(STATUS_LOADED);
Telemetry::Accumulate(Telemetry::WEBFONT_SRCTYPE,
currSrc.mSourceType + 1);
glean::webfont::srctype.AccumulateSingleSample(currSrc.mSourceType +
1);
return;
}
fontSet->LogMessage(this, mCurrentSrcIndex, "font load failed",
@@ -629,8 +629,7 @@ void gfxUserFontEntry::DoLoadNextSrc(bool aIsContinue) {
// LoadPlatformFontSync takes ownership of the buffer, so no need
// to free it here.
SetLoadState(STATUS_LOADED);
Telemetry::Accumulate(Telemetry::WEBFONT_SRCTYPE,
currSrc.mSourceType + 1);
glean::webfont::srctype.AccumulateSingleSample(currSrc.mSourceType + 1);
return;
}
fontSet->LogMessage(this, mCurrentSrcIndex, "font load failed",
@@ -752,11 +751,12 @@ bool gfxUserFontEntry::LoadPlatformFont(uint32_t aSrcIndex,
if (aSanitizedLength) {
fontCompressionRatio =
uint32_t(100.0 * aOriginalLength / aSanitizedLength + 0.5);
if (aFontType == GFX_USERFONT_WOFF || aFontType == GFX_USERFONT_WOFF2) {
Telemetry::Accumulate(aFontType == GFX_USERFONT_WOFF
? Telemetry::WEBFONT_COMPRESSION_WOFF
: Telemetry::WEBFONT_COMPRESSION_WOFF2,
fontCompressionRatio);
if (aFontType == GFX_USERFONT_WOFF) {
glean::webfont::compression_woff.AccumulateSingleSample(
fontCompressionRatio);
} else if (aFontType == GFX_USERFONT_WOFF2) {
glean::webfont::compression_woff2.AccumulateSingleSample(
fontCompressionRatio);
}
}

View File

@@ -1210,12 +1210,11 @@ void PresShell::Destroy() {
uint32_t fontCount;
uint64_t fontSize;
fs->GetLoadStatistics(fontCount, fontSize);
Telemetry::Accumulate(Telemetry::WEBFONT_PER_PAGE, fontCount);
Telemetry::Accumulate(Telemetry::WEBFONT_SIZE_PER_PAGE,
uint32_t(fontSize / 1024));
glean::webfont::per_page.Add(fontCount);
glean::webfont::size_per_page.Accumulate(uint32_t(fontSize / 1024));
} else {
Telemetry::Accumulate(Telemetry::WEBFONT_PER_PAGE, 0);
Telemetry::Accumulate(Telemetry::WEBFONT_SIZE_PER_PAGE, 0);
glean::webfont::per_page.Add(0);
glean::webfont::size_per_page.Accumulate(0);
}
}

View File

@@ -37,7 +37,7 @@
#include "mozilla/ServoUtils.h"
#include "mozilla/Sprintf.h"
#include "mozilla/StaticPrefs_layout.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/GfxMetrics.h"
#include "mozilla/LoadInfo.h"
#include "nsComponentManagerUtils.h"
#include "nsContentUtils.h"
@@ -903,7 +903,7 @@ void FontFaceSetImpl::RecordFontLoadDone(uint32_t aFontSize,
TimeStamp aDoneTime) {
mDownloadCount++;
mDownloadSize += aFontSize;
Telemetry::Accumulate(Telemetry::WEBFONT_SIZE, aFontSize / 1024);
glean::webfont::size.Accumulate(aFontSize / 1024);
TimeStamp navStart = GetNavigationStartTimeStamp();
TimeStamp zero;

View File

@@ -16,7 +16,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/StaticPrefs_layout.h"
#include "mozilla/TaskQueue.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/GfxMetrics.h"
#include "mozilla/Unused.h"
#include "FontFaceSet.h"
#include "nsPresContext.h"
@@ -235,9 +235,9 @@ nsFontFaceLoader::OnStreamComplete(nsIStreamLoader* aLoader,
TimeStamp doneTime = TimeStamp::Now();
TimeDuration downloadTime = doneTime - mStartTime;
uint32_t downloadTimeMS = uint32_t(downloadTime.ToMilliseconds());
Telemetry::Accumulate(Telemetry::WEBFONT_DOWNLOAD_TIME, downloadTimeMS);
glean::webfont::download_time.AccumulateRawDuration(downloadTime);
uint32_t downloadTimeMS = uint32_t(downloadTime.ToMilliseconds());
if (GetFontDisplay() == StyleFontDisplay::Fallback) {
uint32_t loadTimeout = GetFallbackDelay();
if (downloadTimeMS > loadTimeout &&