Title: [v8] Changes to serverless package · Issue #10976 · getsentry/sentry-javascript · GitHub
Open Graph Title: [v8] Changes to serverless package · Issue #10976 · getsentry/sentry-javascript
X Title: [v8] Changes to serverless package · Issue #10976 · getsentry/sentry-javascript
Description: In #10540 we explored refactoring the serverless package for v8, and we found some more structural issues that needed to be solved. This was further expanded with #10561. This is a brief proposal for the changes I think the serverless pa...
Open Graph Description: In #10540 we explored refactoring the serverless package for v8, and we found some more structural issues that needed to be solved. This was further expanded with #10561. This is a brief proposal f...
X Description: In #10540 we explored refactoring the serverless package for v8, and we found some more structural issues that needed to be solved. This was further expanded with #10561. This is a brief proposal f...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/10976
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[v8] Changes to serverless package","articleBody":"In https://github.com/getsentry/sentry-javascript/pull/10540 we explored refactoring the `serverless` package for v8, and we found some more structural issues that needed to be solved. This was further expanded with https://github.com/getsentry/sentry-javascript/pull/10561.\n\nThis is a brief proposal for the changes I think the serverless package should take.\n\n# Current State\n\nRight now `@sentry/serverless`:\n\n1. re-exports everything from `@sentry/node` (aka `@sentry/node-experimental`) under main package exports\n\n```js\nimport { captureException } from '@sentry/serverless';\n```\n\n2. Exports 4 functions `init`, `getDefaultIntegrations`, `wrapHandler`, `tryPatchHandler` and re-exports all of `@sentry/node` under `AWSLambda` namespace\n\n```js\nimport { AWSLambda } from '@sentry/serverless';\n\nAWSLambda.init(...);\n\nAWSLambda.wrapHandler(...);\n\nAWSLambda.captureException(...);\n```\n\n3. Exports 5 functions `init`, `getDefaultIntegrations`, `wrapCloudEventHandler`, `wrapEventFunction`, `wrapHttpFunction` under the `GCPFunction` namespace\n\n```js\nimport { GCPFunction } from '@sentry/serverless';\n\nGCPFunction.init(...);\n\nGCPFunction.wrapCloudEventHandler(...);\n```\n\nThere is some logic in `awslambda-auto.ts` that is used for the lambda layer.\n\nThe main export also contains `awsServicesIntegration` export. There is a `googleCloudGrpcIntegration` and `googleCloudHttpIntegration` that exists in the package, but is not exported 😢.\n\n# Problem\n\n1. Namespace exports like `AWSLambda` and `GCPFunction` are not treeshakable, and bundle size really matters for serverless. This is not that bad for `GCPFunction`, but given `AWSLambda` re-exports all of the node sdk, that means anyone using `AWSLambda` and bundling pulls in the entire node sdk!\n2. It is very confusing to have three different `init` exported from the same package, each with their own behaviours (node init, aws init, gcp init)\n3. AWS and GCP code share nothing in common with each other (the utils file in serverless is only used by gcp related code), and the structure is confusing for maintainers.\n\n# Solution\n\nI propose we split `@sentry/serverless` into two packages, `@sentry/aws` and `@sentry/google-cloud`. This means we only export a single `init`, and for users the onboarding becomes way easier. In the future we can easily add support for `@sentry/azure` or similar! This makes sure we can optimize for that specific serverless package.\n\nWe have two options:\n\n1. Make the change in v7 and deprecate the `@sentry/serverless` package (easier upgrade path)\n2. Just split the packages up in v8 and make the breaking change for every serverless sdk user to switch to using either `@sentry/aws` or `@sentry/google-cloud` (lambda layer users will not be impacted in anyway.\n\nThe biggest change is to change package name, but we aren't breaking any of the top level exports so migration shouldn't be too bad. Lambda functions are also small, so I can't see it being too much work to go through people's codebase and change things.\n\n# Addendum \n\nIn https://github.com/getsentry/sentry-javascript/pull/10561 I explored using subpath exports as an alternative to new packages. I'm happier with the separate packages (more accurate download counts too!), but we can change the proposal if sentiments have changed.\n\n# Work\n\n```[tasklist]\n### Tasks\n- [x] https://github.com/getsentry/sentry-javascript/pull/10993\n- [x] remove all google cloud logic from `@sentry/serverless`\n- [ ] https://github.com/getsentry/sentry-javascript/pull/11052\n- [ ] https://github.com/getsentry/sentry-javascript/pull/11065\n- [ ] https://github.com/getsentry/sentry-javascript/issues/11066\n- [x] Update the path for the env var that Sentry sets in peoples lambdas https://github.com/getsentry/sentry/blob/b5f2368068033e3a32b049cba4ff2d7f20612f48/src/sentry/integrations/aws_lambda/utils.py#L242\n- [ ] https://github.com/getsentry/sentry/pull/70137\n```\n```[tasklist]\n### After Release\n- [ ] Remove deprecated lambda container image code - https://docs.sentry.io/platforms/node/guides/aws-lambda/container-image/\n```","author":{"url":"https://github.com/AbhiPrasad","@type":"Person","name":"AbhiPrasad"},"datePublished":"2024-03-08T04:40:09Z","url":"https://github.com/getsentry/sentry-javascript/issues/10976"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:75a95fb6-5908-b0ce-fb60-1a3636bcb057 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D8C:1FAF:9E2302:D07992:6B03F4B1 |
| html-safe-nonce | d31d34be458c1356711b7a2bca6e034ad73409e76cffd26adf223aac3c8808a9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDhDOjFGQUY6OUUyMzAyOkQwNzk5Mjo2QjAzRjRCMSIsInZpc2l0b3JfaWQiOiI4NjI2NTg0NTc2MjI5MzczMTA1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e7c150218d43f174f6fe5b545abaf52bf7cad1dfeeba1a059aa633e2120ad535 |
| hovercard-subject-tag | issue:2175267575 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/10976/issue_layout |
| twitter:image | https://opengraph.githubassets.com/382c67d76cb5322efd6ce3b8d0788e8505ca9cab70ae288cfdce285a3b1bf1db/getsentry/sentry-javascript/issues/10976 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/382c67d76cb5322efd6ce3b8d0788e8505ca9cab70ae288cfdce285a3b1bf1db/getsentry/sentry-javascript/issues/10976 |
| og:image:alt | In #10540 we explored refactoring the serverless package for v8, and we found some more structural issues that needed to be solved. This was further expanded with #10561. This is a brief proposal f... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AbhiPrasad |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width