diff --git a/netwerk/dns/TRR.cpp b/netwerk/dns/TRR.cpp index 1d0cd5e1142f..0572da4723f0 100644 --- a/netwerk/dns/TRR.cpp +++ b/netwerk/dns/TRR.cpp @@ -882,6 +882,28 @@ void TRR::ReportStatus(nsresult aStatusCode) { } } +static void RecordHttpVersion(nsIHttpChannel* aHttpChannel) { + nsAutoCString protocol; + nsresult rv = aHttpChannel->GetProtocolVersion(protocol); + if (NS_FAILED(rv)) { + LOG(("Failed to get protocol version, rv=%x", (int)rv)); + return; + } + + if (protocol.LowerCaseEqualsLiteral("h2")) { + Telemetry::AccumulateCategorical( + Telemetry::LABELS_DNS_TRR_HTTP_VERSION::h_2); + } else if (protocol.LowerCaseEqualsLiteral("h3")) { + Telemetry::AccumulateCategorical( + Telemetry::LABELS_DNS_TRR_HTTP_VERSION::h_3); + } else { + Telemetry::AccumulateCategorical( + Telemetry::LABELS_DNS_TRR_HTTP_VERSION::h_1); + } + + LOG(("DoH endpoint responded using HTTP version: %s", protocol.get())); +} + NS_IMETHODIMP TRR::OnStopRequest(nsIRequest* aRequest, nsresult aStatusCode) { // The dtor will be run after the function returns @@ -927,6 +949,7 @@ TRR::OnStopRequest(nsIRequest* aRequest, nsresult aStatusCode) { if (NS_SUCCEEDED(rv) && UseDefaultServer()) { RecordReason(nsHostRecord::TRR_OK); RecordProcessingTime(channel); + RecordHttpVersion(httpChannel); return rv; } } else { diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 169a94079b90..7036408a19fe 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -4220,6 +4220,17 @@ "n_buckets": 50, "description": "Time from the last received byte of the response until we have notified the consumer with a DNS record (msec)" }, + "DNS_TRR_HTTP_VERSION": { + "record_in_processes": ["main"], + "products": ["firefox"], + "expires_in_version": "never", + "kind": "categorical", + "labels": ["h_1", "h_2", "h_3"], + "releaseChannelCollection": "opt-out", + "alert_emails": ["nhnt11@mozilla.com", "necko@mozilla.com"], + "bug_numbers": [1460314], + "description": "HTTP version used by DoH endpoint" + }, "DNS_NATIVE_LOOKUP_TIME": { "record_in_processes": ["main"], "products": ["firefox", "fennec"],