Skip to content

Commit

Permalink
fix edge runtime case
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Feb 20, 2024
1 parent 7469075 commit 4aec809
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -649,35 +649,38 @@ async function renderToHTMLOrFlightImpl(
}
}
}
req.on('end', () => {
const type = NextNodeServerSpan.clientComponentLoading
const startTime = clientComponentLoadStart
const endTime = clientComponentLoadStart + clientComponentLoadTimes
getTracer()
.startSpan(type, {
startTime,
attributes: {
'next.clientComponentLoadCount': clientComponentLoadCount,
},
})
.end(endTime)

if (
typeof performance !== 'undefined' &&
process.env.NEXT_OTEL_PERFORMANCE_PREFIX
) {
const { timeOrigin } = performance
performance.measure(
`${process.env.NEXT_OTEL_PERFORMANCE_PREFIX}:next-${(
type.split('.').pop() || ''
).replace(/[A-Z]/g, (match: string) => '-' + match.toLowerCase())}`,
{
start: startTime - timeOrigin,
end: endTime - timeOrigin,
}
)
}
})

if (typeof req.on === 'function') {
req.on('end', () => {
const type = NextNodeServerSpan.clientComponentLoading
const startTime = clientComponentLoadStart
const endTime = clientComponentLoadStart + clientComponentLoadTimes
getTracer()
.startSpan(type, {
startTime,
attributes: {
'next.clientComponentLoadCount': clientComponentLoadCount,
},
})
.end(endTime)

if (
typeof performance !== 'undefined' &&
process.env.NEXT_OTEL_PERFORMANCE_PREFIX
) {
const { timeOrigin } = performance
performance.measure(
`${process.env.NEXT_OTEL_PERFORMANCE_PREFIX}:next-${(
type.split('.').pop() || ''
).replace(/[A-Z]/g, (match: string) => '-' + match.toLowerCase())}`,
{
start: startTime - timeOrigin,
end: endTime - timeOrigin,
}
)
}
})
}

const metadata: AppPageRenderResultMetadata = {}

Expand Down

0 comments on commit 4aec809

Please sign in to comment.