1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
7 // The definitions in this file are not sorted.
8 // Please add new ones to the bottom.
11 * Base interface for all metric types to make typing more expressive.
13 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
14 interface GleanMetric {};
16 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
17 interface GleanBoolean : GleanMetric {
19 * Set to the specified boolean value.
21 * @param value the value to set.
23 undefined set(boolean value);
28 * Gets the currently stored value as a boolean.
30 * This function will attempt to await the last parent-process task (if any)
31 * writing to the the metric's storage engine before returning a value.
32 * This function will not wait for data from child processes.
34 * This doesn't clear the stored value.
35 * Parent process only. Panics in child processes.
37 * @param aPingName The (optional) name of the ping to retrieve the metric
38 * for. Defaults to the first value in `send_in_pings`.
40 * @return value of the stored metric, or null if there is no value.
43 boolean? testGetValue(optional UTF8String aPingName = "");
46 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
47 interface GleanDatetime : GleanMetric {
49 * Set the datetime to the provided value, or the local now.
50 * The internal value will store the local timezone.
52 * Note: The metric's time_unit affects the resolution of the value, not the
53 * unit of this function's parameter (which is always PRTime/nanos).
55 * @param aValue The (optional) time value as PRTime (nanoseconds since epoch).
56 * Defaults to local now.
58 undefined set(optional long long aValue);
63 * Gets the currently stored value as a Date.
65 * This function will attempt to await the last parent-process task (if any)
66 * writing to the the metric's storage engine before returning a value.
67 * This function will not wait for data from child processes.
69 * This doesn't clear the stored value.
70 * Parent process only. Panics in child processes.
72 * @param aPingName The (optional) name of the ping to retrieve the metric
73 * for. Defaults to the first value in `send_in_pings`.
75 * @return value of the stored metric as a JS Date with timezone,
76 * or null if there is no value.
79 any testGetValue(optional UTF8String aPingName = "");
82 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
83 interface GleanCounter : GleanMetric {
85 * Increases the counter by `amount`.
87 * @param aAmount The (optional) amount to increase by. Should be positive. Defaults to 1.
89 undefined add(optional long aAmount = 1);
94 * Gets the currently stored value as an integer.
96 * This function will attempt to await the last parent-process task (if any)
97 * writing to the the metric's storage engine before returning a value.
98 * This function will not wait for data from child processes.
100 * This doesn't clear the stored value.
101 * Parent process only. Panics in child processes.
103 * @param aPingName The (optional) name of the ping to retrieve the metric
104 * for. Defaults to the first value in `send_in_pings`.
106 * @return value of the stored metric, or null if there is no value.
109 long? testGetValue(optional UTF8String aPingName = "");
112 dictionary GleanDistributionData {
113 required unsigned long long sum;
114 required unsigned long long count;
115 required record<UTF8String, unsigned long long> values;
118 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
119 interface GleanTimingDistribution : GleanMetric {
121 * Starts tracking time for the provided metric.
123 * @returns A unique timer id for the new timer
125 unsigned long long start();
128 * Stops tracking time for the provided metric and timer id.
130 * Adds a count to the corresponding bucket in the timing distribution.
131 * This will record an error if no `start` was called for this TimerId or
132 * if this TimerId was used to call `cancel`.
134 * @param aId The TimerId associated with this timing. This allows for
135 * concurrent timing of events associated with different ids.
137 undefined stopAndAccumulate(unsigned long long aId);
140 * Aborts a previous `start` call. No error is recorded if no `start` was
141 * called. (But then where did you get that id from?)
143 * @param aId The TimerID whose `start` you wish to abort.
145 undefined cancel(unsigned long long aId);
150 * Gets the currently stored value.
152 * This function will attempt to await the last parent-process task (if any)
153 * writing to the the metric's storage engine before returning a value.
154 * This function will not wait for data from child processes.
156 * This doesn't clear the stored value.
157 * Parent process only. Panics in child processes.
159 * @param aPingName The (optional) name of the ping to retrieve the metric
160 * for. Defaults to the first value in `send_in_pings`.
162 * @return value of the stored metric, or null if there is no value.
165 GleanDistributionData? testGetValue(optional UTF8String aPingName = "");
170 * Accumulates a raw numeric sample of milliseconds.
172 * @param aSample The sample, in milliseconds, to add.
175 undefined testAccumulateRawMillis(unsigned long long aSample);
178 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
179 interface GleanMemoryDistribution : GleanMetric {
181 * Accumulates the provided signed sample in the metric.
183 * @param aSample The sample to be recorded by the metric. The sample is
184 * assumed to be in the confgured memory unit of the metric.
186 * Notes: Values bigger than 1 Terabyte (2^40 bytes) are truncated and an
187 * InvalidValue error is recorded.
189 undefined accumulate(unsigned long long aSample);
194 * Gets the currently stored value as a DistributionData.
196 * This function will attempt to await the last parent-process task (if any)
197 * writing to the the metric's storage engine before returning a value.
198 * This function will not wait for data from child processes.
200 * This doesn't clear the stored value.
201 * Parent process only. Panics in child processes.
203 * @param aPingName The (optional) name of the ping to retrieve the metric
204 * for. Defaults to the first value in `send_in_pings`.
206 * @return value of the stored metric, or null if there is no value.
209 GleanDistributionData? testGetValue(optional UTF8String aPingName = "");
212 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
213 interface GleanCustomDistribution : GleanMetric {
215 * Accumulates the provided signed samples in the metric.
217 * @param aSamples - The vector holding the samples to be recorded by the metric.
219 * Notes: Discards any negative value in `samples`
220 * and report an `ErrorType::InvalidValue` for each of them.
222 undefined accumulateSamples(sequence<long long> aSamples);
225 * Accumulates the provided single signed sample in the metric.
227 * @param aSample - The sample to be recorded by the metric.
229 * Notes: Discards any negative value of `sample` and reports an
230 * `ErrorType::InvalidValue`.
232 undefined accumulateSingleSample(long long aSample);
237 * Gets the currently stored value as a DistributionData.
239 * This function will attempt to await the last parent-process task (if any)
240 * writing to the the metric's storage engine before returning a value.
241 * This function will not wait for data from child processes.
243 * This doesn't clear the stored value.
244 * Parent process only. Panics in child processes.
246 * @param aPingName The (optional) name of the ping to retrieve the metric
247 * for. Defaults to the first value in `send_in_pings`.
249 * @return value of the stored metric, or null if there is no value.
252 GleanDistributionData? testGetValue(optional UTF8String aPingName = "");
255 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
256 interface GleanString : GleanMetric {
258 * Set the string to the provided value.
260 * @param aValue The string to set the metric to.
262 undefined set(UTF8String? aValue);
267 * Gets the currently stored value as a string.
269 * This function will attempt to await the last parent-process task (if any)
270 * writing to the the metric's storage engine before returning a value.
271 * This function will not wait for data from child processes.
273 * This doesn't clear the stored value.
274 * Parent process only. Panics in child processes.
276 * @param aPingName The (optional) name of the ping to retrieve the metric
277 * for. Defaults to the first value in `send_in_pings`.
279 * @return value of the stored metric, or null if there is no value.
282 UTF8String? testGetValue(optional UTF8String aPingName = "");
285 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
286 interface GleanStringList : GleanMetric {
288 * Adds a new string to the list.
290 * Truncates the value and logs an error if it is longer than 100 bytes.
292 * @param value The string to add.
294 undefined add(UTF8String value);
297 * Sets the string_list to the provided list of strings.
299 * Truncates the list and logs an error if longer than 100 items.
300 * Truncates any item longer than 100 bytes and logs an error.
302 * @param aValue The list of strings to set the metric to.
304 undefined set(sequence<UTF8String> aValue);
309 * Gets the currently stored value.
311 * This function will attempt to await the last parent-process task (if any)
312 * writing to the the metric's storage engine before returning a value.
313 * This function will not wait for data from child processes.
315 * This doesn't clear the stored value.
316 * Parent process only. Panics in child processes.
318 * @param aPingName The (optional) name of the ping to retrieve the metric
319 * for. Defaults to the first value in `send_in_pings`.
321 * @return value of the stored metric, or null if there is no value.
324 sequence<UTF8String>? testGetValue(optional UTF8String aPingName = "");
327 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
328 interface GleanTimespan : GleanMetric {
330 * Start tracking time for the provided metric.
332 * This records an error if it’s already tracking time (i.e. start was already
333 * called with no corresponding [stop]): in that case the original
334 * start time will be preserved.
339 * Stop tracking time for the provided metric.
341 * Sets the metric to the elapsed time, but does not overwrite an already
343 * This will record an error if no [start] was called or there is an already
349 * Aborts a previous start.
351 * Does not record an error if there was no previous call to start.
356 * Explicitly sets the timespan value.
358 * This API should only be used if you cannot make use of
359 * `start`/`stop`/`cancel`.
361 * @param aDuration The duration of this timespan, in units matching the
362 * `time_unit` of this metric's definition.
364 undefined setRaw(unsigned long aDuration);
369 * Gets the currently stored value.
371 * This function will attempt to await the last parent-process task (if any)
372 * writing to the the metric's storage engine before returning a value.
373 * This function will not wait for data from child processes.
375 * This doesn't clear the stored value.
376 * Parent process only. Panics in child processes.
378 * @param aPingName The (optional) name of the ping to retrieve the metric
379 * for. Defaults to the first value in `send_in_pings`.
381 * @return value of the stored metric, or null if there is no value.
384 unsigned long long? testGetValue(optional UTF8String aPingName = "");
387 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
388 interface GleanUuid : GleanMetric {
390 * Set to the specified value.
392 * @param aValue The UUID to set the metric to.
394 undefined set(UTF8String aValue);
397 * Generate a new random UUID and set the metric to it.
399 undefined generateAndSet();
404 * Gets the currently stored value.
406 * This function will attempt to await the last parent-process task (if any)
407 * writing to the the metric's storage engine before returning a value.
408 * This function will not wait for data from child processes.
410 * This doesn't clear the stored value.
411 * Parent process only. Panics in child processes.
413 * @param aPingName The (optional) name of the ping to retrieve the metric
414 * for. Defaults to the first value in `send_in_pings`.
416 * @return value of the stored metric, or null if there is no value.
419 UTF8String? testGetValue(optional UTF8String aPingName = "");
422 dictionary GleanEventRecord {
423 required unsigned long long timestamp;
424 required UTF8String category;
425 required UTF8String name;
426 record<UTF8String, UTF8String> extra;
429 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
430 interface GleanEvent : GleanMetric {
435 * @param aExtra An (optional) map of extra values.
437 undefined _record(optional record<UTF8String, UTF8String?> aExtra);
442 * Gets the currently stored value.
444 * This function will attempt to await the last parent-process task (if any)
445 * writing to the the metric's storage engine before returning a value.
446 * This function will not wait for data from child processes.
448 * This doesn't clear the stored value.
449 * Parent process only. Panics in child processes.
451 * @param aPingName The (optional) name of the ping to retrieve the metric
452 * for. Defaults to the first value in `send_in_pings`.
454 * @return value of the stored metric, or null if there is no value.
456 * The difference between event timestamps is in milliseconds
457 * See https://mozilla.github.io/glean/book/user/metrics/event.html for further details.
458 * Due to limitations of numbers in JavaScript, the timestamp will only be accurate up until 2^53.
459 * (This is probably not an issue with the current clock implementation. Probably.)
462 sequence<GleanEventRecord>? testGetValue(optional UTF8String aPingName = "");
465 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
466 interface GleanQuantity : GleanMetric {
468 * Set to the specified value.
470 * @param aValue The value to set the metric to.
472 undefined set(long long aValue);
477 * Gets the currently stored value.
479 * This function will attempt to await the last parent-process task (if any)
480 * writing to the the metric's storage engine before returning a value.
481 * This function will not wait for data from child processes.
483 * This doesn't clear the stored value.
484 * Parent process only. Panics in child processes.
486 * @param aPingName The (optional) name of the ping to retrieve the metric
487 * for. Defaults to the first value in `send_in_pings`.
489 * @return value of the stored metric, or null if there is no value.
492 long long? testGetValue(optional UTF8String aPingName = "");
495 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
496 interface GleanDenominator : GleanMetric {
498 * Increases the counter by `aAmount`.
500 * @param aAmount The (optional) amount to increase by. Should be positive. Defaults to 1.
502 undefined add(optional long aAmount = 1);
507 * Gets the currently stored value as an integer.
509 * This function will attempt to await the last parent-process task (if any)
510 * writing to the the metric's storage engine before returning a value.
511 * This function will not wait for data from child processes.
513 * This doesn't clear the stored value.
514 * Parent process only. Panics in child processes.
516 * @param aPingName The (optional) name of the ping to retrieve the metric
517 * for. Defaults to the first value in `send_in_pings`.
519 * @return value of the stored metric, or null if there is no value.
522 long? testGetValue(optional UTF8String aPingName = "");
525 dictionary GleanRateData {
526 required long numerator;
527 required long denominator;
530 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
531 interface GleanNumerator : GleanMetric {
533 * Increases the numerator by `aAmount`.
535 * @param aAmount The (optional) amount to increase by. Should be positive. Defaults to 1.
537 undefined addToNumerator(optional long aAmount = 1);
542 * Gets the currently stored value in the form {numerator: n, denominator: d}
544 * This function will attempt to await the last parent-process task (if any)
545 * writing to the the metric's storage engine before returning a value.
546 * This function will not wait for data from child processes.
548 * This doesn't clear the stored value.
549 * Parent process only. Panics in child processes.
551 * @param aPingName The (optional) name of the ping to retrieve the metric
552 * for. Defaults to the first value in `send_in_pings`.
554 * @return value of the stored metric, or null if there is no value.
557 GleanRateData? testGetValue(optional UTF8String aPingName = "");
560 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
561 interface GleanRate : GleanMetric {
563 * Increases the numerator by `amount`.
565 * @param aAmount The (optional) amount to increase by. Should be positive. Defaults to 1.
567 undefined addToNumerator(optional long aAmount = 1);
570 * Increases the denominator by `amount`.
572 * @param aAmount The (optional) amount to increase by. Should be positive. Defaults to 1.
574 undefined addToDenominator(optional long aAmount = 1);
579 * Gets the currently stored value in the form {numerator: n, denominator: d}
581 * This function will attempt to await the last parent-process task (if any)
582 * writing to the the metric's storage engine before returning a value.
583 * This function will not wait for data from child processes.
585 * This doesn't clear the stored value.
586 * Parent process only. Panics in child processes.
588 * @param aPingName The (optional) name of the ping to retrieve the metric
589 * for. Defaults to the first value in `send_in_pings`.
591 * @return value of the stored metric, or null if there is no value.
594 GleanRateData? testGetValue(optional UTF8String aPingName = "");
597 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
598 interface GleanUrl : GleanMetric {
600 * Set to the specified value.
602 * @param aValue The stringified URL to set the metric to.
604 undefined set(UTF8String aValue);
609 * Gets the currently stored value.
611 * This function will attempt to await the last parent-process task (if any)
612 * writing to the the metric's storage engine before returning a value.
613 * This function will not wait for data from child processes.
615 * This doesn't clear the stored value.
616 * Parent process only. Panics in child processes.
618 * @param aPingName The (optional) name of the ping to retrieve the metric
619 * for. Defaults to the first value in `send_in_pings`.
621 * @return value of the stored metric, or null if there is no value.
624 UTF8String? testGetValue(optional UTF8String aPingName = "");
627 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
628 interface GleanText : GleanMetric {
630 * Set to the provided value.
632 * @param aValue The text to set the metric to.
634 undefined set(UTF8String aValue);
639 * Gets the currently stored value as a string.
641 * This function will attempt to await the last parent-process task (if any)
642 * writing to the the metric's storage engine before returning a value.
643 * This function will not wait for data from child processes.
645 * This doesn't clear the stored value.
646 * Parent process only. Panics in child processes.
648 * @param aPingName The (optional) name of the ping to retrieve the metric
649 * for. Defaults to the first value in `send_in_pings`.
651 * @return value of the stored metric, or null if there is no value.
654 UTF8String? testGetValue(optional UTF8String aPingName = "");
657 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
658 interface GleanObject : GleanMetric {
660 * Set to the specified object.
662 * The structure of the metric is validated against the predefined structure.
664 * @param object The object to set the metric to.
666 undefined set(object value);
671 * Gets the currently stored value as an object.
673 * This function will attempt to await the last parent-process task (if any)
674 * writing to the the metric's storage engine before returning a value.
675 * This function will not wait for data from child processes.
677 * This doesn't clear the stored value.
678 * Parent process only. Panics in child processes.
680 * @param aPingName The (optional) name of the ping to retrieve the metric
681 * for. Defaults to the first value in `send_in_pings`.
683 * @return value of the stored metric, or undefined if there is no value.
686 object? testGetValue(optional UTF8String aPingName = "");