-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
add instruction on node --require #9932
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Bundle ReportChanges will increase total bundle size by 3.01kB ⬆️
|
|
|
||
| Once this is done, Sentry's Node SDK captures unhandled exceptions as well as tracing data for your application. | ||
|
|
||
| Therefore, we recommend to create a file named `instrumentation.js` that imports and initializes Sentry. |
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.
Nitpick regarding line 36 and 46 in this file: Can you change the dash to an em dash?
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.
Fixed
| ```javascript {tabTitle:CommonJS} | ||
| require('./instrumentation.js') | ||
|
|
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.
I would argue that we should not honor this escape hatch an entire code block.
Considerations:
- People might do both --require AND the import
- It might be confusing
- We really do not want people to do that unless absolutely necessary and a dedicated code block might be promoting 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.
I agree. I added these specifically to show that it really has to go to the top and any other imports come after but this is already explained in text as well. Probably better to drop 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.
I have a different opinion: We definitely should to show this, because there will def. be people out there who do not have the (easy) capability to adjust the code their app is run in production. Lots of devs do not have direct access to their deployment infrastructure etc, making it much harder for them to get started with using sentry. We can call out why the other solution is preferable and lead with that, but should still show how you can get it to run otherwise. There is really nothing wrong with the instrument-on-top approach for require.js.
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.
actually, we need to keep this anyhow and add a note that this is definitely needed for node <18 - no other way to run stuff there, I think?
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.
actually, we need to keep this anyhow and add a note that this is definitely needed for node <18 - no other way to run stuff there, I think?
--require is supported since v1.6.0
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.
I have a different opinion: We definitely should to show this, because there will def. be people out there who do not have the (easy) capability to adjust the code their app is run in production. Lots of devs do not have direct access to their deployment infrastructure etc, making it much harder for them to get started with using sentry. We can call out why the other solution is preferable and lead with that, but should still show how you can get it to run otherwise. There is really nothing wrong with the instrument-on-top approach for require.js.
We were just thinking that people will skip over reading the leading text and just copy paste code snippets around, ending up with both --require and a top level import.
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.
--require is supported since v1.6.0
Ah, sweet! Good to know 🚀
We were just thinking that people will skip over reading the leading text and just copy paste code snippets around, ending up with both --require and a top level import.
You need to read this anyhow, as the text instructs you to create another file etc anyhow - this is not as easy as copy-pasting a snippet into your app.js anyhow, I'd argue. If you don't read this, it'll not work anyhow.
I'd just like to argue that while for us it is fine and easy to "just add a CLI flag when running the node app", there are loads of devs out there for whom this is not as trivial, and (as stated before) even more that simply can't do this themselves. Why should we not document how they can still use Sentry even if they can't easily adjust this themselves? I don't really see the upside of "hiding" this away? It's not even that problematic if this is double-initialized, it should work just fine even if somebody does that. And we could even guard against this, if we actually need 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.
Yea you're right. I can definitely see some orgs disallowing passing flags to node, or like you said, people not even having the ability to change how things are run.
Will keep it, but maybe give it its own heading — as is, it's easy to not see that this is an alternative way of running it, wdyt?
| const http = require("http"); | ||
| ``` | ||
|
|
||
| ```javascript {tabTitle:ESM} |
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.
Adding a filename here now would be nice!
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.
Fixed
a2b5709 to
6e20f0f
Compare
Co-authored-by: vivianyentran <[email protected]>
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.
Can we also update the SDK initialization section in the migration guide? https://docs.sentry.io/platforms/javascript/guides/node/migration/v7-to-v8/#updated-sdk-initialization
(feel free to do this in a follow-up PR, don't want to block this any longer than necessary)
Yep can do. |
s1gr1d
left a comment
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.
Thanks for adding this 🙌🏻
Do not forget to also add this to koa, aws-lambda, azure-functions, connect, express and fastify.
| ## Configure | ||
|
|
||
| Sentry should be initialized as early in your app as possible. It is essential that you call `Sentry.init` before you require any other modules in your application - otherwise, auto-instrumentation of these modules will _not_ work. | ||
| Sentry should be initialized as early in your app as possible. It is essential that you call `Sentry.init` before you require any other modules in your application — otherwise, auto-instrumentation of these modules will _not_ work. |
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.
| Sentry should be initialized as early in your app as possible. It is essential that you call `Sentry.init` before you require any other modules in your application — otherwise, auto-instrumentation of these modules will _not_ work. | |
| Sentry should be initialized as early in your app as possible. It is essential that you call `Sentry.init` before you require any other modules in your application—otherwise, auto-instrumentation of these modules will _not_ work. |
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.
Thanks, fixed
| If you set a `tracesSampleRate`, performance instrumentation will automatically be enabled for you. See <PlatformLink to="/performance/instrumentation/automatic-instrumentation">Automatic Instrumentation</PlatformLink> to learn about all the things that the SDK automatically instruments for you. | ||
|
|
||
| You can also manually capture performance data - see <PlatformLink to="/performance/instrumentation/custom-instrumentation">Custom Instrumentation</PlatformLink> for details. | ||
| You can also manually capture performance data — see <PlatformLink to="/performance/instrumentation/custom-instrumentation">Custom Instrumentation</PlatformLink> for details. |
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.
| You can also manually capture performance data — see <PlatformLink to="/performance/instrumentation/custom-instrumentation">Custom Instrumentation</PlatformLink> for details. | |
| You can also manually capture performance data—see <PlatformLink to="/performance/instrumentation/custom-instrumentation">Custom Instrumentation</PlatformLink> for details. |
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.
Fixed
| @@ -0,0 +1,28 @@ | |||
| --- | |||
| title: Run Methods | |||
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.
We talked about that already in person: Maybe call this page "Initialization Variants" 🤔
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.
Yep, renamed it.
| @@ -0,0 +1,8 @@ | |||
| --- | |||
| title: Run as toplevel import | |||
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.
| title: Run as toplevel import | |
| title: Add as top-level import |
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.
Thank you :) fixed
Added the others except If you could have another look please :) |
Co-authored-by: vivianyentran <[email protected]> Co-authored-by: Luca Forstner <[email protected]> Co-authored-by: Stephanie Anderson <[email protected]>
No description provided.