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

[Next.js] Use OTEL for Vercel Edge SDK #13740

Closed
lforst opened this issue Sep 20, 2024 · 2 comments
Closed

[Next.js] Use OTEL for Vercel Edge SDK #13740

lforst opened this issue Sep 20, 2024 · 2 comments
Assignees

Comments

@lforst
Copy link
Member

lforst commented Sep 20, 2024

Description

We need this for Turbopack support.

@lforst lforst self-assigned this Sep 20, 2024
@lforst
Copy link
Member Author

lforst commented Sep 30, 2024

I did some work on this in #13742 to discover that @opentelemetry/core relies on the performance API for its browser export in the global scope which is not available in the edge runtime. Next.js 14+ and the @vercel/otel package seem to add a polyfill to make this work, however, in our situation it is a bit more tricky to polyfill, since we are using externalized versions of the @sentry/opentelemetry. We would need to bundle all dependencies into one file and add the polyfill to the top as a banner.

EDIT: Got it working by bundling and putting the polyfill on top as a banner.

lforst added a commit that referenced this issue Oct 7, 2024
**This PR is part of a stacked PR sequence as we need to do many changes
at once for #8105.
Merging this PR as is will create inconsistent data.**

---

This PR will make the `@sentry/vercel-edge` SDK use OpenTelemetry
performance under the hood.

We need to employ a few hacks so that OpenTelemetry works on a worker
runtime:
- We are vendoring the OTEL `AsyncLocalStorageContextManage` because the
original implementation depends on `AsyncLocalStorage` as exported from
`async_hooks` which is not available in workers. In our vendored version
we are taking it from `globalThis.AsyncLocalStorage`.
- We are polyfilling `performance` with `Date.now()` as that API is not
available in worker runtimes.

Resolves #13740
@lforst
Copy link
Member Author

lforst commented Oct 7, 2024

Resolved with #13742

@lforst lforst closed this as completed Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant