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

feat(node): Expose functional integrations to replace classes #10356

Merged
merged 5 commits into from
Jan 31, 2024

Conversation

mydea
Copy link
Member

@mydea mydea commented Jan 25, 2024

This updates the general (non-tracing) node integrations to be functional.

For node & undici, the replacements are slightly different:

  • new Http() --> httpIntegration(): In contrast to the class integration, this will create spans by default if tracing is enabled. While at it, this also "fixes" that if tracing: false is set, no spans will be created.
  • new Undici() --> nativeNodeFetchIntegration(): Renamed this for consistency, and added a tracing option similar to http to allow to disable span creation.

We can't really deprecate Integrations.xxx yet until we have replacements for the tracing integrations 😬 So that would also be a todo left.

@mydea mydea requested review from lforst, Lms24 and AbhiPrasad January 25, 2024 21:00
@mydea mydea self-assigned this Jan 25, 2024
return new Undici(options) as unknown as IntegrationFnResult;
}) satisfies IntegrationFn;

export const undiciIntegration = defineIntegration(_undiciIntegration);
Copy link
Member

@AbhiPrasad AbhiPrasad Jan 25, 2024

Choose a reason for hiding this comment

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

m: we should probably rename this right now tbh. Nobody recognizes Undici 😢

Copy link
Member Author

Choose a reason for hiding this comment

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

ahh right! Let's go with nativeNodeFetchIntegration() as Luca proposed some time ago 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed it!

@mydea mydea force-pushed the fn/node-integrations branch from 85b971c to a116e73 Compare January 26, 2024 14:19
@mydea mydea requested a review from AbhiPrasad January 26, 2024 14:20
@mydea mydea force-pushed the fn/node-integrations branch from a116e73 to 993582b Compare January 29, 2024 09:22
Copy link
Contributor

github-actions bot commented Jan 29, 2024

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 78.18 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 69.39 KB (+0.02% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) - Webpack (gzipped) 73.28 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 63.01 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 33.41 KB (+0.03% 🔺)
@sentry/browser (incl. browserTracingIntegration) - Webpack (gzipped) 33.28 KB (+0.05% 🔺)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 31.33 KB (0%)
@sentry/browser (incl. sendFeedback) - Webpack (gzipped) 31.34 KB (0%)
@sentry/browser - Webpack (gzipped) 22.6 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 76 KB (+0.05% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 67.54 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 33.45 KB (+0.13% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped) 24.66 KB (+0.14% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 213.12 KB (+0.07% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 101.13 KB (+0.14% 🔺)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 74 KB (+0.16% 🔺)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 36.56 KB (+0.11% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 69.78 KB (-0.02% 🔽)
@sentry/react - Webpack (gzipped) 22.63 KB (0%)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 86.45 KB (+0.01% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 50.76 KB (+0.01% 🔺)
@sentry-internal/feedback - Webpack (gzipped) 17.21 KB (0%)

@mydea mydea force-pushed the fn/node-integrations branch from 993582b to 4770c56 Compare January 29, 2024 16:24
@mydea
Copy link
Member Author

mydea commented Jan 29, 2024

Update: So I updated the node http/fetch integrations so that the functional integrations have slightly new/improved behavior:

With them, span creation will be automatically enabled if tracing is enabled - so no more need to add httpIntergation({ tracing: true }). You can still set it to false but the default is different. I also added some tests to cover this.

@mydea mydea requested a review from AbhiPrasad January 29, 2024 16:26
Copy link
Member

@Lms24 Lms24 Jan 30, 2024

Choose a reason for hiding this comment

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

No action required/General comment: Are we actually exporting the async localvariables integration? Already stumbled upon this yesterday and wasn't sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

no, just the sync one right now!

Comment on lines +65 to +75
| `new Console()` | `consoleIntegration()` | `@sentry/node` |
| `new Context()` | `nodeContextIntegration()` | `@sentry/node` |
| `new Modules()` | `modulesIntegration()` | `@sentry/node` |
| `new OnUncaughtException()` | `onUncaughtExceptionIntegration()` | `@sentry/node` |
| `new OnUnhandledRejection()` | `onUnhandledRejectionIntegration()` | `@sentry/node` |
| `new LocalVariables()` | `localVariablesIntegration()` | `@sentry/node` |
| `new Spotlight()` | `spotlightIntergation()` | `@sentry/node` |
| `new Anr()` | `anrIntergation()` | `@sentry/node` |
| `new Hapi()` | `hapiIntegration()` | `@sentry/node` |
| `new Undici()` | `nativeNodeFetchIntegration()` | `@sentry/node` |
| `new Http()` | `httpIntegration()` | `@sentry/node` |
Copy link
Member

@Lms24 Lms24 Jan 30, 2024

Choose a reason for hiding this comment

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

I think we need to do a better job to call out that these integration chanes also apply to all/most @sentry/node-based packages (serverless, fullstack framework SDKs). Doesn't strictly have to happen now but I'd say we should add them. Probably simplest to list them individually (also, they slightly differ per integration :( )

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, I thought about this too but this makes the table veeery unwieldly 😓 not sure, maybe we just point it out above? E.g. node also applies to next, remix, sveltekit, ..., browser also applies to react, ...?

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

LGTM!

@mydea mydea force-pushed the fn/node-integrations branch from 4770c56 to 86c6931 Compare January 30, 2024 15:38
mydea added 4 commits January 30, 2024 17:14

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
We'll need to adjust the http & undici options a bit to align with otel integrations, but we can do this in a follow up, otherwise this will become a bit unwieldly...
@mydea mydea force-pushed the fn/node-integrations branch from 86c6931 to 6827886 Compare January 30, 2024 16:22
@mydea mydea merged commit 0c16f21 into develop Jan 31, 2024
@mydea mydea deleted the fn/node-integrations branch January 31, 2024 09:40
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.

None yet

3 participants