-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added FXIOS-7558 [v119] metric kit large disk write exception (backport
#16826) (#16860) * Added FXIOS-7558 [v119] metric kit large disk write exception (#16826) * Add initial recording * Add glean test * Update Client/metrics.yaml Co-authored-by: lmarceau <[email protected]> --------- Co-authored-by: lmarceau <[email protected]> (cherry picked from commit a8f0fb7) * Fix conflict * Fix lint issue --------- Co-authored-by: OrlaM <[email protected]>
- Loading branch information
1 parent
d79c2e0
commit 7c9c164
Showing
6 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// 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/ | ||
|
||
import Foundation | ||
import MetricKit | ||
|
||
class MetricKitWrapper: NSObject, MXMetricManagerSubscriber { | ||
private let telemetryWrapper: TelemetryWrapperProtocol | ||
private let measurementFormatter: MeasurementFormatter | ||
|
||
init(telemetryWrapper: TelemetryWrapperProtocol = TelemetryWrapper.shared) { | ||
self.telemetryWrapper = telemetryWrapper | ||
|
||
self.measurementFormatter = MeasurementFormatter() | ||
self.measurementFormatter.locale = Locale(identifier: "en_US") | ||
self.measurementFormatter.unitOptions = .providedUnit | ||
|
||
super.init() | ||
MXMetricManager.shared.add(self) | ||
} | ||
|
||
func didReceive(_ payloads: [MXDiagnosticPayload]) { | ||
payloads.forEach { payload in | ||
payload.diskWriteExceptionDiagnostics?.forEach({ exception in | ||
self.handleDiskWriteException(exception) | ||
}) | ||
} | ||
} | ||
|
||
private func handleDiskWriteException(_ exception: MXDiskWriteExceptionDiagnostic) { | ||
let size = Int32(measurementFormatter.string(from: exception.totalWritesCaused)) ?? -1 | ||
let eventExtra = [TelemetryWrapper.EventExtraKey.size.rawValue: size] | ||
telemetryWrapper.recordEvent(category: .information, | ||
method: .error, | ||
object: .app, | ||
value: .largeFileWrite, | ||
extras: eventExtra) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4392,3 +4392,21 @@ baseline.validation: | |
expires: 2023-12-31 | ||
data_sensitivity: | ||
- interaction | ||
|
||
app_errors: | ||
large_file_write: | ||
type: event | ||
description: | | ||
Recorded when a very large file is written to disk | ||
extra_keys: | ||
size: | ||
description: | | ||
The size of the file that was written | ||
type: quantity | ||
bugs: | ||
- https://mozilla-hub.atlassian.net/browse/FXIOS-7558 | ||
data_reviews: | ||
- https://github.com/mozilla-mobile/firefox-ios/pull/16826 | ||
notification_emails: | ||
- [email protected] | ||
expires: never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters