# 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/.

# This file defines the metrics that are recorded by glean telemetry. They are
# automatically converted to Kotlin code at build time using the `glean_parser`
# PyPI package.
---

$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0

crash_metrics:
  crash_count:
    type: labeled_counter
    description: >
      Counts the number of crashes that occur in the application.
      This measures only the counts of each crash in association
      with the labeled type of the crash.
      The labels correspond to the types of crashes handled by lib-crash.

      Deprecated: `native_code_crash`, `fatal_native_code_crash` and
      `nonfatal_native_code_crash` replaced by `main_proc_native_code_crash`,
      `fg_proc_native_code_crash` and `bg_proc_native_code_crash`.
    labels:
      - uncaught_exception
      - caught_exception
      - main_proc_native_code_crash
      - fg_proc_native_code_crash
      - bg_proc_native_code_crash
      - fatal_native_code_crash
      - nonfatal_native_code_crash
    bugs:
      - https://bugzilla.mozilla.org/1553935
      - https://github.com/mozilla-mobile/android-components/issues/5175
      - https://github.com/mozilla-mobile/android-components/issues/11876
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1553935#c3
      - https://github.com/mozilla-mobile/android-components/pull/5700#pullrequestreview-347721248
      - https://github.com/mozilla-mobile/android-components/pull/11908#issuecomment-1075243414
    data_sensitivity:
      - technical
    notification_emails:
      - android-probes@mozilla.com
      - jnicol@mozilla.com
    expires: never

