-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(nextjs): Remove Http integration from Next.js #11304
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b0425e4
Remove Http integration from Next.js
s1gr1d 7b9431b
review comments
s1gr1d f3808b0
start span if there is none
s1gr1d 2f16e1b
feat(nextjs): Fork isolation scopes when incoming HTTP spans are created
lforst 0c82b97
add startOrUpdateSpan function
s1gr1d 77204f4
change nextjs version in e2e test
s1gr1d 7daa837
Revert "change nextjs version in e2e test"
mydea 2a54bd2
fix nextjs PR (#11450)
mydea 35b5ac8
add OP
s1gr1d b28f605
Apply suggestions from code review
s1gr1d 1674e11
fix format
s1gr1d 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
44 changes: 44 additions & 0 deletions
44
packages/nextjs/src/server/requestIsolationScopeIntegration.ts
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { SpanKind } from '@opentelemetry/api'; | ||
import { | ||
defineIntegration, | ||
getCapturedScopesOnSpan, | ||
getCurrentScope, | ||
getIsolationScope, | ||
s1gr1d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
getRootSpan, | ||
setCapturedScopesOnSpan, | ||
spanToJSON, | ||
} from '@sentry/core'; | ||
import { getSpanKind } from '@sentry/opentelemetry'; | ||
|
||
/** | ||
* This integration is responsible for creating isolation scopes for incoming Http requests. | ||
* We do so by waiting for http spans to be created and then forking the isolation scope. | ||
* | ||
* Normally the isolation scopes would be created by our Http instrumentation, however Next.js brings it's own Http | ||
* instrumentation so we had to disable ours. | ||
*/ | ||
export const requestIsolationScopeIntegration = defineIntegration(() => { | ||
return { | ||
name: 'RequestIsolationScope', | ||
setup(client) { | ||
client.on('spanStart', span => { | ||
const spanJson = spanToJSON(span); | ||
const data = spanJson.data || {}; | ||
|
||
// The following check is a heuristic to determine whether the started span is a span that tracks an incoming HTTP request | ||
if ( | ||
(getSpanKind(span) === SpanKind.SERVER && data['http.method']) || | ||
(span === getRootSpan(span) && data['next.route']) | ||
) { | ||
const scopes = getCapturedScopesOnSpan(span); | ||
|
||
// Update the isolation scope, isolate this request | ||
const isolationScope = (scopes.isolationScope || getIsolationScope()).clone(); | ||
const scope = scopes.scope || getCurrentScope(); | ||
|
||
setCapturedScopesOnSpan(span, scope, isolationScope); | ||
} | ||
}); | ||
}, | ||
}; | ||
}); |
This file contains hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.