зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1918226 - Use Glean APIs for dom.quota.try.error#step r=janv
Differential Revision: https://phabricator.services.mozilla.com/D221489
This commit is contained in:
Родитель
223708e03f
Коммит
2023bfa52d
|
@ -14,12 +14,10 @@
|
||||||
#include "mozilla/ErrorNames.h"
|
#include "mozilla/ErrorNames.h"
|
||||||
#include "mozilla/MozPromise.h"
|
#include "mozilla/MozPromise.h"
|
||||||
#include "mozilla/Logging.h"
|
#include "mozilla/Logging.h"
|
||||||
#include "mozilla/Telemetry.h"
|
|
||||||
#include "mozilla/TelemetryComms.h"
|
|
||||||
#include "mozilla/TelemetryEventEnums.h"
|
|
||||||
#include "mozilla/TextUtils.h"
|
#include "mozilla/TextUtils.h"
|
||||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||||
#include "mozilla/dom/quota/ScopedLogExtraInfo.h"
|
#include "mozilla/dom/quota/ScopedLogExtraInfo.h"
|
||||||
|
#include "mozilla/glean/GleanMetrics.h"
|
||||||
#include "nsIConsoleService.h"
|
#include "nsIConsoleService.h"
|
||||||
#include "nsIFile.h"
|
#include "nsIFile.h"
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
|
@ -55,8 +53,6 @@ RefPtr<BoolPromise> CreateAndRejectBoolPromiseFromQMResult(
|
||||||
|
|
||||||
namespace dom::quota {
|
namespace dom::quota {
|
||||||
|
|
||||||
using namespace mozilla::Telemetry;
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -554,75 +550,59 @@ void LogError(const nsACString& aExpr, const Maybe<nsresult> aMaybeRv,
|
||||||
// (accidentally) added because they would have to be added to Events.yaml
|
// (accidentally) added because they would have to be added to Events.yaml
|
||||||
// under "dom.quota.try" which would require a data review.
|
// under "dom.quota.try" which would require a data review.
|
||||||
|
|
||||||
auto extra = Some([&] {
|
mozilla::glean::dom_quota_try::ErrorStepExtra extra;
|
||||||
auto res = CopyableTArray<EventExtraEntry>{};
|
extra.context = Some(MOZ_NO_VALIDATE(
|
||||||
res.SetCapacity(9);
|
contextTainted,
|
||||||
|
"Context has been data-reviewed for telemetry transmission."));
|
||||||
res.AppendElement(EventExtraEntry{
|
|
||||||
"context"_ns,
|
|
||||||
MOZ_NO_VALIDATE(
|
|
||||||
contextTainted,
|
|
||||||
"Context has been data-reviewed for telemetry transmission.")});
|
|
||||||
|
|
||||||
# ifdef QM_ERROR_STACKS_ENABLED
|
# ifdef QM_ERROR_STACKS_ENABLED
|
||||||
if (!frameIdString.IsEmpty()) {
|
if (!frameIdString.IsEmpty()) {
|
||||||
res.AppendElement(
|
extra.frameId = Some(frameIdString);
|
||||||
EventExtraEntry{"frame_id"_ns, nsCString{frameIdString}});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!processIdString.IsEmpty()) {
|
if (!processIdString.IsEmpty()) {
|
||||||
res.AppendElement(
|
extra.processId = Some(processIdString);
|
||||||
EventExtraEntry{"process_id"_ns, nsCString{processIdString}});
|
}
|
||||||
}
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
if (!rvName.IsEmpty()) {
|
if (!rvName.IsEmpty()) {
|
||||||
res.AppendElement(EventExtraEntry{"result"_ns, nsCString{rvName}});
|
extra.result = Some(rvName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here, we are generating thread local sequence number and thread Id
|
// Here, we are generating thread local sequence number and thread Id
|
||||||
// information which could be useful for summarizing and categorizing
|
// information which could be useful for summarizing and categorizing
|
||||||
// log statistics in QM_TRY stack propagation scripts. Since, this is
|
// log statistics in QM_TRY stack propagation scripts. Since, this is
|
||||||
// a thread local object, we do not need to worry about data races.
|
// a thread local object, we do not need to worry about data races.
|
||||||
static MOZ_THREAD_LOCAL(uint32_t) sSequenceNumber;
|
static MOZ_THREAD_LOCAL(uint32_t) sSequenceNumber;
|
||||||
|
|
||||||
// This would be initialized once, all subsequent calls would be a no-op.
|
// This would be initialized once, all subsequent calls would be a no-op.
|
||||||
MOZ_ALWAYS_TRUE(sSequenceNumber.init());
|
MOZ_ALWAYS_TRUE(sSequenceNumber.init());
|
||||||
|
|
||||||
// sequence number should always starts at number 1.
|
// sequence number should always starts at number 1.
|
||||||
// `sSequenceNumber` gets initialized to 0; so we have to increment here.
|
// `sSequenceNumber` gets initialized to 0; so we have to increment here.
|
||||||
const auto newSeqNum = sSequenceNumber.get() + 1;
|
const auto newSeqNum = sSequenceNumber.get() + 1;
|
||||||
const auto threadId =
|
const auto threadId = baseprofiler::profiler_current_thread_id().ToNumber();
|
||||||
mozilla::baseprofiler::profiler_current_thread_id().ToNumber();
|
|
||||||
|
|
||||||
const auto threadIdAndSequence =
|
const auto threadIdAndSequence =
|
||||||
(static_cast<uint64_t>(threadId) << 32) | (newSeqNum & 0xFFFFFFFF);
|
(static_cast<uint64_t>(threadId) << 32) | (newSeqNum & 0xFFFFFFFF);
|
||||||
|
|
||||||
res.AppendElement(
|
extra.seq = Some(threadIdAndSequence);
|
||||||
EventExtraEntry{"seq"_ns, IntToCString(threadIdAndSequence)});
|
|
||||||
|
|
||||||
sSequenceNumber.set(newSeqNum);
|
sSequenceNumber.set(newSeqNum);
|
||||||
|
|
||||||
res.AppendElement(EventExtraEntry{"severity"_ns, severityString});
|
extra.severity = Some(severityString);
|
||||||
|
|
||||||
res.AppendElement(
|
extra.sourceFile = Some(sourceFileRelativePath);
|
||||||
EventExtraEntry{"source_file"_ns, nsCString(sourceFileRelativePath)});
|
|
||||||
|
|
||||||
res.AppendElement(
|
extra.sourceLine = Some(aSourceFileLine);
|
||||||
EventExtraEntry{"source_line"_ns, IntToCString(aSourceFileLine)});
|
|
||||||
|
|
||||||
# ifdef QM_ERROR_STACKS_ENABLED
|
# ifdef QM_ERROR_STACKS_ENABLED
|
||||||
if (!stackIdString.IsEmpty()) {
|
if (!stackIdString.IsEmpty()) {
|
||||||
res.AppendElement(
|
extra.stackId = Some(stackIdString);
|
||||||
EventExtraEntry{"stack_id"_ns, nsCString{stackIdString}});
|
}
|
||||||
}
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
return res;
|
glean::dom_quota_try::error_step.Record(Some(extra));
|
||||||
}());
|
|
||||||
|
|
||||||
Telemetry::RecordEvent(Telemetry::EventID::DomQuotaTry_Error_Step,
|
|
||||||
Nothing(), extra);
|
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
# 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 :: Storage: Quota Manager'
|
||||||
|
|
||||||
|
dom.quota.try:
|
||||||
|
error_step:
|
||||||
|
type: event
|
||||||
|
description: >
|
||||||
|
An event recorded on an error of the quota manager or its clients.
|
||||||
|
Since errors are usually propagated up the call chain, all such
|
||||||
|
propagation steps are recorded for an error. This is only active
|
||||||
|
during specific contexts, in particular during storage
|
||||||
|
initialization. No dynamic data is included in the event beyond the
|
||||||
|
error code which will be added through Bug 1670555.
|
||||||
|
This event was generated to correspond to the Legacy Telemetry event
|
||||||
|
dom.quota.try.error#step.
|
||||||
|
bugs:
|
||||||
|
- https://bugzil.la/1665088
|
||||||
|
data_reviews:
|
||||||
|
- https://bugzil.la/1665088
|
||||||
|
notification_emails:
|
||||||
|
- jvarga@mozilla.com
|
||||||
|
- storage-telemetry@mozilla.com
|
||||||
|
expires: never
|
||||||
|
extra_keys:
|
||||||
|
context:
|
||||||
|
description: >
|
||||||
|
The context in which the error occurred, e.g. during a storage initialization.
|
||||||
|
Telemetry events are only emitted for selected contexts.
|
||||||
|
type: string
|
||||||
|
frame_id:
|
||||||
|
description: >
|
||||||
|
Optionally, the frame within stack_id.
|
||||||
|
type: string
|
||||||
|
process_id:
|
||||||
|
description: >
|
||||||
|
Optionally, the process in which the error occured.
|
||||||
|
type: string
|
||||||
|
result:
|
||||||
|
description: >
|
||||||
|
Optionally, the name of the error that occurred.
|
||||||
|
type: string
|
||||||
|
seq:
|
||||||
|
description: >
|
||||||
|
Sequence number.
|
||||||
|
type: quantity
|
||||||
|
severity:
|
||||||
|
description: >
|
||||||
|
One of WARNING or ERROR.
|
||||||
|
type: string
|
||||||
|
source_file:
|
||||||
|
description: >
|
||||||
|
The name of the source code file where the error occurred.
|
||||||
|
type: string
|
||||||
|
source_line:
|
||||||
|
description: >
|
||||||
|
The line within source_file where the error occurred.
|
||||||
|
type: quantity
|
||||||
|
stack_id:
|
||||||
|
description: >
|
||||||
|
Optionally, the stack within process_id.
|
||||||
|
type: string
|
||||||
|
telemetry_mirror: DomQuotaTry_Error_Step
|
|
@ -26,6 +26,7 @@ gecko_metrics = [
|
||||||
"dom/metrics.yaml",
|
"dom/metrics.yaml",
|
||||||
"dom/notification/metrics.yaml",
|
"dom/notification/metrics.yaml",
|
||||||
"dom/performance/metrics.yaml",
|
"dom/performance/metrics.yaml",
|
||||||
|
"dom/quota/metrics.yaml",
|
||||||
"dom/security/metrics.yaml",
|
"dom/security/metrics.yaml",
|
||||||
"dom/webauthn/metrics.yaml",
|
"dom/webauthn/metrics.yaml",
|
||||||
"gfx/metrics.yaml",
|
"gfx/metrics.yaml",
|
||||||
|
|
Загрузка…
Ссылка в новой задаче