Skip to content

Conversation

@lobsterkatie
Copy link
Member

With @AbhiPrasad's blessing, a bunch of edits which originated as suggestions to #3586. That got merged before they could be made, so this adds them in a different form.

Included changes:

  • renamed variables
  • added comments and docstrings
  • a restructured addIntegrationToArray, to make the conditionals and flow clearer
  • a restructured (and renamed) Options type, to enforce that only options for the given integration can be passed and to allow multiple options to be passed

lobsterkatie and others added 16 commits May 17, 2021 11:26
Adds front-end performance monitoring in the Next.js SDK, by providing a router instrumentation.
…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 <aprasad@sentry.io>
@lobsterkatie lobsterkatie requested a review from kamilogorek as a code owner May 25, 2021 21:58
@github-actions
Copy link
Contributor

github-actions bot commented May 25, 2021

size-limit report

Path Size
@sentry/browser - CDN Bundle (gzipped) 20.76 KB (+0.01% 🔺)
@sentry/browser - Webpack 21.98 KB (0%)
@sentry/react - Webpack 22.01 KB (0%)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 28.16 KB (0%)

BrowserTracing: { keyPath: 'options.routingInstrumentation', value: nextRouterInstrumentation },
});
return addIntegration(defaultBrowserTracingIntegration, integrations, [
['options.routingInstrumentation', nextRouterInstrumentation],
Copy link
Member

Choose a reason for hiding this comment

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

Why not pass in the integration name here? I think that would simplify the logic when trying the find the integration to update.

Copy link
Member Author

@lobsterkatie lobsterkatie May 26, 2021

Choose a reason for hiding this comment

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

Yeah, I thought of that, but I was trying not to completely redo everything, LOL. Happy to do it, though.

Damn, didn't read closely enough. You mean instead of passing in a fully-formed instance? I'm not sure how that makes things simpler.

Copy link
Member

Choose a reason for hiding this comment

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

Something like this (like the logic I had above), so we know exactly what integration to update.

Suggested change
['options.routingInstrumentation', nextRouterInstrumentation],
['BrowserTracing', 'options.routingInstrumentation', nextRouterInstrumentation],

then we can just

for (const integration of allIntegrations) {
  if integration.name === options[0] {
    update(integration, options[1], options[2]);
  }
}

@kamilogorek kamilogorek dismissed their stale review May 27, 2021 07:49

Updated my reviewed parts.

Base automatically changed from kmclb-next-js-performance to master May 31, 2021 09:00
@lobsterkatie
Copy link
Member Author

Closing this as stale, as I think some of these changes have been made in the meantime. I'll come back to the others at some point, but I think it'll be easiest to do that in a new PR.

@lobsterkatie lobsterkatie deleted the kmclb-clarify-user-integration-manipulation branch September 15, 2021 05:42
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.

5 participants