-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
ref(nextjs): UseRequestData
integration for errors
#5729
Merged
lobsterkatie
merged 9 commits into
master
from
kmclb-nextjs-use-requestdata-integration-for-errors
Sep 21, 2022
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8c13337
overwrite `transaction` value after running `addRequestDataToEvent`
lobsterkatie b0d3b94
add request to scope metadata in data fetchers wrapper
lobsterkatie c803491
add request to scope metadata in `instrumentServer`
lobsterkatie b9a2461
add request to scope metadata in `_error` helper
lobsterkatie 3f6835f
add request to scope metadata in `withSentry`
lobsterkatie 520b450
stop using event processor in datafetchers wrapper
lobsterkatie db88154
stop using event processor in `instrumentServer`
lobsterkatie b6d22fe
stop using event processor in `_error` helper
lobsterkatie 19c4fb1
stop using event processor in `withSentry`
lobsterkatie 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
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.
It just took me 20 minutes to figure out why it is safe to remove the
transaction: false
logic here. I believe what confused me since we don't have theinclude.transaction
defaulted tofalse
in therequestdata
integration. I think we should add that default just so it's more explicit.Also (for a lack of better place to comment) there are still some TODO comments in
addRequestDataToEvent
inrequestdata.ts
referencing Next.js. Can we remove those now?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.
include.transaction
isn't a thing anymore, at least not for the integration. From the description of #5703:Regardless, we didn't actually need that setting in the first place, at least not for transaction events. Even if
include.transaction
is set totrue
, transaction events will never fall into theif
because they always already have atransaction
value:sentry-javascript/packages/node/src/requestdata.ts
Line 286 in 17e4cb8
So that handles transaction events. As for error events, as of this PR it doesn't matter what
transaction
valueaddRequestDataToTransaction
sets, because we're overwriting it in the integration.(And sorry - I don't mean that to sound dismissive. It's a valid concern, just not one that happens to apply here.)
Probably. I'll give them a look.
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.
Ah right. I now remember why I set
transaction: false
in the first place - it was because the errors originating from data fetchers had the unparameterized route in a tag - which now seems to be the case again and I'm not sure this is a good thing, since thetransaction
tag now mismatches the actual transaction (Do we even need to be exact here though? I guess it might be confusing to users):Example - here the transaction tag is
GET /parameterized-page-with-getServerSideProps/two
while it should be/parameterized-page-with-getServerSideProps/[pageNum]
(event (after), event (before))
I guess both are sort of correct, I am just wondering which one is better. Do you have an opinion 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.
There also seem to be events where the tag is the request url. Not sure if this is related to this change though:
event
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.
Huh. In my testing, the tag was always overwritten with the
transaction
value, even when I specifically set it to be something different inbeforeSend
. The "after" event is from this branch?(Also, there's no reason we can't just fix the tag, too, just to be certain.)
UPDATE: In your event(after), event(before) links, one thing I notice is that the
before
event doesn't have atransaction
value at all (only a tag). Lemme play around with this a little more.UPDATE2: Damn. Rebase fail. 🤦🏻♀️ An old bug crept back in - wrong naming scheme for the link to the transaction on the request. Now I want to go back and make sure nothing else regressed...
On the
transaction
score, I think we should be good now, though: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.
Yeah before is some event before this PR and after is after checking out the PR.
Are we sure we want to have the
GET
in the transaction tag though? Since there will be a mismatch between actual transaction and transaction tag.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.
Yup, discovered that as well. I think I managed to drop a fixup commit somewhere in there, which both fixed how the transaction is retrieved and the check for whether or not to include the method for nextjs events.
For nextjs, to make it match current behavior, the answer is yes for API routes, no for page routes. I'm proposing that in v8 we should just standardize on always including the method. (We already include it in our express transaction names, for example.)
From my testing, I believe the only way this can happen (in the UI, at least) is for an event to come in with a
transaction
tag but no top-leveltransaction
value (like your "before" event). If an outgoing event has both a top-leveltransaction
value and atransaction
tag, and they don't match, ingest seems to overwrite the tag value with the top-level value. For example, thisbeforeSend
produced an event with this JSON:
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.
Gut feeling wise I like the current behavior (yes for API routes, no for page routes), because that way the pageload/pagenavigation transaction names and data-fetcher transactions line up. But let's discuss this in-depth when we get to it!
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.
Yeah, I'm not wedded to either outcome, I just think we should standardize it across SDKs if possible. The tricky part when it comes to something like Express is that it's not as clear-cut what's an API request and what's a page load request. But as you say, we can talk about it closer to the time.