crash:
  process_type:
    type: string
    # yamllint disable
    description: >
      The type of process that experienced a crash. See the full list of
      options
      [here](https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/data/crash-ping.html#process-types).
    # yamllint enable
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1790569
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1790569#c12
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  remote_type:
    type: string
    description: >
      Type of the child process, can be set to "web", "file" or "extension" but could also be unavailable.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1851518
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1851518#c6
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  time:
    type: datetime
    time_unit: minute
    description: >
      The time at which the crash occurred.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1790569
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1790569#c12
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  startup:
    type: boolean
    description: >
      If true, the crash occurred during process startup.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1790569
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1790569#c12
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  cause:
    type: string
    description: >
      The cause of the crash. May be one of `os_fault` or `java_exception`.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1839697
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1839697#c5
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  app_channel:
    type: string
    description: >
      The release channel of the application. This may differ from
      `client_info` because a main process crash may be reported later by a
      different (e.g. updated) client.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  app_display_version:
    type: string
    description: >
      The version of the application. This may differ from `client_info`
      because a main process crash may be reported later by a different
      (e.g. updated) client.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  app_build:
    type: string
    description: >
      The build id of the application. This may differ from `client_info`
      because a main process crash may be reported later by a different
      (e.g. updated) client.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  minidump_sha256_hash:
    type: string
    description: >
      The SHA256 hash of the associated minidump file, if any.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  stack_traces:
    type: object
    description: >
      Stack trace and module information of the crashing process.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash
    # All addresses are hex strings (with prefix "0x") rather than numbers.
    structure:
      type: object
      properties:
        # An error from the stack trace analysis, omitted if no errors occurred.
        error:
          type: string
        # The type of crash (SIGSEGV, assertion, etc)
        crash_type:
          type: string
        crash_address:
          type: string
        # Index of the crash thread
        crash_thread:
          type: number
        # Index of the main executable module.
        main_module:
          type: number
        # Modules ordered by base memory address.
        modules:
          type: array
          items:
            type: object
            properties:
              base_address:
                type: string
              end_address:
                type: string
              # Unique ID of the module
              code_id:
                type: string
              debug_file:
                type: string
              debug_id:
                type: string
              filename:
                type: string
              version:
                type: string
        # Stack traces for each thread.
        threads:
          type: array
          items:
            type: object
            properties:
              # Frames in the thread stack trace
              frames:
                type: array
                items:
                  type: object
                  properties:
                    # Index of the module that contains the frame
                    module_index:
                      type: number
                    # The instruction pointer (address) of the frame
                    ip:
                      type: string
                    # Trust of the frame, one of "context", "prewalked", "cfi",
                    # "frame_pointer", "cfi_scan", "scan", or "none"
                    trust:
                      type: string


  async_shutdown_timeout:
    type: object
    description: >
      Present when a shutdown blocker failed to respond within a reasonable
      amount of time.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash
    structure:
      type: object
      properties:
        phase:
          type: string
        conditions:
          type: string
        broken_add_blockers:
          type: array
          items:
            type: string

  background_task_name:
    type: string
    description: >
      The name of the background task if launched as one.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  event_loop_nesting_level:
    type: quantity
    unit: levels
    description: >
      Indicates the nesting level of the event loop.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  font_name:
    type: string
    description: >
      The font family name that is being loaded when the crash occurred.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  gpu_process_launch:
    type: quantity
    unit: events
    description: >
      The number of times that the GPU process was launched.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  ipc_channel_error:
    type: string
    description: >
      The error reason for an ipc-based content crash.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  is_garbage_collecting:
    type: boolean
    description: >
      Indicates that the crash occurred while the garbage collector was
      running.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  main_thread_runnable_name:
    type: string
    description: >
      Name of the currently executing `nsIRunnable` on the main thread.
      Nightly-only.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  moz_crash_reason:
    type: string
    description: >
      Contains the string passed to `MOZ_CRASH()`.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  profiler_child_shutdown_phase:
    type: string
    description: >
      The shutdown phase of the profiler.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  quota_manager_shutdown_timeout:
    type: object
    description: >
      Contains a list of shutdown steps and status of the quota manager
      clients.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash
    structure:
      type: array
      items:
        type: string

  shutdown_progress:
    type: string
    description: >
      The shutdown phase in which the crash occurred.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  java_exception:
    type: object
    description: >
      Error and stack trace information for a java exception.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1904847
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1904847
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash
    structure:
      type: object
      properties:
        # The message of the throwable and any cause throwables
        messages:
          type: array
          items:
            type: string
        # The stack trace, from nearest to farthest execution point.
        stack:
          type: array
          items:
            type: object
            properties:
              # The source file containing this stack trace element.
              file:
                type: string
              # The line number of the source file containing this stack trace element.
              line:
                type: number
              # The name of the class containing this stack trace element.
              class_name:
                type: string
              # The name of the method containing this stack trace element.
              method_name:
                type: string
              # Whether the method is native.
              is_native:
                type: boolean

  breadcrumbs:
    type: object
    description: >
      Crash breadcrumb information.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1904847
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1904847
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash
    structure:
      type: array
      items:
        type: object
        properties:
          timestamp:
            type: string
          message:
            type: string
          category:
            type: string
          level:
            type: string
          type:
            type: string
          data:
            type: array
            items:
              type: object
              properties:
                key:
                  type: string
                value:
                  type: string


memory:
  available_commit:
    type: quantity
    unit: bytes
    description: >
      Available commit space.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  available_physical:
    type: quantity
    unit: bytes
    description: >
      Available physical memory.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  available_swap:
    type: quantity
    unit: bytes
    description: >
      Available swap memory.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  available_virtual:
    type: quantity
    unit: bytes
    description: >
      Available virtual memory.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  low_physical:
    type: quantity
    unit: events
    description: >
      The number of times the available memory tracker has detected that free
      physical memory is running low.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  oom_allocation_size:
    type: quantity
    unit: bytes
    description: >
      The size of the allocation that caused on OOM crash.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  purgeable_physical:
    type: quantity
    unit: bytes
    description: >
      The amount of memory that can be deallocated by the OS in case of memory
      pressure.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  system_use_percentage:
    type: quantity
    unit: percent
    description: >
      The percentage of memory in use.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  texture:
    type: quantity
    unit: bytes
    description: >
      The amount of memory used in textures.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  total_page_file:
    type: quantity
    unit: bytes
    description: >
      The total page file size.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  total_physical:
    type: quantity
    unit: bytes
    description: >
      The total physical memory.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  total_virtual:
    type: quantity
    unit: bytes
    description: >
      The total virtual memory.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash


environment:
  headless_mode:
    type: boolean
    description: >
      Whether the app was invoked in headless mode via `--headless` or
      `--backgroundtask`.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash

  uptime:
    type: timespan
    time_unit: millisecond
    description: >
      The start time of the application.
    notification_emails:
      - crash-reporting-wg@mozilla.org
      - stability@mozilla.org
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1830098
    data_sensitivity:
      - technical
    expires: never
    send_in_pings:
      - crash
