Bug 1956726 - Migrate histograms to use Glean APIs for ipc related histograms, r=chutten,media-playback-reviewers,padenot.

Differential Revision: https://phabricator.services.mozilla.com/D242916
This commit is contained in:
Florian Quèze
2025-03-31 14:09:54 +00:00
parent 95f7f24088
commit 92cc8bb101
11 changed files with 172 additions and 31 deletions

View File

@@ -84,6 +84,7 @@
#include "mozilla/StyleSheetInlines.h"
#include "mozilla/TaskController.h"
#include "mozilla/glean/DomMetrics.h"
#include "mozilla/glean/IpcMetrics.h"
#include "mozilla/Telemetry.h"
#include "mozilla/TelemetryIPC.h"
#include "mozilla/ThreadSafety.h"
@@ -1942,8 +1943,7 @@ void ContentParent::ActorDestroy(ActorDestroyReason why) {
if (StringBeginsWith(mRemoteType, WEB_REMOTE_TYPE) ||
mRemoteType == FILE_REMOTE_TYPE || mRemoteType == EXTENSION_REMOTE_TYPE) {
TimeDuration runtime = TimeStamp::Now() - mActivateTS;
Telemetry::Accumulate(Telemetry::PROCESS_LIFETIME,
uint64_t(runtime.ToSeconds()));
glean::process::lifetime.AccumulateRawDuration(runtime);
}
if (mSendShutdownTimer) {
@@ -2007,8 +2007,7 @@ void ContentParent::ActorDestroy(ActorDestroyReason why) {
props->SetPropertyAsUint64(u"childID"_ns, mChildID);
if (AbnormalShutdown == why) {
Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT, "content"_ns,
1);
glean::subprocess::abnormal_abort.Get("content"_ns).Add(1);
props->SetPropertyAsBool(u"abnormal"_ns, true);
@@ -4349,7 +4348,7 @@ void ContentParent::KillHard(const char* aReason) {
} else {
reason = nsDependentCString("KillHard after IsNotifiedShutdownSuccess.");
}
Telemetry::Accumulate(Telemetry::SUBPROCESS_KILL_HARD, reason, 1);
glean::subprocess::kill_hard.Get(reason).Add(1);
ProcessHandle otherProcessHandle;
if (!base::OpenProcessHandle(OtherPid(), &otherProcessHandle)) {

View File

@@ -28,6 +28,7 @@
#include "mozilla/SSE.h"
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/SyncRunnable.h"
#include "mozilla/glean/IpcMetrics.h"
#include "mozilla/Telemetry.h"
#include "mozilla/Unused.h"
#include "nsComponentManagerUtils.h"
@@ -818,8 +819,7 @@ void GMPParent::ActorDestroy(ActorDestroyReason aWhy) {
uint32_t(GMPState(mState)));
if (AbnormalShutdown == aWhy) {
Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT, "gmplugin"_ns,
1);
glean::subprocess::abnormal_abort.Get("gmplugin"_ns).Add(1);
nsString dumpID;
GetCrashID(dumpID);
if (dumpID.IsEmpty()) {

View File

@@ -27,6 +27,7 @@
#include "mozilla/dom/MemoryReportRequest.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/glean/GleanTestsTestMetrics.h"
#include "mozilla/glean/IpcMetrics.h"
#include "mozilla/ipc/CrashReporterClient.h"
#include "mozilla/ipc/ProcessChild.h"
@@ -300,7 +301,7 @@ void RDDParent::ActorDestroy(ActorDestroyReason aWhy) {
if (AbnormalShutdown == aWhy) {
NS_WARNING("Shutting down RDD process early due to a crash!");
Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT, "rdd"_ns, 1);
glean::subprocess::abnormal_abort.Get("rdd"_ns).Add(1);
ProcessChild::QuickExit();
}

View File

@@ -18,6 +18,7 @@
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/glean/GfxMetrics.h"
#include "mozilla/glean/IpcMetrics.h"
#include "mozilla/Telemetry.h"
#include "mozilla/TelemetryIPC.h"
#include "mozilla/dom/CheckerboardReportService.h"
@@ -320,10 +321,10 @@ mozilla::ipc::IPCResult GPUChild::RecvAddMemoryReport(
void GPUChild::ActorDestroy(ActorDestroyReason aWhy) {
if (aWhy == AbnormalShutdown || mUnexpectedShutdown) {
Telemetry::Accumulate(
Telemetry::SUBPROCESS_ABNORMAL_ABORT,
nsDependentCString(XRE_GeckoProcessTypeToString(GeckoProcessType_GPU)),
1);
glean::subprocess::abnormal_abort
.Get(nsDependentCString(
XRE_GeckoProcessTypeToString(GeckoProcessType_GPU)))
.Add(1);
nsAutoString dumpId;
if (!mCreatedPairedMinidumps) {

View File

@@ -11,7 +11,7 @@
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/IpcMetrics.h"
#include "mozilla/VsyncDispatcher.h"
#include "mozilla/dom/MemoryReportRequest.h"
@@ -88,10 +88,10 @@ void VRChild::ActorDestroy(ActorDestroyReason aWhy) {
if (aWhy == AbnormalShutdown) {
GenerateCrashReport();
Telemetry::Accumulate(
Telemetry::SUBPROCESS_ABNORMAL_ABORT,
nsDependentCString(XRE_GeckoProcessTypeToString(GeckoProcessType_VR)),
1);
glean::subprocess::abnormal_abort
.Get(nsDependentCString(
XRE_GeckoProcessTypeToString(GeckoProcessType_VR)))
.Add(1);
}
gfxVars::RemoveReceiver(this);
mHost->OnChannelClosed();

View File

@@ -8,7 +8,7 @@
#include "mozilla/dom/Promise.h"
#include "mozilla/Sprintf.h"
#include "mozilla/SyncRunnable.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/IpcMetrics.h"
#include "nsServiceManagerUtils.h"
#include "nsICrashService.h"
#include "nsXULAppAPI.h"
@@ -122,7 +122,7 @@ void CrashReporterHost::RecordCrashWithTelemetry(GeckoProcessType aProcessType,
MOZ_ASSERT_UNREACHABLE("unknown process type");
}
Telemetry::Accumulate(Telemetry::SUBPROCESS_CRASHES_WITH_DUMP, key, 1);
glean::subprocess::crashes_with_dump.Get(key).Add(1);
}
/* static */

View File

@@ -52,7 +52,7 @@
#include "mozilla/StaticMutex.h"
#include "mozilla/TaskQueue.h"
#include "mozilla/glean/DomMetrics.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/IpcMetrics.h"
#include "mozilla/UniquePtrExtensions.h"
#include "mozilla/ipc/IOThread.h"
#include "mozilla/ipc/EnvironmentMap.h"
@@ -806,10 +806,10 @@ bool GeckoChildProcessHost::AsyncLaunch(
<< XRE_GeckoProcessTypeToString(mProcessType)
<< " subprocess @" << aError.FunctionName()
<< " (Error:" << aError.ErrorCode() << ")";
Telemetry::Accumulate(
Telemetry::SUBPROCESS_LAUNCH_FAILURE,
nsDependentCString(
XRE_GeckoProcessTypeToString(mProcessType)));
glean::subprocess::launch_failure
.Get(nsDependentCString(
XRE_GeckoProcessTypeToString(mProcessType)))
.Add(1);
nsCString telemetryKey = nsPrintfCString(
#if defined(XP_WIN)
"%s,0x%lx,%s",
@@ -1730,8 +1730,8 @@ RefPtr<ProcessLaunchPromise> BaseProcessLauncher::FinishLaunch() {
MOZ_DIAGNOSTIC_ASSERT(mResults.mHandle);
Telemetry::AccumulateTimeDelta(Telemetry::CHILD_PROCESS_LAUNCH_MS,
mStartTimeStamp);
glean::process::child_launch.AccumulateRawDuration(TimeStamp::Now() -
mStartTimeStamp);
return ProcessLaunchPromise::CreateAndResolve(std::move(mResults), __func__);
}

View File

@@ -26,7 +26,7 @@
#include "mozilla/ScopeExit.h"
#include "mozilla/Sprintf.h"
#include "mozilla/StaticMutex.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/IpcMetrics.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/UniquePtrExtensions.h"
#include "mozilla/dom/ScriptSettings.h"
@@ -2393,8 +2393,9 @@ void CancelCPOWs() {
MOZ_ASSERT(NS_IsMainThread());
if (gParentProcessBlocker) {
mozilla::Telemetry::Accumulate(mozilla::Telemetry::IPC_TRANSACTION_CANCEL,
true);
mozilla::glean::ipc::transaction_cancel
.EnumGet(mozilla::glean::ipc::TransactionCancelLabel::eTrue)
.Add();
gParentProcessBlocker->CancelCurrentTransaction();
}
}

138
ipc/metrics.yaml Normal file
View File

@@ -0,0 +1,138 @@
# 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 :: DOM: Content Processes'
process:
child_launch:
type: timing_distribution
description: >
Time spent in the generic child process launching code, which is run
off-main-thread and used by all child process types
This metric was generated to correspond to the Legacy Telemetry
exponential histogram CHILD_PROCESS_LAUNCH_MS.
time_unit: millisecond
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1474991
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1474991
notification_emails:
- jld@mozilla.com
- jimm@mozilla.com
- mconley@mozilla.com
expires: never
telemetry_mirror: CHILD_PROCESS_LAUNCH_MS
lifetime:
type: timing_distribution
description: >
Average lifetime of a content process in seconds
This metric was generated to correspond to the Legacy Telemetry
exponential histogram PROCESS_LIFETIME.
time_unit: second
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1897060
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1897060
notification_emails:
- pbone@mozilla.com
expires: 142
telemetry_mirror: PROCESS_LIFETIME
ipc:
transaction_cancel:
type: labeled_counter
description: >
True when an IPC transaction is canceled
This metric was generated to correspond to the Legacy Telemetry boolean
histogram IPC_TRANSACTION_CANCEL.
labels:
- "false"
- "true"
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
notification_emails:
- billm@mozilla.com
expires: never
telemetry_mirror: h#IPC_TRANSACTION_CANCEL
subprocess:
abnormal_abort:
type: labeled_counter
description: >
Counts of plugin/content process abnormal shutdown, whether or not a crash
report was available.
This metric was generated to correspond to the Legacy Telemetry count
histogram SUBPROCESS_ABNORMAL_ABORT.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
notification_emails:
- gsvelto@mozilla.com
expires: never
telemetry_mirror: h#SUBPROCESS_ABNORMAL_ABORT
crashes_with_dump:
type: labeled_counter
description: >
Counts of plugin and content process crashes which are reported with a
crash dump.
This metric was generated to correspond to the Legacy Telemetry count
histogram SUBPROCESS_CRASHES_WITH_DUMP.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1950710
notification_emails:
- gsvelto@mozilla.com
expires: never
telemetry_mirror: h#SUBPROCESS_CRASHES_WITH_DUMP
launch_failure:
type: labeled_counter
description: >
Counts the number of times launching a subprocess fails. Counts are by
subprocess-type using the GeckoProcessType enum.
This metric was generated to correspond to the Legacy Telemetry count
histogram SUBPROCESS_LAUNCH_FAILURE.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1275430
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1275430
notification_emails:
- haftandilian@mozilla.com
expires: never
telemetry_mirror: h#SUBPROCESS_LAUNCH_FAILURE
kill_hard:
type: labeled_counter
description: >
Counts the number of times a subprocess was forcibly killed, and the
reason.
This metric was generated to correspond to the Legacy Telemetry count
histogram SUBPROCESS_KILL_HARD.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1269961
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1269961
notification_emails:
- wmccloskey@mozilla.com
expires: never
telemetry_mirror: h#SUBPROCESS_KILL_HARD

View File

@@ -48,6 +48,7 @@ gecko_metrics = [
"editor/libeditor/metrics.yaml",
"gfx/metrics.yaml",
"image/decoders/metrics.yaml",
"ipc/metrics.yaml",
"js/xpconnect/metrics.yaml",
"layout/base/metrics.yaml",
"mobile/shared/modules/geckoview/metrics.yaml",

View File

@@ -16,8 +16,8 @@ Also, the ``aborted-session`` is updated at least every 5 minutes, so it may lag
Child process crashes
=====================
If a Firefox plugin, content, gmplugin, or any other type of child process dies unexpectedly, this is recorded in the main ping's ``SUBPROCESS_ABNORMAL_ABORT`` keyed histogram.
If a Firefox plugin, content, gmplugin, or any other type of child process dies unexpectedly, this is recorded in the main ping's ``SUBPROCESS_ABNORMAL_ABORT`` keyed histogram (glean subprocess:abnormal_abort metric).
If we catch a crash report for this, then additionally the ``SUBPROCESS_CRASHES_WITH_DUMP`` keyed histogram is incremented.
If we catch a crash report for this, then additionally the ``SUBPROCESS_CRASHES_WITH_DUMP`` keyed histogram (glean subprocess:crashes_with_dump metric) is incremented.
Some processes also generate :doc:`crash pings <../data/crash-ping>` when they crash and generate a crash dump. See `bug 1352496 <https://bugzilla.mozilla.org/show_bug.cgi?id=1352496>`_ for an example of how to allow crash pings for new process types.