1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
|
# 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/.
---
$schema: http://json-schema.org/draft-07/schema#
title: Metrics
description: |
Schema for the metrics.yaml files for Mozilla's Glean telemetry SDK.
The top-level of the `metrics.yaml` file has a key defining each category of
metrics. Categories must be snake_case, and they may also have dots `.` to
define subcategories.
$id: moz://mozilla.org/schemas/glean/metrics/2-0-0
definitions:
token:
type: string
pattern: "^[A-Za-z_][A-Za-z0-9_\\.]*$"
snake_case:
type: string
pattern: "^[a-z_][a-z0-9_]*$"
dotted_snake_case:
type: string
pattern: "^[a-z_][a-z0-9_]{0,29}(\\.[a-z_][a-z0-9_]{0,29})*$"
maxLength: 40
# Prior to version 2.0.0 of the schema, special ping names with underscores
# were also supported.
kebab_case:
type: string
pattern: "^[a-z][a-z0-9-]{0,29}$"
long_id:
allOf:
- $ref: "#/definitions/snake_case"
- maxLength: 40
short_id:
allOf:
- $ref: "#/definitions/snake_case"
- maxLength: 70
labeled_metric_id:
type: string
pattern: "^[ -~]+$"
maxLength: 71 # Note: this should be category + metric + 1
metric:
description: |
Describes a single metric.
See https://mozilla.github.io/glean_parser/metrics-yaml.html
type: object
additionalProperties: false
properties:
type:
title: Metric type
description: |
**Required.**
Specifies the type of a metric, like "counter" or "event". This
defines which operations are valid for the metric, how it is stored
and how data analysis tooling displays it.
The supported types are:
- `event`: Record a specific event (with optional metadata).
Additional properties: `extra_keys`.
- `boolean`: A metric storing values of true or false.
- `string`: A metric storing Unicode string values.
- `string_list`: a list of Unicode strings.
- `counter`: A numeric value that can only be incremented.
- `quantity`: A numeric value that is set directly.
- `timespan`: Represents a time interval. Additional properties:
`time_unit`.
- `timing_distribution`: Record the distribution of multiple
timings. Additional properties: `time_unit`.
- `datetime`: A date/time value. Represented as an ISO datetime in
UTC. Additional properties: `time_unit`.
- `uuid`: Record a UUID v4.
- `url`: Record a valid URL string.
- `memory_distribution`: A histogram for recording memory usage
values. Additional properties: `memory_unit`.
- `custom_distribution`: A histogram with a custom range and number
of buckets. This metric type is for legacy support only and is
only allowed for metrics coming from GeckoView. Additional
properties: `range_min`, `range_max`, `bucket_count`,
`histogram_type`.
- `rate`: Used to record the rate something happens relative to some
other thing. For example, the number of HTTP connections that
experience an error relative to the number of total HTTP
connections made.
- Additionally, labeled versions of many metric types are supported.
These support the `labels`_ parameter, allowing multiple instances
of the metric to be stored at a given set of labels. The labeled
metric types include:
`labeled_boolean`, `labeled_string`, `labeled_counter`.
- `text`: Record long text data.
- `object`: Record structured data based on a pre-defined schema
Additional properties: `structure`.
type: string
enum:
- event
- boolean
- string
- string_list
- counter
- quantity
- timespan
- timing_distribution
- custom_distribution
- memory_distribution
- datetime
- uuid
- url
- jwe
- labeled_boolean
- labeled_string
- labeled_counter
- rate
- text
- object
description:
title: Description
description: |
**Required.**
A textual description of what this metric does, what it means, and its
edge cases or any other helpful information.
Descriptions may contain [markdown
syntax](https://www.markdownguide.org/basic-syntax/).
type: string
metadata:
title: Metadata
description: |
Additional metadata about this metric. Currently limited to a list of
tags.
type: object
properties:
tags:
title: Tags
description: Which tags are specified for this metric.
type: array
items:
type: string
maxLength: 80
default: {}
lifetime:
title: Lifetime
description: |
Defines the lifetime of the metric. It must be one of the following
values:
- `ping` (default): The metric is reset each time it is sent in a
ping.
- `user`: The metric contains a property that is part of the user's
profile and is never reset.
- `application`: The metric contains a property that is related to the
application, and is reset only at application restarts.
enum:
- ping
- user
- application
default: ping
send_in_pings:
title: Send in pings
description: |
Which pings the metric should be sent on. If not specified, the metric
is sent on the "default ping", which is the `events` ping for events,
and the `metrics` ping for everything else. Most metrics don't need to
specify this.
(There is an additional special value of `all-pings` for internal
Glean metrics only that is used to indicate that a metric may appear
in any ping.)
type: array
items:
anyOf:
- $ref: "#/definitions/kebab_case"
# Allow "special" ping names that start with "glean_" used
# internally by the Glean SDK
- type: string
pattern: "^glean_.*$"
default:
- default
notification_emails:
title: Notification emails
description: |
**Required.**
A list of email addresses to notify for important events with the
metric or when people with context or ownership for the metric need to
be contacted.
type: array
minItems: 1
items:
type: string
format: email
bugs:
title: Related bugs
description: |
**Required.**
A list of bug URLs (e.g. Bugzilla and Github) that are relevant to
this metric, e.g., tracking its original implementation or later
changes to it.
Prior to version 2.0.0 of the schema, bugs could also be integers.
type: array
minItems: 1
items:
type: string
format: uri
data_reviews:
title: Review references
description: |
**Required.**
A list of URIs to any data collection reviews relevant to the metric.
type: array
items:
type: string
format: uri
disabled:
title: Disabled
description: |
If `true`, the metric is disabled, and any metric collection on it
will be silently ignored at runtime.
type: boolean
default: false
expires:
title: Expires
description: |
**Required.**
By default it may be one of the following values:
- `<build date>`: An ISO date `yyyy-mm-dd` in UTC on which the
metric expires. For example, `2019-03-13`. This date is checked at
build time. Except in special cases, this form should be used so
that the metric automatically "sunsets" after a period of time.
- `<major version>`: An integer greater than 0 representing the
major version the metric expires in. For example, `11`. The
version is checked at build time against the major provided to the
glean_parser and is only valid if a major version is provided at
built time. If no major version is provided at build time and
expiration by major version is used for a metric, an error is
raised.
Note that mixing expiration by date and version is not allowed
within a product.
- `never`: This metric never expires.
- `expired`: This metric is manually expired.
The default may be overriden in certain applications by the
`custom_validate_expires` and `custom_is_expired` configs.
oneOf:
- type: string
- type: integer
minimum: 1
version:
title: Metric version
description: |
The version of the metric. A monotonically increasing value. If not
provided, defaults to 0.
time_unit:
title: Time unit
description: |
For timespans and datetimes, specifies the unit that the metric will
be stored and displayed in. If not provided, it defaults to
"millisecond". Time values are sent to the backend as integers, so
`time_unit`_ determines the maximum resolution at which timespans are
recorded. Times are always truncated, not rounded, to the nearest time
unit. For example, a measurement of 25 ns will be returned as 0 ms if
`time_unit` is `"millisecond"`.
For timing distributions, times are always recorded and sent in
nanoseconds, but `time_unit` controls the minimum and maximum values.
If not provided, it defaults to "nanosecond".
- nanosecond: 1ns <= x <= 10 minutes
- microsecond: 1μs <= x <= ~6.94 days
- millisecond: 1ms <= x <= ~19 years
Valid when `type`_ is `timespan`, `timing_distribution` or `datetime`.
enum:
- nanosecond
- microsecond
- millisecond
- second
- minute
- hour
- day
memory_unit:
title: Memory unit
description: |
The unit that the incoming memory size values are recorded in.
The units are the power-of-2 units, so "kilobyte" is correctly a
"kibibyte".
- kilobyte == 2^10 == 1,024 bytes
- megabyte == 2^20 == 1,048,576 bytes
- gigabyte == 2^30 == 1,073,741,824 bytes
Values are automatically converted to and transmitted as bytes.
Valid when `type`_ is `memory_distribution`.
enum:
- byte
- kilobyte
- megabyte
- gigabyte
labels:
title: Labels
description: |
A list of labels for a labeled metric. If provided, the labels are
enforced at run time, and recording to an unknown label is recorded
to the special label `__other__`. If not provided, the labels
may be anything, but using too many unique labels will put some
labels in the special label `__other__`.
Valid with any of the labeled metric types.
anyOf:
- type: array
uniqueItems: true
items:
$ref: "#/definitions/labeled_metric_id"
maxItems: 4096
- type: "null"
extra_keys:
title: Extra keys
description: |
The acceptable keys on the "extra" object sent with events. This is an
object mapping the key to an object containing metadata about the key.
A maximum of 50 extra keys is allowed.
This metadata object has the following keys:
- `description`: **Required.** A description of the key.
Valid when `type`_ is `event`.
type: object
propertyNames:
$ref: "#/definitions/dotted_snake_case"
additionalProperties:
type: object
properties:
description:
type: string
type:
type: string
enum:
- string
- boolean
- quantity
required:
- description
maxProperties: 50
default: {}
gecko_datapoint:
title: Gecko Datapoint
description: |
This is a Gecko-specific property. It is the name of the Gecko metric
to accumulate the data from, when using the Glean SDK in a product
using GeckoView. See bug 1566356 for more context.
type: string
range_min:
title: Range minimum
description: |
The minimum value of a custom distribution.
Valid when `type`_ is `custom_distribution`.
type: number
default: 1
range_max:
title: Range maximum
description: |
The maximum value of a custom distribution.
Required when `type`_ is `custom_distribution`.
type: number
bucket_count:
title: Bucket count
description: |
The number of buckets to include in a custom distribution.
Required when `type`_ is `custom_distribution`.
type: number
minimum: 1
maximum: 100
histogram_type:
title: Histogram type
description: |
The type of histogram bucketing to use:
- `linear`: The buckets are linearly spaced within the range.
- `exponential`: The buckets use the natural logarithmic so the
smaller-valued buckets are smaller in size than the higher-valued
buckets.
Required when `type`_ is `custom_distribution`.
enum:
- linear
- exponential
unit:
title: Unit
description: |
The unit of the metric.
This is only required for metrics
that don't already require a meaningful unit, e.g. `quantity`
This is provided for informational purposes only and doesn't have any
effect on data collection.
Metric types like `timespan`, `datetime`
and `timing_distribution` take a `time_unit` instead.
type: string
no_lint:
title: Lint checks to skip
description: |
This parameter lists any lint checks to skip for this metric only.
type: array
items:
type: string
data_sensitivity:
title: The level of data sensitivity
description: |
There are four data collection categories related to data sensitivity
[defined here](https://wiki.mozilla.org/Firefox/Data_Collection):
- **Category 1: Technical Data:** (`technical`) Information about the
machine or Firefox itself. Examples include OS, available memory,
crashes and errors, outcome of automated processes like updates,
safebrowsing, activation, version \#s, and buildid. This also
includes compatibility information about features and APIs used by
websites, addons, and other 3rd-party software that interact with
Firefox during usage.
- **Category 2: Interaction Data:** (`interaction`) Information about
the user’s direct engagement with Firefox. Examples include how many
tabs, addons, or windows a user has open; uses of specific Firefox
features; session length, scrolls and clicks; and the status of
discrete user preferences.
It also includes information about the user's in-product journeys
and product choices helpful to understand engagement (attitudes).
For example, selections of add-ons or tiles to determine
potential interest categories etc.
- **Category 3: Stored Content & Communications:**
(`stored_content`, formerly Web activity data, `web_activity`)
Information about what people store, sync, communicate or connect to
where the information is generally considered to be more sensitive
and personal in nature.
Examples include users' saved URLs or URL history,
specific web browsing history, general information
about their web browsing history
(such as TLDs or categories of webpages visited over time)
and potentially certain types of interaction data
about specific web pages or stories visited
(such as highlighted portions of a story).
It also includes information such as content saved by users to
an individual account like saved URLs, tags, notes, passwords
and files as well as communications that users have with one another
through a Mozilla service.
- **Category 4: Highly sensitive data
or clearly identifiable personal data:** (`highly_sensitive`)
Information that directly identifies a person, or if combined with
other data could identify a person.
This data may be embedded within specific website content,
such as memory contents, dumps, captures of screen data,
or DOM data.
Examples include account registration data like name, password,
and email address associated with an account,
payment data in connection with subscriptions or donations,
contact information such as phone numbers or mailing addresses,
email addresses associated with surveys, promotions
and customer support contacts.
It also includes any data from different categories that,
when combined, can identify a person, device, household or account.
For example Category 1 log data combined with Category 3 saved URLs.
Additional examples are: voice audio commands
(including a voice audio file), speech-to-text or text-to-speech
(including transcripts), biometric data, demographic information,
and precise location data associated with a persistent identifier,
individual or small population cohorts.
This is location inferred or determined from mechanisms
other than IP such as wi-fi access points, Bluetooth beacons,
cell phone towers or provided directly to us,
such as in a survey or a profile.
type: array
items:
enum:
- technical
- interaction
- stored_content
- web_activity
- highly_sensitive
type: string
minLength: 1
uniqueItems: true
telemetry_mirror:
title: Which probe in Telemetry to mirror this metric's value to.
description: |
The C++ enum form of the Scalar, Event, or Histogram to which we
should mirror values.
Use is limited to Firefox Desktop only.
Has no effect when used with non-FOG outputters.
See FOG's documentation on mirroring for details -
https://firefox-source-docs.mozilla.org/toolkit/components/glean/mirroring.html
type: string
minLength: 6
denominator_metric:
title: The name of the denominator for this `rate` metric.
description: |
Denominators for `rate` metrics may be private and internal
or shared and external.
External denominators are `counter` metrics.
This field names the `counter` metric that serves as this
`rate` metric's external denominator.
The named denominator must be defined in this component
so glean_parser can find it.
type: string
structure:
title: A subset of a JSON schema definition
description: |
The expected structure of data, defined in a strict subset of
YAML-dialect JSON Schema (Draft 7) supporting keys "type"
(only values "object", "array", "number", "string", and "boolean"),
"properties", and "items".
type: object
required:
- type
- bugs
- description
- notification_emails
- data_reviews
- expires
type: object
propertyNames:
anyOf:
- allOf:
- $ref: "#/definitions/dotted_snake_case"
- not:
description: "'pings' is reserved as a category name."
const: pings
- not:
description: "'tags' is reserved as a category name."
const: tags
- enum: ['$schema', '$tags']
properties:
$schema:
type: string
format: url
no_lint:
title: Lint checks to skip globally
description: |
This parameter lists any lint checks to skip for this whole file.
type: array
items:
type: string
$tags:
title: Tags that apply to the whole file
description: |
This denotes the list of tags that apply to all metrics in this file.
type: array
items:
type: string
additionalProperties:
type: object
propertyNames:
anyOf:
- $ref: "#/definitions/short_id"
additionalProperties:
allOf:
- $ref: "#/definitions/metric"
-
if:
properties:
type:
const: event
then:
properties:
lifetime:
description: |
Event metrics must have ping lifetime.
const: ping
- if:
not:
properties:
type:
enum:
- timing_distribution
- custom_distribution
- memory_distribution
- quantity
- boolean
- string
- labeled_counter
then:
properties:
gecko_datapoint:
description: |
`gecko_datapoint` is only allowed for `timing_distribution`,
`custom_distribution`, `memory_distribution`, `quantity`,
`boolean`, `string` and `labeled_counter`.
maxLength: 0
-
if:
properties:
type:
const: custom_distribution
then:
required:
- range_max
- bucket_count
- histogram_type
description: |
`custom_distribution` is missing required parameters `range_max`,
`bucket_count` and `histogram_type`.
-
if:
properties:
type:
const: memory_distribution
then:
required:
- memory_unit
description: |
`memory_distribution` is missing required parameter `memory_unit`.
-
if:
properties:
type:
const: quantity
then:
required:
- unit
description: |
`quantity` is missing required parameter `unit`.
-
if:
properties:
type:
const: jwe
then:
required:
- jwe_support_was_removed
description: |
JWE support was removed.
If you require this send an email to glean-team@mozilla.com.
- if:
not:
properties:
type:
const: rate
then:
properties:
denominator_metric:
description: |
`denominator_metric` is only allowed for `rate`.
maxLength: 0
-
if:
properties:
type:
const: text
then:
properties:
lifetime:
description: >
Text metrics must have ping or application lifetime.
enum:
- ping
- application
data_sensitivity:
description: >
Text metrics require Category 3
(`stored_content` / `web_activity`)
or Category 4 (`highly_sensitive`).
type: array
items:
enum:
- stored_content
- web_activity
- highly_sensitive
send_in_pings:
description: |
Text metrics can only be sent in custom pings.
Built-in pings are not allowed.
type: array
items:
allOf:
- $ref: "#/definitions/kebab_case"
- not:
description: >
Text metrics can only be sent in custom pings.
Built-in pings are not allowed."
pattern:
"^(metrics|baseline|events|deletion-request|default|glean_.*)$"
-
if:
# This is a schema check:
# This is true when the checked YAML passes the schema validation.
#
# If it has a datetime/timing_distribution/timespan type
# AND has a `unit` property, then...
properties:
type:
enum:
- datetime
- timing_distribution
- timespan
required:
- unit
# ... then `time_unit` is required,
# because that's the only way we can force this to fail.
then:
required:
- time_unit
description: |
This metric type uses the (optional) `time_unit` parameter,
not `unit`.
|