-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(node): Add Fastify
integration
#9138
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
I really would like us to avoid the pattern of passing in the app instance to the integration. I know we've done this in previous cases, but it leads to the situation where Sentry isn't the first thing you call in your app, which has other consequences. Could we work around this somehow? Ideally we can fix all cases of this in v8. |
The challenge I am trying to solve is to make this work in current IMHO even with this pattern you can solve this by adding the integration later, like: Sentry.init({
integrations: []
});
// later your app is setup
getCurrentHub().getClient().addIntegration(new Sentry.Integrations.Fastify({ fastify: app }); Would this be acceptable in your book? Or would you generally want to avoid any instance passing, in any place? If we want to prioritize that we do not need to pass the instance in at all, I'll have to see how to do this nicely. FWIW, we can also duplicate the plugin for node-experimental (it's not really that complicated, the error capturing code), though it would be nice to use the same code there I guess. |
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're right that getCurrentHub().getClient().addIntegration
does work in this case, maybe we should be talking about that more in the docs.
lgtm for errors, nice work!
1b24faa
to
c04f1a5
Compare
size-limit report 📦
|
Hello! Is there anything blocking this PR? |
Hey! Mostly we are exploring a bit if we want to follow this path or try something else. (e.g. can we automatically set this up without having the user add any plugins manually)! We'll keep you updated here. |
scope.setTag('baz', 'wat'); | ||
}); | ||
|
||
await new Promise(resolve => setTimeout(resolve, 10)); |
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('node:timers/promises').setTimeout
exist. We don't need to await new Promise here. Although, it might not work with Node 8.
Very excited for this - my employer uses Fastify extensively and recently started integrating Sentry. Please let me know if I can assist in any way to get this through. |
This adds a new
Fastify
integration to@sentry/node
, which does two things:Note that it does not support performance monitoring for now, as we're exploring to only add this in the upcoming OTEL-based performance world. But even so, this should already be useful (and can also be used in the node-experimental world).
Usage
ref #4784