Skip to content

Pass client trace metadata to client in pages router - #69620

Merged
huozhi merged 4 commits into
vercel:canaryfrom
lforst:client-trace-metadata-pages-router
Sep 10, 2024
Merged

huozhi merged 4 commits into
vercel:canaryfrom
lforst:client-trace-metadata-pages-router

Conversation

@lforst

@lforst lforst commented Sep 3, 2024 •

Copy link
Copy Markdown
Contributor

What?

Building on #64256, this PR forwards client trace metadata from OpenTelemetry to the client, but this time for the Pages router.

Why?

To reduce Telemetry libraries need to do expensive and complicated build-time instrumentation to pass these values to the client.

How?

We are using the ambient OpenTelemetry tracer to collect the data and pass it through the Document.

Resolves getsentry/sentry-javascript#13645

@ijjk ijjk added the type: next label Sep 3, 2024
@ijjk

ijjk commented Sep 3, 2024 •

Copy link
Copy Markdown
Member

Allow CI Workflow Run

  • approve CI run for commit: a636d73

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

import { addPathPrefix } from '../../shared/lib/router/utils/add-path-prefix'
import type { ClientTraceDataEntry } from '../lib/trace/tracer'

export function getTracedMetadata(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this to the trace utils as a generic place because here it was in the app router code and we also want to use it in the pages router.

@lforst lforst changed the title Pass client trace metadata to pages router clients Pass client trace metadata to client in pages router Sep 4, 2024
@ijjk ijjk added the tests label Sep 4, 2024
@lforst
lforst marked this pull request as ready for review September 4, 2024 08:57
@ijjk

ijjk commented Sep 4, 2024 •

Copy link
Copy Markdown
Member

Tests Passed

@huozhi
huozhi merged commit 47072bf into vercel:canary Sep 10, 2024
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Next.js] Contribute clientTraceMetadata for Pages Router upstream

3 participants