diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp index dbbd8fe0cacd..d065ab17d9ca 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp +++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp @@ -62,16 +62,23 @@ struct UrlMarker { } static void StreamJSONMarkerData( mozilla::baseprofiler::SpliceableJSONWriter& aWriter, - const mozilla::ProfilerString8View& aURL) { + const mozilla::ProfilerString8View& aURL, const TimeDuration& aDuration, + uint64_t aChannelId) { if (aURL.Length() != 0) { aWriter.StringProperty("url", aURL); } + if (!aDuration.IsZero()) { + aWriter.DoubleProperty("duration", aDuration.ToMilliseconds()); + } + aWriter.IntProperty("channelId", static_cast(aChannelId)); } static MarkerSchema MarkerTypeDisplay() { using MS = MarkerSchema; MS schema(MS::Location::MarkerChart, MS::Location::MarkerTable); schema.SetTableLabel("{marker.name} - {marker.data.url}"); - schema.AddKeyFormat("url", MS::Format::Url); + schema.AddKeyFormatSearchable("url", MS::Format::Url, + MS::Searchable::Searchable); + schema.AddKeyLabelFormat("duration", "Duration", MS::Format::Duration); return schema; } }; @@ -505,9 +512,10 @@ nsresult nsHttpConnectionMgr::SpeculativeConnect( return NS_OK; } - nsCString url = ci->EndToEndSSL() ? "https://"_ns : "http://"_ns; + nsAutoCString url(ci->EndToEndSSL() ? "https://"_ns : "http://"_ns); url += ci->GetOrigin(); - PROFILER_MARKER("SpeculativeConnect", NETWORK, {}, UrlMarker, url); + PROFILER_MARKER("SpeculativeConnect", NETWORK, {}, UrlMarker, url, + TimeDuration::Zero(), 0); RefPtr args = new SpeculativeConnectArgs(); @@ -1649,9 +1657,9 @@ nsresult nsHttpConnectionMgr::DispatchTransaction(ConnectionEntry* ent, trans->CancelPacing(NS_OK); TimeStamp now = TimeStamp::Now(); + TimeDuration elapsed = now - trans->GetPendingTime(); auto recordPendingTimeForHTTPSRR = [&](nsCString& aKey) { uint32_t stage = trans->HTTPSSVCReceivedStage(); - TimeDuration elapsed = now - trans->GetPendingTime(); if (HTTPS_RR_IS_USED(stage)) { glean::networking::transaction_wait_time_https_rr.AccumulateRawDuration( elapsed); @@ -1659,10 +1667,16 @@ nsresult nsHttpConnectionMgr::DispatchTransaction(ConnectionEntry* ent, } else { glean::networking::transaction_wait_time.AccumulateRawDuration(elapsed); } - PerfStats::RecordMeasurement(PerfStats::Metric::HttpTransactionWaitTime, - elapsed); }; + PerfStats::RecordMeasurement(PerfStats::Metric::HttpTransactionWaitTime, + elapsed); + + PROFILER_MARKER( + "DispatchTransaction", NETWORK, + MarkerOptions(MarkerTiming::Interval(trans->GetPendingTime(), now)), + UrlMarker, trans->GetUrl(), elapsed, trans->ChannelId()); + nsAutoCString httpVersionkey("h1"_ns); if (conn->UsingSpdy() || conn->UsingHttp3()) { LOG( @@ -1770,6 +1784,9 @@ nsresult nsHttpConnectionMgr::ProcessNewTransaction(nsHttpTransaction* trans) { trans->SetPendingTime(); + PROFILER_MARKER("ProcessNewTransaction", NETWORK, {}, UrlMarker, + trans->GetUrl(), TimeDuration::Zero(), trans->ChannelId()); + RefPtr pushedStreamWrapper = trans->GetPushedStream(); if (pushedStreamWrapper) { diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp index c9bea71e74a4..9bf837f478cc 100644 --- a/netwerk/protocol/http/nsHttpTransaction.cpp +++ b/netwerk/protocol/http/nsHttpTransaction.cpp @@ -398,11 +398,16 @@ nsresult nsHttpTransaction::Init( } RefPtr httpChannel = do_QueryObject(eventsink); - RefPtr listener = - httpChannel ? httpChannel->GetWebTransportSessionEventListener() - : nullptr; - if (listener) { - mWebTransportSessionEventListener = std::move(listener); + if (httpChannel) { + RefPtr listener = + httpChannel->GetWebTransportSessionEventListener(); + if (listener) { + mWebTransportSessionEventListener = std::move(listener); + } + nsCOMPtr uri; + if (NS_SUCCEEDED(httpChannel->GetURI(getter_AddRefs(uri)))) { + mUrl = uri->GetSpecOrDefault(); + } } return NS_OK; diff --git a/netwerk/protocol/http/nsHttpTransaction.h b/netwerk/protocol/http/nsHttpTransaction.h index 5256de4cf2df..dd019e00e8a6 100644 --- a/netwerk/protocol/http/nsHttpTransaction.h +++ b/netwerk/protocol/http/nsHttpTransaction.h @@ -196,6 +196,10 @@ class nsHttpTransaction final : public nsAHttpTransaction, bool IsForWebTransport() { return mIsForWebTransport; } + nsAutoCString GetUrl() { return mUrl; } + + uint64_t ChannelId() { return mChannelId; } + private: friend class DeleteHttpTransaction; virtual ~nsHttpTransaction(); @@ -593,6 +597,8 @@ class nsHttpTransaction final : public nsAHttpTransaction, nsCString mHashKeyOfConnectionEntry; nsCOMPtr mWebTransportSessionEventListener; + + nsAutoCString mUrl; }; } // namespace mozilla::net