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

fix(nextjs): Remove Http integration from Next.js #11304

Merged
merged 11 commits into from
Apr 9, 2024

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Mar 27, 2024

Next.js provides their own OTel http integration, which conflicts with ours
ref #11016
added commit from this PR: #11319

@s1gr1d s1gr1d requested review from lforst and mydea March 27, 2024 10:32
@s1gr1d s1gr1d force-pushed the sig-nextjs-remove-http branch from c10f4ed to 2184334 Compare March 27, 2024 10:33

This comment was marked as off-topic.

return new Proxy(routeHandler, {
apply: (originalFunction, thisArg, args) => {
return withIsolationScope(async isolationScope => {
Copy link
Member

Choose a reason for hiding this comment

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

h: Since the http integration was responsible for creating the isolation scope, we need to add the call to withIsolationScope back, otherwise we'll mutate the global isolation scope and leak request data into other requests.

packages/nextjs/src/server/index.ts Show resolved Hide resolved
@s1gr1d s1gr1d force-pushed the sig-nextjs-remove-http branch 3 times, most recently from a9e26e9 to b3bc50f Compare March 27, 2024 16:06
Copy link
Contributor

github-actions bot commented Mar 27, 2024

size-limit report 📦

Path Size
@sentry/browser 22.1 KB (0%)
@sentry/browser (incl. Tracing) 31.71 KB (0%)
@sentry/browser (incl. Tracing, Replay) 66.92 KB (0%)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 60.52 KB (0%)
@sentry/browser (incl. Tracing, Replay with Canvas) 70.75 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) 75.67 KB (0%)
@sentry/browser (incl. Feedback) 30.87 KB (0%)
@sentry/browser (incl. Feedback, Feedback Modal) 30.88 KB (0%)
@sentry/browser (incl. Feedback, Feedback Modal, Feedback Screenshot) 30.89 KB (0%)
@sentry/browser (incl. sendFeedback) 26.88 KB (0%)
@sentry/react 24.78 KB (0%)
@sentry/react (incl. Tracing) 34.61 KB (0%)
@sentry/vue 25.53 KB (0%)
@sentry/vue (incl. Tracing) 33.44 KB (0%)
@sentry/svelte 22.23 KB (0%)
CDN Bundle 24.11 KB (0%)
CDN Bundle (incl. Tracing) 32.66 KB (0%)
CDN Bundle (incl. Tracing, Replay) 66.37 KB (0%)
CDN Bundle (incl. Tracing, Replay, Feedback) 71.63 KB (0%)
CDN Bundle - uncompressed 71.67 KB (0%)
CDN Bundle (incl. Tracing) - uncompressed 97.71 KB (0%)
CDN Bundle (incl. Tracing, Replay) - uncompressed 207.1 KB (0%)
@sentry/nextjs (client) 33.8 KB (0%)
@sentry/sveltekit (client) 32.24 KB (0%)
@sentry/node 119.99 KB (+0.04% 🔺)

@s1gr1d s1gr1d force-pushed the sig-nextjs-remove-http branch 3 times, most recently from d41b917 to 37649af Compare April 5, 2024 12:48
@s1gr1d s1gr1d mentioned this pull request Apr 5, 2024
13 tasks
const spanJson = spanToJSON(span);

// 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 && spanJson.data && 'http.method' in spanJson.data) {
Copy link
Member

@mydea mydea Apr 5, 2024

Choose a reason for hiding this comment

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

m: Let's use otel semantic attributes here (from @opentelemetry/semantic-conventions), I'd say?

Copy link
Member Author

@s1gr1d s1gr1d Apr 8, 2024

Choose a reason for hiding this comment

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

Yeah, that makes sense! Here: #11467
This comment was supposed to be elsewhere, I added it to the correct place

@@ -72,6 +73,16 @@ export class SentrySampler implements Sampler {
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: sampleRate,
};

const method = `${spanAttributes[SemanticAttributes.HTTP_METHOD]}`.toUpperCase();
Copy link
Member

Choose a reason for hiding this comment

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

Let's pull this into a separate PR!

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that makes sense! Here: #11467

@mydea mydea force-pushed the sig-nextjs-remove-http branch from 37649af to 786b4cb Compare April 8, 2024 14:13
@s1gr1d s1gr1d force-pushed the sig-nextjs-remove-http branch from 364119c to 6f17db7 Compare April 8, 2024 15:26
@s1gr1d s1gr1d requested review from mydea and lforst April 9, 2024 06:31
Copy link
Member

@mydea mydea left a comment

Choose a reason for hiding this comment

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

very nice! Such a small and easy PR at the end xD

packages/nextjs/src/common/wrapRouteHandlerWithSentry.ts Outdated Show resolved Hide resolved
rootSpan.updateName(spanName);
rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');
rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'http.server');
rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.function.nextjs');
Copy link
Member

Choose a reason for hiding this comment

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

l: In a follow up, we can extend this to also set method and other stuff we possibly get there. But no need to do that now!

Side note, you can also use rootSpan.setAttributes({ ... }) to set multiple attributes at once :)

s1gr1d and others added 2 commits April 9, 2024 13:42
Co-authored-by: Francesco Novy <francesco.novy@sentry.io>
@s1gr1d s1gr1d force-pushed the sig-nextjs-remove-http branch from 6bc00da to 1674e11 Compare April 9, 2024 11:43
@s1gr1d s1gr1d merged commit 4676ca3 into develop Apr 9, 2024
67 checks passed
@s1gr1d s1gr1d deleted the sig-nextjs-remove-http branch April 9, 2024 13:27
cadesalaberry pushed a commit to cadesalaberry/sentry-javascript that referenced this pull request Apr 19, 2024
Next.js provides their own OTel http integration, which conflicts with
ours
ref getsentry#11016
added commit from this PR:
getsentry#11319

---------

Co-authored-by: Luca Forstner <luca.forstner@sentry.io>
Co-authored-by: Francesco Novy <francesco.novy@sentry.io>
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.

3 participants