Skip to content

Commit

Permalink
extend metric, add extra (#10133)
Browse files Browse the repository at this point in the history
* add extra to metric and extend the metric

* extend connection health error metric and add extra

* fix syntax
  • Loading branch information
mcleinman authored Jan 2, 2025
1 parent e172d9b commit 1078d39
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/platforms/ios/ConnectionHealth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ class ConnectionHealth {
}

logger.info(message: "Creating PingAnalyzer")
let _ = PingAnalyzer(pingAddress: pingAddress) { (connectivity) in
let _ = PingAnalyzer(pingAddress: pingAddress) { (connectivity, error) in
guard let connectivity = connectivity else {
self.logger.error(message: "PingAnalyzer returned error")
GleanMetrics.ConnectionHealth.pingAnalyzerError.record()
GleanMetrics.ConnectionHealth.pingAnalyzerError.record(GleanMetrics.ConnectionHealth.PingAnalyzerErrorExtra(errorMessage: error?.localizedDescription ?? "no error"))
return
}

Expand Down
12 changes: 6 additions & 6 deletions src/platforms/ios/PingAnalyzer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class PingAnalyzer {
private let pingLossUnstableThreshold: Double = 0.65 // 13 of 20 pings
private let pingLossNoSignalThreshold: Double = 1.0 // all pings

private let callback: (ConnectionHealth.ConnectionStability?) -> Void
private let callback: (ConnectionHealth.ConnectionStability?, Error?) -> Void

init(pingAddress: String, callback: @escaping (ConnectionHealth.ConnectionStability?) -> Void) {
init(pingAddress: String, callback: @escaping (ConnectionHealth.ConnectionStability?, Error?) -> Void) {
self.callback = callback

do {
Expand All @@ -55,7 +55,7 @@ class PingAnalyzer {
timer = Timer.scheduledTimer(timeInterval: TimeInterval(checkTime), target: self, selector: #selector(calculateStability), userInfo: nil, repeats: false)
} catch {
logger.error(message: "Error when sending pings: \(error)")
callback(nil)
callback(nil, error)
}
}

Expand All @@ -68,11 +68,11 @@ class PingAnalyzer {

// If any pings take too long to return or
if (packetLossPercent >= pingLossNoSignalThreshold) {
callback(.noSignal)
callback(.noSignal, nil)
} else if (packetLossPercent >= pingLossUnstableThreshold) {
callback(.unstable)
callback(.unstable, nil)
} else {
callback(.stable)
callback(.stable, nil)
}
}
}
9 changes: 7 additions & 2 deletions src/telemetry/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1050,10 +1050,15 @@ connection_health:
bugs:
- https://mozilla-hub.atlassian.net/browse/VPN-6406
data_reviews:
- TBA
- https://github.com/mozilla-mobile/mozilla-vpn-client/pull/9593#issuecomment-2159109154
data_sensitivity:
- technical
notification_emails:
- [email protected]
- [email protected]
expires: 2024-12-31
expires: 2025-06-30
extra_keys:
error_message:
description: |
Error type
type: string

0 comments on commit 1078d39

Please sign in to comment.