Skip to content
This repository was archived by the owner on Nov 1, 2022. It is now read-only.

Commit 3c3ed6e

Browse files
committed
Record Sync engine telemetry in Glean.
1 parent 6714341 commit 3c3ed6e

File tree

18 files changed

+583
-50
lines changed

18 files changed

+583
-50
lines changed

buildSrc/src/main/java/Dependencies.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ object Dependencies {
9797
const val tools_lintapi = "com.android.tools.lint:lint-api:${Versions.lint}"
9898
const val tools_linttests = "com.android.tools.lint:lint-tests:${Versions.lint}"
9999

100-
const val mozilla_appservices_support = "org.mozilla.appservices:support:${Versions.mozilla_appservices}"
101100
const val mozilla_fxa = "org.mozilla.appservices:fxaclient:${Versions.mozilla_appservices}"
102101
const val mozilla_support = "org.mozilla.appservices:support:${Versions.mozilla_appservices}"
103102
const val mozilla_sync_logins = "org.mozilla.appservices:logins:${Versions.mozilla_appservices}"
104103
const val mozilla_places = "org.mozilla.appservices:places:${Versions.mozilla_appservices}"
105104
const val mozilla_places_forUnitTests = "org.mozilla.appservices:places-forUnitTests:${Versions.mozilla_appservices}"
105+
const val mozilla_sync15 = "org.mozilla.appservices:sync15:${Versions.mozilla_appservices}"
106106
const val mozilla_rustlog = "org.mozilla.appservices:rustlog:${Versions.mozilla_appservices}"
107107
const val mozilla_servo_arm = "org.mozilla.servoview:servoview-armv7:${Versions.servo}"
108108
const val mozilla_servo_x86 = "org.mozilla.servoview:servoview-x86:${Versions.servo}"

components/browser/storage-sync/build.gradle

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5+
plugins {
6+
id "com.jetbrains.python.envs" version "0.0.26"
7+
}
8+
59
apply plugin: 'com.android.library'
610
apply plugin: 'kotlin-android'
711

@@ -46,7 +50,9 @@ dependencies {
4650
api project(':concept-storage')
4751
api project(':concept-sync')
4852

53+
implementation project(':service-glean')
4954
implementation project(':support-utils')
55+
implementation Dependencies.mozilla_sync15
5056

5157
implementation Dependencies.kotlin_stdlib
5258

@@ -65,3 +71,5 @@ dependencies {
6571

6672
apply from: '../../../publish.gradle'
6773
ext.configurePublish(config.componentsGroupId, archivesBaseName, project.ext.description)
74+
75+
apply from: '../../service/glean/scripts/sdk_generator.gradle'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
$schema: moz://mozilla.org/schemas/glean/metrics/1-0-0
6+
7+
events:
8+
fetch_local_tree:
9+
type: event
10+
description: The merger built the local tree.
11+
extra_keys:
12+
flow_id:
13+
description: A flow ID grouping all events for this merge.
14+
time:
15+
description: The time taken to run the merge, in milliseconds.
16+
items:
17+
description: The number of items in the tree.
18+
send_in_pings:
19+
- bookmarks_sync
20+
bugs:
21+
- 000
22+
data_reviews:
23+
- https://github.com/mozilla-mobile/fenix/pull/000
24+
notification_emails:
25+
- sync-core@mozilla.com
26+
expires: never
27+
fetch_local_contents:
28+
type: event
29+
description: The merger fetched content info for all new local items.
30+
extra_keys:
31+
flow_id:
32+
description: A flow ID grouping all events for this merge.
33+
time:
34+
description: The time taken to run the merge, in milliseconds.
35+
items:
36+
description: The number of items in the tree.
37+
send_in_pings:
38+
- bookmarks_sync
39+
bugs:
40+
- 000
41+
data_reviews:
42+
- https://github.com/mozilla-mobile/fenix/pull/000
43+
notification_emails:
44+
- sync-core@mozilla.com
45+
expires: never
46+
merge:
47+
type: event
48+
description: The merger finished merging the local and remote trees.
49+
extra_keys:
50+
flow_id:
51+
description: A flow ID grouping all events for this merge.
52+
time:
53+
description: The time taken to run the merge, in milliseconds.
54+
send_in_pings:
55+
- bookmarks_sync
56+
bugs:
57+
- 000
58+
data_reviews:
59+
- https://github.com/mozilla-mobile/fenix/pull/000
60+
notification_emails:
61+
- sync-core@mozilla.com
62+
expires: never
63+
structure:
64+
type: event
65+
description: The merger has structure info for a local or remote tree.
66+
extra_keys:
67+
remote_revives:
68+
description: Remote non-folder change wins over local deletion.
69+
local_deletes:
70+
description: Local folder deletion wins over remote change.
71+
local_revives:
72+
description: Local non-folder change wins over remote deletion.
73+
remote_deletes:
74+
description: Remote folder deletion wins over local change.
75+
dupes:
76+
description: Deduped local items.
77+
send_in_pings:
78+
- bookmarks_sync
79+
bugs:
80+
- 000
81+
data_reviews:
82+
- https://github.com/mozilla-mobile/fenix/pull/000
83+
notification_emails:
84+
- sync-core@mozilla.com
85+
expires: never
86+
87+
# The `history_sync` and `bookmarks_sync` metrics use the same structure, but are
88+
# sent in separate pings, after each sync. This means we submit one ping per
89+
# store per sync.
90+
history_sync:
91+
started_at:
92+
type: datetime
93+
time_unit: millisecond
94+
description: >
95+
Records when the history sync started.
96+
send_in_pings:
97+
- history_sync
98+
bugs:
99+
- 000
100+
data_reviews:
101+
- https://github.com/mozilla-mobile/fenix/pull/000
102+
notification_emails:
103+
- sync-core@mozilla.com
104+
expires: never
105+
finished_at:
106+
type: datetime
107+
time_unit: millisecond
108+
description: >
109+
Records when the history sync finished.
110+
send_in_pings:
111+
- history_sync
112+
bugs:
113+
- 000
114+
data_reviews:
115+
- https://github.com/mozilla-mobile/fenix/pull/000
116+
notification_emails:
117+
- sync-core@mozilla.com
118+
expires: never
119+
incoming:
120+
type: labeled_counter
121+
labels:
122+
- applied
123+
- failed_to_apply
124+
- reconciled
125+
description: >
126+
Records incoming history record counts.
127+
send_in_pings:
128+
- history_sync
129+
bugs:
130+
- 000
131+
data_reviews:
132+
- https://github.com/mozilla-mobile/fenix/pull/000
133+
notification_emails:
134+
- sync-core@mozilla.com
135+
expires: never
136+
outgoing:
137+
type: labeled_counter
138+
labels:
139+
- uploaded
140+
- failed_to_upload
141+
description: >
142+
Records outgoing history record counts.
143+
send_in_pings:
144+
- history_sync
145+
bugs:
146+
- 000
147+
data_reviews:
148+
- https://github.com/mozilla-mobile/fenix/pull/000
149+
notification_emails:
150+
- sync-core@mozilla.com
151+
expires: never
152+
outgoing_batches:
153+
type: counter
154+
description: >
155+
Records the number of batches needed to upload all outgoing records.
156+
send_in_pings:
157+
- history_sync
158+
bugs:
159+
- 000
160+
data_reviews:
161+
- https://github.com/mozilla-mobile/fenix/pull/000
162+
notification_emails:
163+
- sync-core@mozilla.com
164+
expires: never
165+
failure_reason:
166+
type: labeled_string
167+
labels:
168+
- other
169+
- unexpected
170+
- auth
171+
description: >
172+
Records history sync failure reasons.
173+
send_in_pings:
174+
- history_sync
175+
bugs:
176+
- 000
177+
data_reviews:
178+
- https://github.com/mozilla-mobile/fenix/pull/000
179+
notification_emails:
180+
- sync-core@mozilla.com
181+
expires: never
182+
183+
bookmarks_sync:
184+
started_at:
185+
type: datetime
186+
time_unit: millisecond
187+
description: >
188+
Records when the bookmark sync started.
189+
send_in_pings:
190+
- bookmarks_sync
191+
bugs:
192+
- 000
193+
data_reviews:
194+
- https://github.com/mozilla-mobile/fenix/pull/000
195+
notification_emails:
196+
- sync-core@mozilla.com
197+
expires: never
198+
finished_at:
199+
type: datetime
200+
time_unit: millisecond
201+
description: >
202+
Records when the bookmark sync finished.
203+
send_in_pings:
204+
- bookmarks_sync
205+
bugs:
206+
- 000
207+
data_reviews:
208+
- https://github.com/mozilla-mobile/fenix/pull/000
209+
notification_emails:
210+
- sync-core@mozilla.com
211+
expires: never
212+
incoming:
213+
type: labeled_counter
214+
labels:
215+
- applied
216+
- failed_to_apply
217+
- reconciled
218+
description: >
219+
Records incoming bookmark record counts.
220+
send_in_pings:
221+
- bookmarks_sync
222+
bugs:
223+
- 000
224+
data_reviews:
225+
- https://github.com/mozilla-mobile/fenix/pull/000
226+
notification_emails:
227+
- sync-core@mozilla.com
228+
expires: never
229+
outgoing:
230+
type: labeled_counter
231+
labels:
232+
- uploaded
233+
- failed_to_upload
234+
description: >
235+
Records outgoing bookmark record counts.
236+
send_in_pings:
237+
- bookmarks_sync
238+
bugs:
239+
- 000
240+
data_reviews:
241+
- https://github.com/mozilla-mobile/fenix/pull/000
242+
notification_emails:
243+
- sync-core@mozilla.com
244+
expires: never
245+
outgoing_batches:
246+
type: counter
247+
description: >
248+
Records the number of batches needed to upload all outgoing records.
249+
send_in_pings:
250+
- history_sync
251+
bugs:
252+
- 000
253+
data_reviews:
254+
- https://github.com/mozilla-mobile/fenix/pull/000
255+
notification_emails:
256+
- sync-core@mozilla.com
257+
expires: never
258+
failure_reason:
259+
type: labeled_string
260+
labels:
261+
- other
262+
- unexpected
263+
- auth
264+
description: >
265+
Records bookmark sync failure reasons.
266+
send_in_pings:
267+
- bookmarks_sync
268+
bugs:
269+
- 000
270+
data_reviews:
271+
- https://github.com/mozilla-mobile/fenix/pull/000
272+
notification_emails:
273+
- sync-core@mozilla.com
274+
expires: never
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
$schema: moz://mozilla.org/schemas/glean/pings/1-0-0
6+
7+
history_sync:
8+
description: >
9+
A ping sent for every history sync. It doesn't include the `client_id`
10+
because it reports a hashed version of the user's FxA ID.
11+
include_client_id: false
12+
bugs:
13+
- 000
14+
notification_emails:
15+
- sync-core@mozilla.com
16+
bookmarks_sync:
17+
description: >
18+
A ping sent for every bookmarks sync. It doesn't include the `client_id`
19+
because it reports a hashed version of the user's FxA ID.
20+
include_client_id: false
21+
bugs:
22+
- 000
23+
notification_emails:
24+
- sync-core@mozilla.com

components/browser/storage-sync/src/main/java/mozilla/components/browser/storage/sync/Connection.kt

+9-7
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
package mozilla.components.browser.storage.sync
66

77
import androidx.annotation.GuardedBy
8+
import android.util.Log
89
import mozilla.appservices.places.PlacesApi
910
import mozilla.appservices.places.PlacesReaderConnection
1011
import mozilla.appservices.places.PlacesWriterConnection
12+
import mozilla.appservices.sync15.SyncTelemetryPing
1113
import java.io.Closeable
1214
import java.io.File
1315

@@ -22,14 +24,14 @@ const val DB_NAME = "places.sqlite"
2224
*
2325
* Writer is always the same, as guaranteed by [PlacesApi].
2426
*/
25-
interface Connection : Closeable {
27+
internal interface Connection : Closeable {
2628
fun reader(): PlacesReaderConnection
2729
fun writer(): PlacesWriterConnection
2830

2931
// Until we get a real SyncManager in application-services libraries, we'll have to live with this
3032
// strange split that doesn't quite map all that well to our internal storage model.
31-
fun syncHistory(syncInfo: SyncAuthInfo)
32-
fun syncBookmarks(syncInfo: SyncAuthInfo)
33+
fun syncHistory(syncInfo: SyncAuthInfo): SyncTelemetryPing
34+
fun syncBookmarks(syncInfo: SyncAuthInfo): SyncTelemetryPing
3335
}
3436

3537
/**
@@ -65,14 +67,14 @@ internal object RustPlacesConnection : Connection {
6567
return api!!.getWriter()
6668
}
6769

68-
override fun syncHistory(syncInfo: SyncAuthInfo) {
70+
override fun syncHistory(syncInfo: SyncAuthInfo): SyncTelemetryPing {
6971
check(api != null) { "must call init first" }
70-
api!!.syncHistory(syncInfo)
72+
return api!!.syncHistory(syncInfo)
7173
}
7274

73-
override fun syncBookmarks(syncInfo: SyncAuthInfo) {
75+
override fun syncBookmarks(syncInfo: SyncAuthInfo): SyncTelemetryPing {
7476
check(api != null) { "must call init first" }
75-
api!!.syncBookmarks(syncInfo)
77+
return api!!.syncBookmarks(syncInfo)
7678
}
7779

7880
override fun close() = synchronized(this) {

0 commit comments

Comments
 (0)