Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turbopack: add tracing for fetch calls #77673

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions turbopack/crates/turbo-tasks-fetch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use anyhow::Result;
use turbo_rcstr::RcStr;
use turbo_tasks::{mark_session_dependent, ResolvedVc, Vc};
use turbo_tasks::{duration_span, mark_session_dependent, ResolvedVc, Vc};
use turbo_tasks_fs::FileSystemPath;
use turbopack_core::issue::{Issue, IssueSeverity, IssueStage, OptionStyledString, StyledString};

Expand Down Expand Up @@ -72,11 +72,20 @@ pub async fn fetch(
builder = builder.header("User-Agent", user_agent.as_str());
}

let response = builder.send().await.and_then(|r| r.error_for_status());
let response = {
let _span = duration_span!("fetch request", url = url.as_str());
builder.send().await
}
.and_then(|r| r.error_for_status());
match response {
Ok(response) => {
let status = response.status().as_u16();
let body = response.bytes().await?.to_vec();

let body = {
let _span = duration_span!("fetch response", url = url.as_str());
response.bytes().await?
}
.to_vec();

Ok(Vc::cell(Ok(HttpResponse {
status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ pub static TRACING_OVERVIEW_TARGETS: Lazy<Vec<&str>> = Lazy::new(|| {
vec![
"turbo_tasks=info",
"turbo_tasks_fs=info",
"turbo_tasks_fetch=info",
"turbopack=info",
"turbopack_binding=info",
"turbopack_browser=info",
"turbopack_nodejs=info",
"turbopack_cli=info",
"turbopack_cli_utils=info",
"turbopack_core=info",
"turbopack_css=info",
"turbopack_browser=info",
"turbopack_dev_server=info",
"turbopack_ecmascript=info",
"turbopack_ecmascript_hmr_protocol=info",
Expand Down
Loading