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
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*/
// The definitions in this file are not sorted.
// Please add new ones to the bottom.
/**
* Base interface for all metric types to make typing more expressive.
*/
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanMetric {};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanBoolean : GleanMetric {
/**
* Set to the specified boolean value.
*
* @param value the value to set.
*/
undefined set(boolean value);
/**
* **Test-only API**
*
* Gets the currently stored value as a boolean.
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or null if there is no value.
*/
[Throws, ChromeOnly]
boolean? testGetValue(optional UTF8String aPingName = "");
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanDatetime : GleanMetric {
/**
* Set the datetime to the provided value, or the local now.
* The internal value will store the local timezone.
*
* Note: The metric's time_unit affects the resolution of the value, not the
* unit of this function's parameter (which is always PRTime/nanos).
*
* @param aValue The (optional) time value as PRTime (nanoseconds since epoch).
* Defaults to local now.
*/
undefined set(optional long long aValue);
/**
* **Test-only API**
*
* Gets the currently stored value as a Date.
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric as a JS Date with timezone,
* or null if there is no value.
*/
[Throws, ChromeOnly]
any testGetValue(optional UTF8String aPingName = "");
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanCounter : GleanMetric {
/*
* Increases the counter by `amount`.
*
* @param aAmount The (optional) amount to increase by. Should be positive. Defaults to 1.
*/
undefined add(optional long aAmount = 1);
/**
* **Test-only API**
*
* Gets the currently stored value as an integer.
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or null if there is no value.
*/
[Throws, ChromeOnly]
long? testGetValue(optional UTF8String aPingName = "");
};
dictionary GleanDistributionData {
required unsigned long long sum;
required unsigned long long count;
required record<UTF8String, unsigned long long> values;
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanTimingDistribution : GleanMetric {
/**
* Starts tracking time for the provided metric.
*
* @returns A unique timer id for the new timer
*/
unsigned long long start();
/**
* Stops tracking time for the provided metric and timer id.
*
* Adds a count to the corresponding bucket in the timing distribution.
* This will record an error if no `start` was called for this TimerId or
* if this TimerId was used to call `cancel`.
*
* @param aId The TimerId associated with this timing. This allows for
* concurrent timing of events associated with different ids.
*/
undefined stopAndAccumulate(unsigned long long aId);
/**
* Aborts a previous `start` call. No error is recorded if no `start` was
* called. (But then where did you get that id from?)
*
* @param aId The TimerID whose `start` you wish to abort.
*/
undefined cancel(unsigned long long aId);
/**
* **Test-only API**
*
* Gets the currently stored value.
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or null if there is no value.
*/
[Throws, ChromeOnly]
GleanDistributionData? testGetValue(optional UTF8String aPingName = "");
/**
* **Test-only API**
*
* Accumulates a raw numeric sample of milliseconds.
*
* @param aSample The sample, in milliseconds, to add.
*/
[ChromeOnly]
undefined testAccumulateRawMillis(unsigned long long aSample);
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanMemoryDistribution : GleanMetric {
/**
* Accumulates the provided signed sample in the metric.
*
* @param aSample The sample to be recorded by the metric. The sample is
* assumed to be in the confgured memory unit of the metric.
*
* Notes: Values bigger than 1 Terabyte (2^40 bytes) are truncated and an
* InvalidValue error is recorded.
*/
undefined accumulate(unsigned long long aSample);
/**
* **Test-only API**
*
* Gets the currently stored value as a DistributionData.
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or null if there is no value.
*/
[Throws, ChromeOnly]
GleanDistributionData? testGetValue(optional UTF8String aPingName = "");
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanCustomDistribution : GleanMetric {
/**
* Accumulates the provided signed samples in the metric.
*
* @param aSamples - The vector holding the samples to be recorded by the metric.
*
* Notes: Discards any negative value in `samples`
* and report an `ErrorType::InvalidValue` for each of them.
*/
undefined accumulateSamples(sequence<long long> aSamples);
/**
* **Test-only API**
*
* Gets the currently stored value as a DistributionData.
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or null if there is no value.
*/
[Throws, ChromeOnly]
GleanDistributionData? testGetValue(optional UTF8String aPingName = "");
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanString : GleanMetric {
/**
* Set the string to the provided value.
*
* @param aValue The string to set the metric to.
*/
undefined set(UTF8String? aValue);
/**
* **Test-only API**
*
* Gets the currently stored value as a string.
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or null if there is no value.
*/
[Throws, ChromeOnly]
UTF8String? testGetValue(optional UTF8String aPingName = "");
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanStringList : GleanMetric {
/**
* Adds a new string to the list.
*
* Truncates the value and logs an error if it is longer than 100 bytes.
*
* @param value The string to add.
*/
undefined add(UTF8String value);
/**
* Sets the string_list to the provided list of strings.
*
* Truncates the list and logs an error if longer than 100 items.
* Truncates any item longer than 100 bytes and logs an error.
*
* @param aValue The list of strings to set the metric to.
*/
undefined set(sequence<UTF8String> aValue);
/**
* **Test-only API**
*
* Gets the currently stored value.
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or null if there is no value.
*/
[Throws, ChromeOnly]
sequence<UTF8String>? testGetValue(optional UTF8String aPingName = "");
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanTimespan : GleanMetric {
/**
* Start tracking time for the provided metric.
*
* This records an error if it’s already tracking time (i.e. start was already
* called with no corresponding [stop]): in that case the original
* start time will be preserved.
*/
undefined start();
/**
* Stop tracking time for the provided metric.
*
* Sets the metric to the elapsed time, but does not overwrite an already
* existing value.
* This will record an error if no [start] was called or there is an already
* existing value.
*/
undefined stop();
/**
* Aborts a previous start.
*
* Does not record an error if there was no previous call to start.
*/
undefined cancel();
/**
* Explicitly sets the timespan value.
*
* This API should only be used if you cannot make use of
* `start`/`stop`/`cancel`.
*
* @param aDuration The duration of this timespan, in units matching the
* `time_unit` of this metric's definition.
*/
undefined setRaw(unsigned long aDuration);
/**
* **Test-only API**
*
* Gets the currently stored value.
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or null if there is no value.
*/
[Throws, ChromeOnly]
unsigned long long? testGetValue(optional UTF8String aPingName = "");
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanUuid : GleanMetric {
/**
* Set to the specified value.
*
* @param aValue The UUID to set the metric to.
*/
undefined set(UTF8String aValue);
/**
* Generate a new random UUID and set the metric to it.
*/
undefined generateAndSet();
/**
* **Test-only API**
*
* Gets the currently stored value.
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or null if there is no value.
*/
[Throws, ChromeOnly]
UTF8String? testGetValue(optional UTF8String aPingName = "");
};
dictionary GleanEventRecord {
required unsigned long long timestamp;
required UTF8String category;
required UTF8String name;
record<UTF8String, UTF8String> extra;
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanEvent : GleanMetric {
/*
* Record an event.
*
* @param aExtra An (optional) map of extra values.
*/
undefined _record(optional record<UTF8String, UTF8String?> aExtra);
/**
* **Test-only API**
*
* Gets the currently stored value.
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or null if there is no value.
*
* The difference between event timestamps is in milliseconds
* See https://mozilla.github.io/glean/book/user/metrics/event.html for further details.
* Due to limitations of numbers in JavaScript, the timestamp will only be accurate up until 2^53.
* (This is probably not an issue with the current clock implementation. Probably.)
*/
[Throws, ChromeOnly]
sequence<GleanEventRecord>? testGetValue(optional UTF8String aPingName = "");
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanQuantity : GleanMetric {
/**
* Set to the specified value.
*
* @param aValue The value to set the metric to.
*/
undefined set(long long aValue);
/**
* **Test-only API**
*
* Gets the currently stored value.
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or null if there is no value.
*/
[Throws, ChromeOnly]
long long? testGetValue(optional UTF8String aPingName = "");
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanDenominator : GleanMetric {
/*
* Increases the counter by `aAmount`.
*
* @param aAmount The (optional) amount to increase by. Should be positive. Defaults to 1.
*/
undefined add(optional long aAmount = 1);
/**
* **Test-only API**
*
* Gets the currently stored value as an integer.
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or null if there is no value.
*/
[Throws, ChromeOnly]
long? testGetValue(optional UTF8String aPingName = "");
};
dictionary GleanRateData {
required long numerator;
required long denominator;
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanNumerator : GleanMetric {
/*
* Increases the numerator by `aAmount`.
*
* @param aAmount The (optional) amount to increase by. Should be positive. Defaults to 1.
*/
undefined addToNumerator(optional long aAmount = 1);
/**
* **Test-only API**
*
* Gets the currently stored value in the form {numerator: n, denominator: d}
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or null if there is no value.
*/
[Throws, ChromeOnly]
GleanRateData? testGetValue(optional UTF8String aPingName = "");
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanRate : GleanMetric {
/*
* Increases the numerator by `amount`.
*
* @param aAmount The (optional) amount to increase by. Should be positive. Defaults to 1.
*/
undefined addToNumerator(optional long aAmount = 1);
/*
* Increases the denominator by `amount`.
*
* @param aAmount The (optional) amount to increase by. Should be positive. Defaults to 1.
*/
undefined addToDenominator(optional long aAmount = 1);
/**
* **Test-only API**
*
* Gets the currently stored value in the form {numerator: n, denominator: d}
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or null if there is no value.
*/
[Throws, ChromeOnly]
GleanRateData? testGetValue(optional UTF8String aPingName = "");
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanUrl : GleanMetric {
/**
* Set to the specified value.
*
* @param aValue The stringified URL to set the metric to.
*/
undefined set(UTF8String aValue);
/**
* **Test-only API**
*
* Gets the currently stored value.
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or null if there is no value.
*/
[Throws, ChromeOnly]
UTF8String? testGetValue(optional UTF8String aPingName = "");
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanText : GleanMetric {
/**
* Set to the provided value.
*
* @param aValue The text to set the metric to.
*/
undefined set(UTF8String aValue);
/**
* **Test-only API**
*
* Gets the currently stored value as a string.
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or null if there is no value.
*/
[Throws, ChromeOnly]
UTF8String? testGetValue(optional UTF8String aPingName = "");
};
[Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
interface GleanObject : GleanMetric {
/**
* Set to the specified object.
*
* The structure of the metric is validated against the predefined structure.
*
* @param object The object to set the metric to.
*/
undefined set(object value);
/**
* **Test-only API**
*
* Gets the currently stored value as an object.
*
* This function will attempt to await the last parent-process task (if any)
* writing to the the metric's storage engine before returning a value.
* This function will not wait for data from child processes.
*
* This doesn't clear the stored value.
* Parent process only. Panics in child processes.
*
* @param aPingName The (optional) name of the ping to retrieve the metric
* for. Defaults to the first value in `send_in_pings`.
*
* @return value of the stored metric, or undefined if there is no value.
*/
[Throws, ChromeOnly]
object? testGetValue(optional UTF8String aPingName = "");
};
|