-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
Add clientTraceMetadata
experimental option to propagate tracing data to the client
#64256
Merged
huozhi
merged 13 commits into
vercel:canary
from
lforst:lforst-propagate-trace-to-client
May 15, 2024
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
fc32c5e
Add `clientTraceMetadata` experimental option to propagate tracing da…
lforst 3f5afcc
Add e2e test
lforst 7cfb692
Move folder
lforst 0f05491
Update tests to cover a few cases
lforst e2bac9c
Add test to ensure dynamicity of data
lforst 55a7209
Run tests for ppr true and false
lforst 9231fcb
Remove dev artifact
lforst 38536c4
Add comment clarifying the purpose of the `_next-trace-data-` prefix
lforst e430d57
use array to filer the injected metadata
huozhi 52abe2a
change type in turbopack
huozhi 1f42da0
rm conflicted flag
huozhi 4311c48
fix missing serverInsertedHTML
huozhi 2b3412e
test the non-injected case
huozhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# files generated by next.js | ||
node_modules/ |
5 changes: 5 additions & 0 deletions
5
test/e2e/opentelemetry/client-trace-metadata/app/dynamic-page/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const dynamic = 'force-dynamic' | ||
|
||
export default function DynamicPage() { | ||
return <h1 id="dynamic-page-header">Dynamic Page</h1> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Root({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
3 changes: 3 additions & 0 deletions
3
test/e2e/opentelemetry/client-trace-metadata/app/static-page-2/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function StaticPage() { | ||
return <h1 id="static-page-2-header">Static Page 2</h1> | ||
} |
15 changes: 15 additions & 0 deletions
15
test/e2e/opentelemetry/client-trace-metadata/app/static-page/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Link from 'next/link' | ||
|
||
export default function StaticPage() { | ||
return ( | ||
<> | ||
<h1 id="static-page-header">Static Page</h1> | ||
<Link href="/dynamic-page" id="go-to-dynamic-page"> | ||
Go to dynamic page | ||
</Link> | ||
<Link href="/static-page-2" id="go-to-static-page"> | ||
Go to static page | ||
</Link> | ||
</> | ||
) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBD, but you could check if the context is sampled and output nothing if it's not. The traceparent and similar have "sampled" flag. But usually non-sampled trace context is not helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, it is beneficial to propagate sampled and un-sampled contexts because telemetry systems often do traced-based sampling, where a tracing decision for a particular trace (usually decided on the first service) is propagated across the entire system, and the individual services of the system only report spans, if the incoming tracing decision is positive.
For example in the
traceparent
header there is a flag indicating whether the trace is sampled or not: https://www.w3.org/TR/trace-context/#sampled-flag If we didn't propagate the data when the trace is not sampled, the flag would not be needed in the first place.Does that make sense? All in all this is good because it allows us to have less logic here. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I meant - the absence of the trace can be used to mean the traceflags are
00
. But I agree with the overall reasoning. You can keep this.