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 record<UTF8String, unsigned long long> values;
117 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
118 interface GleanTimingDistribution : GleanMetric {
120 * Starts tracking time for the provided metric.
122 * @returns A unique timer id for the new timer
124 unsigned long long start();
127 * Stops tracking time for the provided metric and timer id.
129 * Adds a count to the corresponding bucket in the timing distribution.
130 * This will record an error if no `start` was called for this TimerId or
131 * if this TimerId was used to call `cancel`.
133 * @param aId The TimerId associated with this timing. This allows for
134 * concurrent timing of events associated with different ids.
136 undefined stopAndAccumulate(unsigned long long aId);
139 * Aborts a previous `start` call. No error is recorded if no `start` was
140 * called. (But then where did you get that id from?)
142 * @param aId The TimerID whose `start` you wish to abort.
144 undefined cancel(unsigned long long aId);
149 * Gets the currently stored value.
151 * This function will attempt to await the last parent-process task (if any)
152 * writing to the the metric's storage engine before returning a value.
153 * This function will not wait for data from child processes.
155 * This doesn't clear the stored value.
156 * Parent process only. Panics in child processes.
158 * @param aPingName The (optional) name of the ping to retrieve the metric
159 * for. Defaults to the first value in `send_in_pings`.
161 * @return value of the stored metric, or null if there is no value.
164 GleanDistributionData? testGetValue(optional UTF8String aPingName = "");
169 * Accumulates a raw numeric sample of milliseconds.
171 * @param aSample The sample, in milliseconds, to add.
174 undefined testAccumulateRawMillis(unsigned long long aSample);
177 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
178 interface GleanMemoryDistribution : GleanMetric {
180 * Accumulates the provided signed sample in the metric.
182 * @param aSample The sample to be recorded by the metric. The sample is
183 * assumed to be in the confgured memory unit of the metric.
185 * Notes: Values bigger than 1 Terabyte (2^40 bytes) are truncated and an
186 * InvalidValue error is recorded.
188 undefined accumulate(unsigned long long aSample);
193 * Gets the currently stored value as a DistributionData.
195 * This function will attempt to await the last parent-process task (if any)
196 * writing to the the metric's storage engine before returning a value.
197 * This function will not wait for data from child processes.
199 * This doesn't clear the stored value.
200 * Parent process only. Panics in child processes.
202 * @param aPingName The (optional) name of the ping to retrieve the metric
203 * for. Defaults to the first value in `send_in_pings`.
205 * @return value of the stored metric, or null if there is no value.
208 GleanDistributionData? testGetValue(optional UTF8String aPingName = "");
211 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
212 interface GleanCustomDistribution : GleanMetric {
214 * Accumulates the provided signed samples in the metric.
216 * @param aSamples - The vector holding the samples to be recorded by the metric.
218 * Notes: Discards any negative value in `samples`
219 * and report an `ErrorType::InvalidValue` for each of them.
221 undefined accumulateSamples(sequence<long long> aSamples);
226 * Gets the currently stored value as a DistributionData.
228 * This function will attempt to await the last parent-process task (if any)
229 * writing to the the metric's storage engine before returning a value.
230 * This function will not wait for data from child processes.
232 * This doesn't clear the stored value.
233 * Parent process only. Panics in child processes.
235 * @param aPingName The (optional) name of the ping to retrieve the metric
236 * for. Defaults to the first value in `send_in_pings`.
238 * @return value of the stored metric, or null if there is no value.
241 GleanDistributionData? testGetValue(optional UTF8String aPingName = "");
244 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
245 interface GleanString : GleanMetric {
247 * Set the string to the provided value.
249 * @param aValue The string to set the metric to.
251 undefined set(UTF8String? aValue);
256 * Gets the currently stored value as a string.
258 * This function will attempt to await the last parent-process task (if any)
259 * writing to the the metric's storage engine before returning a value.
260 * This function will not wait for data from child processes.
262 * This doesn't clear the stored value.
263 * Parent process only. Panics in child processes.
265 * @param aPingName The (optional) name of the ping to retrieve the metric
266 * for. Defaults to the first value in `send_in_pings`.
268 * @return value of the stored metric, or null if there is no value.
271 UTF8String? testGetValue(optional UTF8String aPingName = "");
274 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
275 interface GleanStringList : GleanMetric {
277 * Adds a new string to the list.
279 * Truncates the value and logs an error if it is longer than 100 bytes.
281 * @param value The string to add.
283 undefined add(UTF8String value);
286 * Sets the string_list to the provided list of strings.
288 * Truncates the list and logs an error if longer than 100 items.
289 * Truncates any item longer than 100 bytes and logs an error.
291 * @param aValue The list of strings to set the metric to.
293 undefined set(sequence<UTF8String> aValue);
298 * Gets the currently stored value.
300 * This function will attempt to await the last parent-process task (if any)
301 * writing to the the metric's storage engine before returning a value.
302 * This function will not wait for data from child processes.
304 * This doesn't clear the stored value.
305 * Parent process only. Panics in child processes.
307 * @param aPingName The (optional) name of the ping to retrieve the metric
308 * for. Defaults to the first value in `send_in_pings`.
310 * @return value of the stored metric, or null if there is no value.
313 sequence<UTF8String>? testGetValue(optional UTF8String aPingName = "");
316 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
317 interface GleanTimespan : GleanMetric {
319 * Start tracking time for the provided metric.
321 * This records an error if it’s already tracking time (i.e. start was already
322 * called with no corresponding [stop]): in that case the original
323 * start time will be preserved.
328 * Stop tracking time for the provided metric.
330 * Sets the metric to the elapsed time, but does not overwrite an already
332 * This will record an error if no [start] was called or there is an already
338 * Aborts a previous start.
340 * Does not record an error if there was no previous call to start.
345 * Explicitly sets the timespan value.
347 * This API should only be used if you cannot make use of
348 * `start`/`stop`/`cancel`.
350 * @param aDuration The duration of this timespan, in units matching the
351 * `time_unit` of this metric's definition.
353 undefined setRaw(unsigned long aDuration);
358 * Gets the currently stored value.
360 * This function will attempt to await the last parent-process task (if any)
361 * writing to the the metric's storage engine before returning a value.
362 * This function will not wait for data from child processes.
364 * This doesn't clear the stored value.
365 * Parent process only. Panics in child processes.
367 * @param aPingName The (optional) name of the ping to retrieve the metric
368 * for. Defaults to the first value in `send_in_pings`.
370 * @return value of the stored metric, or null if there is no value.
373 unsigned long long? testGetValue(optional UTF8String aPingName = "");
376 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
377 interface GleanUuid : GleanMetric {
379 * Set to the specified value.
381 * @param aValue The UUID to set the metric to.
383 undefined set(UTF8String aValue);
386 * Generate a new random UUID and set the metric to it.
388 undefined generateAndSet();
393 * Gets the currently stored value.
395 * This function will attempt to await the last parent-process task (if any)
396 * writing to the the metric's storage engine before returning a value.
397 * This function will not wait for data from child processes.
399 * This doesn't clear the stored value.
400 * Parent process only. Panics in child processes.
402 * @param aPingName The (optional) name of the ping to retrieve the metric
403 * for. Defaults to the first value in `send_in_pings`.
405 * @return value of the stored metric, or null if there is no value.
408 UTF8String? testGetValue(optional UTF8String aPingName = "");
411 dictionary GleanEventRecord {
412 required unsigned long long timestamp;
413 required UTF8String category;
414 required UTF8String name;
415 record<UTF8String, UTF8String> extra;
418 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
419 interface GleanEvent : GleanMetric {
424 * @param aExtra An (optional) map of extra values.
426 undefined _record(optional record<UTF8String, UTF8String?> aExtra);
431 * Gets the currently stored value.
433 * This function will attempt to await the last parent-process task (if any)
434 * writing to the the metric's storage engine before returning a value.
435 * This function will not wait for data from child processes.
437 * This doesn't clear the stored value.
438 * Parent process only. Panics in child processes.
440 * @param aPingName The (optional) name of the ping to retrieve the metric
441 * for. Defaults to the first value in `send_in_pings`.
443 * @return value of the stored metric, or null if there is no value.
445 * The difference between event timestamps is in milliseconds
446 * See https://mozilla.github.io/glean/book/user/metrics/event.html for further details.
447 * Due to limitations of numbers in JavaScript, the timestamp will only be accurate up until 2^53.
448 * (This is probably not an issue with the current clock implementation. Probably.)
451 sequence<GleanEventRecord>? testGetValue(optional UTF8String aPingName = "");
454 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
455 interface GleanQuantity : GleanMetric {
457 * Set to the specified value.
459 * @param aValue The value to set the metric to.
461 undefined set(long long aValue);
466 * Gets the currently stored value.
468 * This function will attempt to await the last parent-process task (if any)
469 * writing to the the metric's storage engine before returning a value.
470 * This function will not wait for data from child processes.
472 * This doesn't clear the stored value.
473 * Parent process only. Panics in child processes.
475 * @param aPingName The (optional) name of the ping to retrieve the metric
476 * for. Defaults to the first value in `send_in_pings`.
478 * @return value of the stored metric, or null if there is no value.
481 long long? testGetValue(optional UTF8String aPingName = "");
484 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
485 interface GleanDenominator : GleanMetric {
487 * Increases the counter by `aAmount`.
489 * @param aAmount The (optional) amount to increase by. Should be positive. Defaults to 1.
491 undefined add(optional long aAmount = 1);
496 * Gets the currently stored value as an integer.
498 * This function will attempt to await the last parent-process task (if any)
499 * writing to the the metric's storage engine before returning a value.
500 * This function will not wait for data from child processes.
502 * This doesn't clear the stored value.
503 * Parent process only. Panics in child processes.
505 * @param aPingName The (optional) name of the ping to retrieve the metric
506 * for. Defaults to the first value in `send_in_pings`.
508 * @return value of the stored metric, or null if there is no value.
511 long? testGetValue(optional UTF8String aPingName = "");
514 dictionary GleanRateData {
515 required long numerator;
516 required long denominator;
519 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
520 interface GleanNumerator : GleanMetric {
522 * Increases the numerator by `aAmount`.
524 * @param aAmount The (optional) amount to increase by. Should be positive. Defaults to 1.
526 undefined addToNumerator(optional long aAmount = 1);
531 * Gets the currently stored value in the form {numerator: n, denominator: d}
533 * This function will attempt to await the last parent-process task (if any)
534 * writing to the the metric's storage engine before returning a value.
535 * This function will not wait for data from child processes.
537 * This doesn't clear the stored value.
538 * Parent process only. Panics in child processes.
540 * @param aPingName The (optional) name of the ping to retrieve the metric
541 * for. Defaults to the first value in `send_in_pings`.
543 * @return value of the stored metric, or null if there is no value.
546 GleanRateData? testGetValue(optional UTF8String aPingName = "");
549 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
550 interface GleanRate : GleanMetric {
552 * Increases the numerator by `amount`.
554 * @param aAmount The (optional) amount to increase by. Should be positive. Defaults to 1.
556 undefined addToNumerator(optional long aAmount = 1);
559 * Increases the denominator by `amount`.
561 * @param aAmount The (optional) amount to increase by. Should be positive. Defaults to 1.
563 undefined addToDenominator(optional long aAmount = 1);
568 * Gets the currently stored value in the form {numerator: n, denominator: d}
570 * This function will attempt to await the last parent-process task (if any)
571 * writing to the the metric's storage engine before returning a value.
572 * This function will not wait for data from child processes.
574 * This doesn't clear the stored value.
575 * Parent process only. Panics in child processes.
577 * @param aPingName The (optional) name of the ping to retrieve the metric
578 * for. Defaults to the first value in `send_in_pings`.
580 * @return value of the stored metric, or null if there is no value.
583 GleanRateData? testGetValue(optional UTF8String aPingName = "");
586 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
587 interface GleanUrl : GleanMetric {
589 * Set to the specified value.
591 * @param aValue The stringified URL to set the metric to.
593 undefined set(UTF8String aValue);
598 * Gets the currently stored value.
600 * This function will attempt to await the last parent-process task (if any)
601 * writing to the the metric's storage engine before returning a value.
602 * This function will not wait for data from child processes.
604 * This doesn't clear the stored value.
605 * Parent process only. Panics in child processes.
607 * @param aPingName The (optional) name of the ping to retrieve the metric
608 * for. Defaults to the first value in `send_in_pings`.
610 * @return value of the stored metric, or null if there is no value.
613 UTF8String? testGetValue(optional UTF8String aPingName = "");
616 [Func="nsGlobalWindowInner::IsGleanNeeded", Exposed=Window]
617 interface GleanText : GleanMetric {
619 * Set to the provided value.
621 * @param aValue The text to set the metric to.
623 undefined set(UTF8String aValue);
628 * Gets the currently stored value as a string.
630 * This function will attempt to await the last parent-process task (if any)
631 * writing to the the metric's storage engine before returning a value.
632 * This function will not wait for data from child processes.
634 * This doesn't clear the stored value.
635 * Parent process only. Panics in child processes.
637 * @param aPingName The (optional) name of the ping to retrieve the metric
638 * for. Defaults to the first value in `send_in_pings`.
640 * @return value of the stored metric, or null if there is no value.
643 UTF8String? testGetValue(optional UTF8String aPingName = "");