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

# Adding a new metric? We have docs for that!
# https://firefox-source-docs.mozilla.org/toolkit/components/glean/user/new_definitions_file.html

---
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0
$tags:
  - 'WebExtensions :: General'

extensions:
  startup_cache_load_time:
    type: timespan
    time_unit: millisecond
    expires: never
    description: |
      Time to load and deserialize the extensions startupCache data.
    lifetime: application
    notification_emails:
      - addons-dev-internal@mozilla.com
      - lgreco@mozilla.com
    bugs:
      - https://bugzilla.mozilla.org/1767336/
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1767336#c7
    data_sensitivity:
      - technical
    telemetry_mirror: EXTENSIONS_STARTUPCACHE_LOAD_TIME

extensions.apis.dnr:

  startup_cache_read_size:
    type: memory_distribution
    memory_unit: byte
    expires: 120
    description: |
      Amount of data read from the DNR startup cache file.
    lifetime: application
    notification_emails:
      - addons-dev-internal@mozilla.com
    bugs:
      - https://bugzilla.mozilla.org/1803363/
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1803363#c11
    data_sensitivity:
      - technical
    telemetry_mirror: WEBEXT_DNR_STARTUPCACHE_READ_BYTES

  startup_cache_read_time:
    type: timing_distribution
    time_unit: millisecond
    expires: 120
    description: |
      Amount of time it takes to read data into the DNR startup cache file.
    lifetime: application
    notification_emails:
      - addons-dev-internal@mozilla.com
    bugs:
      - https://bugzilla.mozilla.org/1803363/
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1803363#c11
    data_sensitivity:
      - technical
    telemetry_mirror: WEBEXT_DNR_STARTUPCACHE_READ_MS

  startup_cache_write_size:
    type: memory_distribution
    memory_unit: byte
    expires: 120
    description: |
      Amount of data written to the DNR startup cache file.
    lifetime: application
    notification_emails:
      - addons-dev-internal@mozilla.com
    bugs:
      - https://bugzilla.mozilla.org/1803363/
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1803363#c11
    data_sensitivity:
      - technical
    telemetry_mirror: WEBEXT_DNR_STARTUPCACHE_WRITE_BYTES

  startup_cache_write_time:
    type: timing_distribution
    time_unit: millisecond
    expires: 120
    description: |
      Amount of time it takes to write data into the DNR startup cache file.
    lifetime: application
    notification_emails:
      - addons-dev-internal@mozilla.com
    bugs:
      - https://bugzilla.mozilla.org/1803363/
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1803363#c11
    data_sensitivity:
      - technical
    telemetry_mirror: WEBEXT_DNR_STARTUPCACHE_WRITE_MS

  startup_cache_entries:
    type: labeled_counter
    expires: 120
    description: |
      Counters for startup cache data hits or misses on initializating
      DNR rules for extensions loaded on application startup.
    lifetime: application
    notification_emails:
      - addons-dev-internal@mozilla.com
    bugs:
      - https://bugzilla.mozilla.org/1803363/
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1803363#c11
    data_sensitivity:
      - technical
    labels:
      - hit
      - miss
    telemetry_mirror: EXTENSIONS_APIS_DNR_STARTUP_CACHE_ENTRIES

  validate_rules_time:
    type: timing_distribution
    time_unit: millisecond
    expires: 120
    description: |
      Amount of time it takes to validate DNR rules of individual ruleset
      when dynamic or static rulesets have been loaded from disk.
    lifetime: application
    notification_emails:
      - addons-dev-internal@mozilla.com
    bugs:
      - https://bugzilla.mozilla.org/1803363/
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1803363#c11
    data_sensitivity:
      - technical
    telemetry_mirror: WEBEXT_DNR_VALIDATE_RULES_MS

  evaluate_rules_time:
    type: timing_distribution
    time_unit: millisecond
    expires: 120
    description: |
      Amount of time it takes to evaluate DNR rules for one network request.
    lifetime: application
    notification_emails:
      - addons-dev-internal@mozilla.com
    bugs:
      - https://bugzilla.mozilla.org/1803363/
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1803363#c11
    data_sensitivity:
      - technical
    telemetry_mirror: WEBEXT_DNR_EVALUATE_RULES_MS

  evaluate_rules_count_max:
    type: quantity
    unit: rules
    expires: 120
    description: |
      Max amount of DNR rules being evaluated.
    lifetime: ping
    notification_emails:
      - addons-dev-internal@mozilla.com
    bugs:
      - https://bugzilla.mozilla.org/1803363/
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1803363#c11
    data_sensitivity:
      - technical
    telemetry_mirror: EXTENSIONS_APIS_DNR_EVALUATE_RULES_COUNT_MAX