Skip to content

Conversation

@lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented May 21, 2021

This enables front end and API route performance monitoring in @sentry/nextjs. Hat tip to @iker-barriocanal, @AbhiPrasad, and @HazAT - this was a group effort.

CleanShot 2021-05-31 at 09 29 47
CleanShot 2021-05-31 at 09 30 28

@github-actions
Copy link
Contributor

github-actions bot commented May 21, 2021

size-limit report

Path Size
@sentry/browser - CDN Bundle (gzipped) 20.77 KB (0%)
@sentry/browser - Webpack 22 KB (0%)
@sentry/react - Webpack 22.03 KB (0%)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 28.17 KB (0%)

@HazAT
Copy link
Member

HazAT commented May 21, 2021

6.5.0-beta.0

lobsterkatie and others added 8 commits May 21, 2021 20:21
…request data (#3577)

This PR does two things:

1) It wraps two more methods on `next`'s `Server` class, one of which is called on every API request, and the other of which is called on every page request. Both methods are passed a parameterized version of the path, which our wrappers grab and use to modify the name of the currently active transaction.

2) It adds an event processor which pulls data off of the request and adds it to the event. This runs whether or not tracing is enabled, in order to add data to both error and transaction events.

The only other thing of minor interest is that the type for `Event.request.query_string` is expanded to include objects, which is okay according to the dev docs: https://develop.sentry.dev/sdk/event-payloads/request/#attribute).
Just a bunch of random housekeeping.

- No longer return project root directory from `instrumentServer` since it's not yet defined at that point.
- No longer store transaction on `res`, since our new use of domains means that `getActiveTransaction` is safe. As a result, change `NextResponse` from an interface to a type which is purely an alias.
- Store a pointer to the live `Server` instance directly on the top scope rather than in an object, and get rid of the other stuff being stored in that object (`closure`) since it can all be gotten off of the aforementioned `Server` instance.
- Fix/expand/tweak various docstrings and comments.
- Improve log message when tracing an outgoing HTTP request.
)

Adds support for continuing a trace started in another service, by reading and applying the `sentry-trace` header on incoming requests. It also passes the request as extra context in the `tracesSampler`.
1) Fix a bug which prevented the "don't overwrite these keys" warning from working correctly. 

2) Restrict the warning to appearing when overwriting keys which actually have values.
Automatically enable `BrowserTracing` if a traceSampler or tracesSample Rate is set.

Co-authored-by: Abhijeet Prasad <[email protected]>
Use the stripUrlQueryAndFragment function from @sentry/utils
instead of using our implementation.
@tm1000 tm1000 mentioned this pull request May 26, 2021
1 task
import { addIntegration, UserIntegrations } from './utils/userIntegrations';

export * from '@sentry/react';
export { nextRouterInstrumentation } from './performance/client';
Copy link

Choose a reason for hiding this comment

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

This is imported twice

AbhiPrasad and others added 5 commits May 26, 2021 14:23
When instrumenting the nextjs server, we should check if the
public directory exists.
Update default tracingOrigins for NextJS BrowserTracing to
include api routes so we can add sentry-trace header correctly.
@HazAT HazAT changed the title WIP nextjs performance feat(nextjs): Frontend + withSentry Performance Monitoring May 31, 2021
@HazAT HazAT marked this pull request as ready for review May 31, 2021 07:30
@HazAT HazAT requested a review from kamilogorek as a code owner May 31, 2021 07:30
@iker-barriocanal iker-barriocanal self-requested a review May 31, 2021 08:46
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

Successfully merging this pull request may close these issues.

6 participants