diff --git a/netwerk/dns/TRRSkippedReason.h b/netwerk/dns/TRRSkippedReason.h index c9f605333c9b..b480e08057f7 100644 --- a/netwerk/dns/TRRSkippedReason.h +++ b/netwerk/dns/TRRSkippedReason.h @@ -51,6 +51,27 @@ enum class TRRSkippedReason : uint32_t { ODOH_DECRYPTION_FAILED = 36, // Failed to decrypt DNS packets. }; +inline bool IsRelevantTRRSkipReason(TRRSkippedReason aReason) { + // - TRR_REQ_MODE_DISABLED - these requests are intentionally skipping TRR. + // These include DNS queries used to bootstrap the TRR connection, + // captive portal checks, connectivity checks, etc. + // Since we don't want to use TRR for these connections, we don't need + // to include them with other relevant skip reasons. + // - TRR_DISABLED_FLAG - This reason is used when retrying failed connections, + // sync DNS resolves on the main thread, or requests coming from + // webextensions that choose to skip TRR + // - TRR_EXCLUDED - This reason is used when a certain domain is excluded + // from TRR because it is explicitly set by the user, or because it + // is part of the user's DNS suffix list, indicating a host that is likely + // to be on the local network. + if (aReason == TRRSkippedReason::TRR_REQ_MODE_DISABLED || + aReason == TRRSkippedReason::TRR_DISABLED_FLAG || + aReason == TRRSkippedReason::TRR_EXCLUDED) { + return false; + } + return true; +} + } // namespace net } // namespace mozilla diff --git a/netwerk/dns/nsHostRecord.cpp b/netwerk/dns/nsHostRecord.cpp index f7ec1020d21b..229c6728cd43 100644 --- a/netwerk/dns/nsHostRecord.cpp +++ b/netwerk/dns/nsHostRecord.cpp @@ -312,6 +312,20 @@ void AddrHostRecord::ResolveComplete() { : Telemetry::TRR_SKIP_REASON_NATIVE_FAILED, TRRService::ProviderKey(), static_cast(mTRRSkippedReason)); } + + if (IsRelevantTRRSkipReason(mTRRSkippedReason)) { + Telemetry::Accumulate(Telemetry::TRR_RELEVANT_SKIP_REASON_TRR_FIRST, + TRRService::ProviderKey(), + static_cast(mTRRSkippedReason)); + + if (!mTRRSuccess) { + Telemetry::Accumulate( + mNativeSuccess ? Telemetry::TRR_RELEVANT_SKIP_REASON_NATIVE_SUCCESS + : Telemetry::TRR_RELEVANT_SKIP_REASON_NATIVE_FAILED, + TRRService::ProviderKey(), + static_cast(mTRRSkippedReason)); + } + } } if (mEffectiveTRRMode == nsIRequest::TRR_FIRST_MODE) { diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 7fde8c0ba94b..de7a883c8b24 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -4641,6 +4641,44 @@ "releaseChannelCollection": "opt-out", "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." }, + + "TRR_RELEVANT_SKIP_REASON_TRR_FIRST": { + "record_in_processes": ["main", "socket"], + "products": ["firefox"], + "alert_emails": ["necko@mozilla.com", "vgosu@mozilla.com"], + "expires_in_version": "never", + "kind": "enumerated", + "keyed": true, + "n_values": 50, + "bug_numbers": [1649143, 1699523, 1742408], + "releaseChannelCollection": "opt-out", + "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." + }, + "TRR_RELEVANT_SKIP_REASON_NATIVE_SUCCESS": { + "record_in_processes": ["main", "socket"], + "products": ["firefox"], + "alert_emails": ["necko@mozilla.com", "vgosu@mozilla.com"], + "expires_in_version": "never", + "kind": "enumerated", + "keyed": true, + "n_values": 50, + "bug_numbers": [1649143, 1699523, 1742408], + "releaseChannelCollection": "opt-out", + "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." + }, + "TRR_RELEVANT_SKIP_REASON_NATIVE_FAILED": { + "record_in_processes": ["main", "socket"], + "products": ["firefox"], + "alert_emails": ["necko@mozilla.com", "vgosu@mozilla.com"], + "expires_in_version": "never", + "kind": "enumerated", + "keyed": true, + "n_values": 50, + "bug_numbers": [1699523, 1742408], + "releaseChannelCollection": "opt-out", + "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." + }, + "DNS_TRR_FIRST4": { "record_in_processes": ["main", "socket"], "products": ["firefox", "fennec"],