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 SSR category to tracing #62318

Merged
merged 1 commit into from
Feb 21, 2024
Merged
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
17 changes: 16 additions & 1 deletion packages/next-swc/crates/next-api/src/pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,13 @@ enum PageEndpointType {
SsrOnly,
}

#[derive(Copy, Clone, Serialize, Deserialize, PartialEq, Eq, Debug, TaskInput, TraceRawVcs)]
enum SsrChunkType {
Page,
Data,
Api,
}

#[turbo_tasks::value_impl]
impl PageEndpoint {
#[turbo_tasks::function]
Expand Down Expand Up @@ -631,6 +638,7 @@ impl PageEndpoint {
#[turbo_tasks::function]
async fn internal_ssr_chunk(
self: Vc<Self>,
ty: SsrChunkType,
reference_type: Value<ReferenceType>,
node_path: Vc<FileSystemPath>,
project_root: Vc<FileSystemPath>,
Expand Down Expand Up @@ -749,14 +757,19 @@ impl PageEndpoint {
.cell())
}
}
.instrument(tracing::info_span!("page server side rendering"))
.instrument(match ty {
SsrChunkType::Page => tracing::info_span!("page server side rendering"),
SsrChunkType::Data => tracing::info_span!("server side data"),
SsrChunkType::Api => tracing::info_span!("server side api"),
})
.await
}

#[turbo_tasks::function]
async fn ssr_chunk(self: Vc<Self>) -> Result<Vc<SsrChunk>> {
let this = self.await?;
Ok(self.internal_ssr_chunk(
SsrChunkType::Page,
Value::new(ReferenceType::Entry(EntryReferenceSubType::Page)),
this.pages_project
.project()
Expand All @@ -776,6 +789,7 @@ impl PageEndpoint {
async fn ssr_data_chunk(self: Vc<Self>) -> Result<Vc<SsrChunk>> {
let this = self.await?;
Ok(self.internal_ssr_chunk(
SsrChunkType::Data,
Value::new(ReferenceType::Entry(EntryReferenceSubType::Page)),
this.pages_project
.project()
Expand All @@ -795,6 +809,7 @@ impl PageEndpoint {
async fn api_chunk(self: Vc<Self>) -> Result<Vc<SsrChunk>> {
let this = self.await?;
Ok(self.internal_ssr_chunk(
SsrChunkType::Api,
Value::new(ReferenceType::Entry(EntryReferenceSubType::PagesApi)),
this.pages_project
.project()
Expand Down
Loading