diff --git a/gfx/metrics.yaml b/gfx/metrics.yaml index f5d1b962d6a2..6be39459af01 100644 --- a/gfx/metrics.yaml +++ b/gfx/metrics.yaml @@ -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 diff --git a/gfx/thebes/gfxUserFontSet.cpp b/gfx/thebes/gfxUserFontSet.cpp index cd1787d19318..c3a95a01128e 100644 --- a/gfx/thebes/gfxUserFontSet.cpp +++ b/gfx/thebes/gfxUserFontSet.cpp @@ -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& 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); } } diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 70ea463dfa0a..9cb41ea2deaf 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -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); } } diff --git a/layout/style/FontFaceSetImpl.cpp b/layout/style/FontFaceSetImpl.cpp index 7ea98939adc0..409d4c4cc13b 100644 --- a/layout/style/FontFaceSetImpl.cpp +++ b/layout/style/FontFaceSetImpl.cpp @@ -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; diff --git a/layout/style/nsFontFaceLoader.cpp b/layout/style/nsFontFaceLoader.cpp index 37ebebd56a84..fa2394773c37 100644 --- a/layout/style/nsFontFaceLoader.cpp +++ b/layout/style/nsFontFaceLoader.cpp @@ -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 &&