# 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:
  - 'Core :: Networking: Cache'

network:
  disk_cache2_shutdown_clear_private:
    type: timing_distribution
    description: >
      Time spent (ms) during shutdown deleting disk cache v2 for 'clear private
      data' option

      This metric was generated to correspond to the Legacy Telemetry
      exponential histogram NETWORK_DISK_CACHE2_SHUTDOWN_CLEAR_PRIVATE.
    time_unit: millisecond
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2037081
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
    notification_emails:
      - necko@mozilla.com
    expires: never

  cache_v2_output_stream_status:
    type: custom_distribution
    description: >
      Final status of the CacheFileOutputStream (0=ok, 1=other error, 2=out of
      memory, 3=disk full, 4=file corrupted, 5=file not found, 6=binding
      aborted)

      This metric was generated to correspond to the Legacy Telemetry enumerated
      histogram NETWORK_CACHE_V2_OUTPUT_STREAM_STATUS.
    range_min: 0
    range_max: 7
    bucket_count: 8
    histogram_type: linear
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2037081
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
    notification_emails:
      - necko@mozilla.com
    expires: never

  cache_v2_input_stream_status:
    type: custom_distribution
    description: >
      Final status of the CacheFileInputStream (0=ok, 1=other error, 2=out of
      memory, 3=disk full, 4=file corrupted, 5=file not found, 6=binding
      aborted)

      This metric was generated to correspond to the Legacy Telemetry enumerated
      histogram NETWORK_CACHE_V2_INPUT_STREAM_STATUS.
    range_min: 0
    range_max: 7
    bucket_count: 8
    histogram_type: linear
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2037081
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
    notification_emails:
      - necko@mozilla.com
    expires: never

  cache_size:
    type: labeled_memory_distribution
    description: >
      Cache size in megabytes keyed by cache capacity calculation type. Numbers
      are sampled periodically, every time 2GB of data is written to the cache.
    memory_unit: megabyte
    labels:
      - SMARTSIZE
      - USERDEFINEDSIZE
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1548472
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2037081
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1548472
    notification_emails:
      - necko@mozilla.com
    expires: never

  cache_entry_count:
    type: labeled_custom_distribution
    description: >
      Number of entries in the cache keyed by cache capacity calculation type.
      Numbers are sampled periodically, every time 2GB of data is written to the
      cache.
    range_min: 1
    range_max: 100000
    bucket_count: 100
    histogram_type: exponential
    unit: cache entries
    labels:
      - SMARTSIZE
      - USERDEFINEDSIZE
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1548472
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2037081
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1548472
    notification_emails:
      - necko@mozilla.com
    expires: never

  cache_size_share:
    type: labeled_custom_distribution
    description: >
      Percentage of the cache size occupied by given content type. Numbers are
      sampled periodically, every time 2GB of data is written to the cache.

      This metric was generated to correspond to the Legacy Telemetry enumerated
      histogram NETWORK_CACHE_SIZE_SHARE.
    range_min: 0
    range_max: 99
    bucket_count: 100
    histogram_type: linear
    labels:
      - UNKNOWN
      - OTHER
      - JAVASCRIPT
      - IMAGE
      - MEDIA
      - STYLESHEET
      - WASM
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1548472
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2037081
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1548472
    notification_emails:
      - necko@mozilla.com
    expires: never

  cache_entry_count_share:
    type: labeled_custom_distribution
    description: >
      Percentage of the entries with the given content type. Numbers are sampled
      periodically, every time 2GB of data is written to the cache.

      This metric was generated to correspond to the Legacy Telemetry enumerated
      histogram NETWORK_CACHE_ENTRY_COUNT_SHARE.
    range_min: 0
    range_max: 99
    bucket_count: 100
    histogram_type: linear
    labels:
      - UNKNOWN
      - OTHER
      - JAVASCRIPT
      - IMAGE
      - MEDIA
      - STYLESHEET
      - WASM
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1548472
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2037081
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1548472
    notification_emails:
      - necko@mozilla.com
    expires: never

  http_cache_entry_reload_time:
    type: timing_distribution
    description: >
      Time before we reload an HTTP cache entry again to memory

      This metric was generated to correspond to the Legacy Telemetry
      exponential histogram HTTP_CACHE_ENTRY_RELOAD_TIME.
    time_unit: millisecond
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2037081
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
    notification_emails:
      - necko@mozilla.com
    expires: never

  http_cache_entry_alive_time:
    type: timing_distribution
    description: >
      Time for which an HTTP cache entry is kept warmed in memory

      This metric was generated to correspond to the Legacy Telemetry
      exponential histogram HTTP_CACHE_ENTRY_ALIVE_TIME.
    time_unit: millisecond
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2037081
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
    notification_emails:
      - necko@mozilla.com
    expires: never

  http_cache_entry_reuse_count:
    type: custom_distribution
    description: >
      Reuse count of an HTTP cache entry warmed in memory

      This metric was generated to correspond to the Legacy Telemetry linear
      histogram HTTP_CACHE_ENTRY_REUSE_COUNT.
    range_min: 1
    range_max: 20
    bucket_count: 19
    histogram_type: linear
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2037081
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
    notification_emails:
      - necko@mozilla.com
    expires: never
