Bug 1918226 - Use Glean APIs for ysod.shown#ysod r=gregtatum,eemeli

Differential Revision: https://phabricator.services.mozilla.com/D221498
This commit is contained in:
Chris H-C 2024-09-20 18:43:08 +00:00
parent 5b571268bf
commit 446f16283a
3 changed files with 78 additions and 24 deletions

View File

@ -0,0 +1,64 @@
# 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 :: XML'
ysod:
shown_ysod:
type: event
description: >
This event is recorded only for Firefox UI documents (chrome).
Recorded when a Yellow Screen of Death is shown. The `value` is a
url on which the error happened. Yellow Screen of Death happens when
XML or XHTML document encounters a parsing error. It is commonly a
result of the document being malformed or missing DTD entity.
This data should be reviewed periodically for urls that error frequently.
This event was generated to correspond to the Legacy Telemetry event
ysod.shown#ysod.
bugs: &ysod_shown_bugs
- https://bugzil.la/1657242
data_reviews: &ysod_shown_data_reviews
- https://bugzil.la/1657242
notification_emails:
- gtatum@mozilla.com
- nordzilla@mozilla.com
- earo@mozilla.com
- vchin@mozilla.com
expires: never
extra_keys:
value:
description: >
The url of the Firefox UI (chrome) document that showed the YSOD.
type: string
error_code:
description: >
Code of the XML Error (See `XML_Error` enum in expat.h for the list of errors where XML_ERROR_NONE is 0).
type: quantity
location:
description: >
Location as Row:Column of where the error happened.
type: string
last_line:
description: >
The content of the last line that led to the error.
type: string
last_line_len:
description: >
The length of the last line that led to the error.
type: quantity
hidden:
description: >
The document is hidden.
type: boolean
destroyed:
description: >
The container of this document is destroyed.
type: string
telemetry_mirror: Ysod_Shown_Ysod

View File

@ -35,7 +35,7 @@
#include "mozilla/IntegerTypeTraits.h"
#include "mozilla/NullPrincipal.h"
#include "mozilla/Telemetry.h"
#include "mozilla/TelemetryComms.h"
#include "mozilla/glean/GleanMetrics.h"
#include "nsThreadUtils.h"
#include "mozilla/ClearOnShutdown.h"
@ -1108,30 +1108,19 @@ nsresult nsExpatDriver::HandleError() {
docShellDestroyed.Assign(destroyed ? "true"_ns : "false"_ns);
}
mozilla::Maybe<nsTArray<mozilla::Telemetry::EventExtraEntry>> extra =
mozilla::Some<nsTArray<mozilla::Telemetry::EventExtraEntry>>({
mozilla::Telemetry::EventExtraEntry{"error_code"_ns,
nsPrintfCString("%u", code)},
mozilla::Telemetry::EventExtraEntry{
"location"_ns,
nsPrintfCString(
"%lu:%lu",
lineNumber.unverified_safe_because(RLBOX_SAFE_PRINT),
colNumber.unverified_safe_because(RLBOX_SAFE_PRINT))},
mozilla::Telemetry::EventExtraEntry{
"last_line"_ns, NS_ConvertUTF16toUTF8(mLastLine)},
mozilla::Telemetry::EventExtraEntry{
"last_line_len"_ns, nsPrintfCString("%zu", mLastLine.Length())},
mozilla::Telemetry::EventExtraEntry{
"hidden"_ns, doc->Hidden() ? "true"_ns : "false"_ns},
mozilla::Telemetry::EventExtraEntry{"destroyed"_ns,
docShellDestroyed},
});
mozilla::Telemetry::SetEventRecordingEnabled("ysod"_ns, true);
mozilla::Telemetry::RecordEvent(
mozilla::Telemetry::EventID::Ysod_Shown_Ysod, mozilla::Some(path),
extra);
mozilla::glean::ysod::ShownYsodExtra extra = {
.destroyed = mozilla::Some(docShellDestroyed),
.errorCode = mozilla::Some(code),
.hidden = mozilla::Some(doc->Hidden()),
.lastLine = mozilla::Some(NS_ConvertUTF16toUTF8(mLastLine)),
.lastLineLen = mozilla::Some(mLastLine.Length()),
.location = mozilla::Some(nsPrintfCString(
"%lu:%lu", lineNumber.unverified_safe_because(RLBOX_SAFE_PRINT),
colNumber.unverified_safe_because(RLBOX_SAFE_PRINT))),
.value = mozilla::Some(path),
};
mozilla::glean::ysod::shown_ysod.Record(mozilla::Some(extra));
}
// Try to create and initialize the script error.

View File

@ -40,6 +40,7 @@ gecko_metrics = [
"netwerk/metrics.yaml",
"netwerk/protocol/http/metrics.yaml",
"parser/html/metrics.yaml",
"parser/htmlparser/metrics.yaml",
"security/certverifier/metrics.yaml",
"security/manager/ssl/metrics.yaml",
"services/common/metrics.yaml",