# 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: DNS'

dns:
  lookup_method:
    type: custom_distribution
    description: >
      DNS Lookup Type (hit, renewal, negative-hit, literal, overflow,
      network-first, network-shared)

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

  cleanup_age:
    type: timing_distribution
    description: >
      DNS Cache Entry Age at Removal Time (minutes)

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

  by_type_cleanup_age:
    type: timing_distribution
    description: >
      DNS Cache Entry Age for by-type queries at Removal Time (minutes)

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

  premature_eviction:
    type: timing_distribution
    description: >
      DNS Cache Entry Age at Removal Time of non-expired entries (minutes)

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

  by_type_premature_eviction:
    type: timing_distribution
    description: >
      DNS Cache Entry Age for by-type queries at Removal Time of non-expired
      entries (minutes)

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

  trr_lookup_time:
    type: labeled_timing_distribution
    description: >
      Time for a completed TRR resolution (msec); Keyed by TRR domain

      This metric was generated to correspond to the Legacy Telemetry
      exponential histogram DNS_TRR_LOOKUP_TIME3.
    time_unit: millisecond
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1434852
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1640867
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1646452
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1434852
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1640867
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1646452
    notification_emails:
      - necko@mozilla.com
      - vgosu@mozilla.com
    expires: never
    telemetry_mirror: DNS_TRR_LOOKUP_TIME3

  trr_processing_time:
    type: timing_distribution
    description: >
      Time from the last received byte of the response until we have notified
      the consumer with a DNS record (msec)

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

  trr_skip_reason_trr_first:
    type: labeled_custom_distribution
    description: >
      When in TRR-first mode, it lists the reason we may have skipped TRR, keyed
      by the provider.

      This metric was generated to correspond to the Legacy Telemetry enumerated
      histogram TRR_SKIP_REASON_TRR_FIRST2.
    range_min: 0
    range_max: 50
    bucket_count: 51
    histogram_type: linear
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1649143
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1699523
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1649143
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1699523
    notification_emails:
      - necko@mozilla.com
      - vgosu@mozilla.com
    expires: never
    telemetry_mirror: TRR_SKIP_REASON_TRR_FIRST2

  trr_skip_reason_native_success:
    type: labeled_custom_distribution
    description: >
      When in TRR-first mode, if TRR was skipped and native succeeded, it lists
      the reason we may have skipped TRR, keyed by the provider.

      This metric was generated to correspond to the Legacy Telemetry enumerated
      histogram TRR_SKIP_REASON_NATIVE_SUCCESS.
    range_min: 0
    range_max: 50
    bucket_count: 51
    histogram_type: linear
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1649143
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1699523
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1649143
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1699523
    notification_emails:
      - necko@mozilla.com
      - vgosu@mozilla.com
    expires: never
    telemetry_mirror: TRR_SKIP_REASON_NATIVE_SUCCESS

  trr_skip_reason_native_failed:
    type: labeled_custom_distribution
    description: >
      When in TRR-first mode, if TRR was skipped and native failed, it lists the
      reason we may have skipped TRR, keyed by the provider.

      This metric was generated to correspond to the Legacy Telemetry enumerated
      histogram TRR_SKIP_REASON_NATIVE_FAILED.
    range_min: 0
    range_max: 50
    bucket_count: 51
    histogram_type: linear
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1699523
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1699523
    notification_emails:
      - necko@mozilla.com
      - vgosu@mozilla.com
    expires: never
    telemetry_mirror: TRR_SKIP_REASON_NATIVE_FAILED

  trr_relevant_skip_reason_trr_first:
    type: labeled_custom_distribution
    description: >
      When in TRR-first mode, it lists the reason we may have skipped TRR, keyed
      by the provider. Does not include requests that intentionally skip TRR.

      This metric was generated to correspond to the Legacy Telemetry enumerated
      histogram TRR_RELEVANT_SKIP_REASON_TRR_FIRST.
    range_min: 0
    range_max: 50
    bucket_count: 51
    histogram_type: linear
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1649143
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1699523
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1742408
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1649143
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1699523
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1742408
    notification_emails:
      - necko@mozilla.com
      - vgosu@mozilla.com
    expires: never
    telemetry_mirror: TRR_RELEVANT_SKIP_REASON_TRR_FIRST

  trr_relevant_skip_reason_native_success:
    type: labeled_custom_distribution
    description: >
      When in TRR-first mode, if TRR was skipped and native succeeded, it lists
      the reason we may have skipped TRR, keyed by the provider. Does not
      include requests that intentionally skip TRR.

      This metric was generated to correspond to the Legacy Telemetry enumerated
      histogram TRR_RELEVANT_SKIP_REASON_NATIVE_SUCCESS.
    range_min: 0
    range_max: 50
    bucket_count: 51
    histogram_type: linear
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1649143
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1699523
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1742408
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1649143
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1699523
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1742408
    notification_emails:
      - necko@mozilla.com
      - vgosu@mozilla.com
    expires: never
    telemetry_mirror: TRR_RELEVANT_SKIP_REASON_NATIVE_SUCCESS

  trr_relevant_skip_reason_native_failed:
    type: labeled_custom_distribution
    description: >
      When in TRR-first mode, if TRR was skipped and native failed, it lists the
      reason we may have skipped TRR, keyed by the provider. Does not include
      requests that intentionally skip TRR.

      This metric was generated to correspond to the Legacy Telemetry enumerated
      histogram TRR_RELEVANT_SKIP_REASON_NATIVE_FAILED.
    range_min: 0
    range_max: 50
    bucket_count: 51
    histogram_type: linear
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1699523
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1742408
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1699523
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1742408
    notification_emails:
      - necko@mozilla.com
      - vgosu@mozilla.com
    expires: never
    telemetry_mirror: TRR_RELEVANT_SKIP_REASON_NATIVE_FAILED

  trr_skip_reason_strict_mode:
    type: labeled_custom_distribution
    description: >
      When in TRR-first mode, it lists the reason we may have skipped TRR. The
      key is like `<provider>|<skip reason of first attempt>` or just
      `<provider>` used when there was no second attempt.

      This metric was generated to correspond to the Legacy Telemetry enumerated
      histogram TRR_SKIP_REASON_STRICT_MODE.
    range_min: 0
    range_max: 50
    bucket_count: 51
    histogram_type: linear
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1737198
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1737198
    notification_emails:
      - necko@mozilla.com
    expires: never
    telemetry_mirror: TRR_SKIP_REASON_STRICT_MODE

  trr_skip_reason_retry_success:
    type: labeled_custom_distribution
    description: >
      When in TRR-first mode, if TRR failed once and was successfully retried,
      it lists the reason for the first failure, keyed by the provider.

      This metric was generated to correspond to the Legacy Telemetry enumerated
      histogram TRR_SKIP_REASON_RETRY_SUCCESS.
    range_min: 0
    range_max: 50
    bucket_count: 51
    histogram_type: linear
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1737198
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1737198
    notification_emails:
      - necko@mozilla.com
    expires: never
    telemetry_mirror: TRR_SKIP_REASON_RETRY_SUCCESS

  trr_skip_reason_retry_failed:
    type: labeled_custom_distribution
    description: >
      When in TRR-first mode, if TRR failed once and retried unsuccessfully, it
      lists the reason for the first failure, keyed by the provider.

      This metric was generated to correspond to the Legacy Telemetry enumerated
      histogram TRR_SKIP_REASON_RETRY_FAILED.
    range_min: 0
    range_max: 50
    bucket_count: 51
    histogram_type: linear
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1737198
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1737198
    notification_emails:
      - necko@mozilla.com
    expires: never
    telemetry_mirror: TRR_SKIP_REASON_RETRY_FAILED

  trr_relevant_skip_reason_trr_first_type_rec:
    type: labeled_custom_distribution
    description: >
      When in TRR-first mode, it lists the reason we may have skipped TRR for
      HTTPS RR, keyed by the provider. Does not include requests that
      intentionally skip TRR.

      This metric was generated to correspond to the Legacy Telemetry enumerated
      histogram TRR_RELEVANT_SKIP_REASON_TRR_FIRST_TYPE_REC.
    range_min: 0
    range_max: 50
    bucket_count: 51
    histogram_type: linear
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1850367
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1850367
    notification_emails:
      - necko@mozilla.com
      - kershaw@mozilla.com
    expires: never
    telemetry_mirror: TRR_RELEVANT_SKIP_REASON_TRR_FIRST_TYPE_REC

  trr_attempt_count:
    type: labeled_custom_distribution
    description: >
      Number of times we attempted TRR for a successful lookup in TRR-first
      mode. Keyed by provider.

      This metric was generated to correspond to the Legacy Telemetry enumerated
      histogram TRR_ATTEMPT_COUNT.
    range_min: 0
    range_max: 10
    bucket_count: 11
    histogram_type: linear
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1737198
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1737198
    notification_emails:
      - necko@mozilla.com
    expires: never
    telemetry_mirror: TRR_ATTEMPT_COUNT

  native_lookup_time:
    type: timing_distribution
    description: >
      Time for a completed native name resolution (msec)

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

  by_type_failed_lookup_time:
    type: timing_distribution
    description: >
      Time for a completed by-type resolution that has a negative answer (msec).

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

  by_type_succeeded_lookup_time:
    type: timing_distribution
    description: >
      Time for a completed by-type resolution that succeeded (msec).

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

  native_queuing:
    type: timing_distribution
    description: >
      Time in resolve queue waiting to getaddrinfo (msec)

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

  lookup_algorithm:
    type: labeled_counter
    description: >
      DNS: lookup algorithm

      This metric was generated to correspond to the Legacy Telemetry
      categorical histogram DNS_LOOKUP_ALGORITHM.
    labels:
      - nativeOnly
      - trrRace
      - trrFirst
      - trrOnly
      - trrShadow
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1434852
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1434852
    notification_emails:
      - necko@mozilla.com
    expires: never
    telemetry_mirror: h#DNS_LOOKUP_ALGORITHM

  blocklist_count:
    type: custom_distribution
    description: >
      The number of unusable addresses reported for each record

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