-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Replacement for Handlers.requestHandler, Handlers.errorHandler, etc. #12007
Comments
Hey, we are going to highlight this - but there is no need for these handlers anymore. So it should work, if it doesn't it's a bug. |
For Expess for example: https://docs.sentry.io/platforms/javascript/guides/express/#use |
I ran headfirst into another issue before I could test if auto-instrumentation works: #12011 It seems like v8 of the SDK is really oriented around tracing. For instance, from looking at the implementation, it seems like Express is only instrumented if we enable tracing:
If I'm interpreting that correctly, I frankly think this is a step back. We don't use Sentry for tracing (we use Honeycomb), and we don't plan on starting. We use Sentry only for error reporting, and it's really really good at that! The old I'll withhold judgement until #12011 is fixed and I can actually try the new SDK. However, on an initial look, it doesn't seem like the Express auto-instrumentation will grab headers, cookies, the body, etc. and attach them to error events, as I don't see a call to Aside, I see that the Remix support actually still operates how the Express integration used to: sentry-javascript/packages/remix/src/utils/serverAdapters/express.ts Lines 21 to 37 in 1390402
|
👋 I am also very concerned by this and it will likely block us moving to v8. We cannot initialize Sentry before importing other stuff due to the nature of how our application passes around the Sentry DSN etc. We're also using a custom-wrapped version of Restify, so I am very doubtful that Sentry is going to auto-inject itself as middleware correctly. I feel this is quite the regression in the usability of Sentry for folks that aren't following a standard path... and I would ask that these handlers are readded, or at least have documented self-serve replacements, not just documented as being removed with the recommendation being to rely on import magic. |
Thank you for your feedback! I'll try to address the points:
a. Create a file If it is really impossible for you to have a DSN to be set early in your application, I recommend to do something like this: // instrument.js - Call this right at the top of your application!
import * as Sentry from '@sentry/node';
// No idea what the DSN is yet
// We still call Sentry.init(), which will setup a client but not do anything with it because we have no DSN
Sentry.init({
dsn: undefined
});
const client = Sentry.getClient();
// Now we add the integrations we def. need
// If we do not care about performance, http is enough
// This will setup handlers but do nothing until later when we're ready
client.addIntegration(Sentry.httpIntegration()); // sentry-is-loaded.js - called when we know the DSN and want to finish the setup
import * as Sentry from '@sentry/node';
// Calling init again will setup a new client that is now enabled
Sentry.init({
dsn: 'MY_DSN'
}); You can look at this PR: #12016 to see a test that implements something like this. We will look into ways to possibly make this easier!
|
Thanks, this reference was really helpful! I was able to trace through and prove to myself that headers, etc. will still work as intended even without Express instrumentation. I do indeed see that parameterized transaction names are missing without the Express instrumentation, as you pointed out. It would be very nice if that could work the same as before out of the box (though it's nice that I can just enable the Express instrumentation on its own - thanks for pointing that out). |
When we encounter an error in our stack, we manually call We also call With both of these changes in place, the two immediate differences I noticed in behaviour are:
I appreciate you aren't going to add these back, and I agree that the It'd also be nice to see these be documented as being removed, with recommendations for what to do instead, rather than just silently removed and leaving users to figure it out, getting angry at Sentry in the process. |
This is actually not quite correct; with |
This seems correct to me 👍
With culprit, you mean the top of the stack frame? I guess this makes sense - is it, from your POV, not correct the way it is shown?
This is true - it is a limitation of not having the
I totally get the feeling! FWIW, it is documented here: https://docs.sentry.io/platforms/javascript/guides/express/migration/v7-to-v8/#updated-sdk-initialization but I understand that not everybody will see this properly. To give some background, the reason why we didn't deprecate this in v7, is that there simply was no direct replacement - you could not get rid of this before updating to v8, so we couldn't show a deprecation warning (because they should always be actionable). I understand that this could lead to annoyance after updating, though. We are currently working on updating our codemod migr8 to also update these for you, but this is still WIP - but very soon, it should update the handlers for you too!
Thanks for raising this, this is not ideal and we'll adjust this, should not be this way! |
I don't want to hijack the conversation, but is there any solution for tracing with node service bundled using webpack and without any external dependencies setup (so virtually express is part of the bundle)? This previously worked fine with |
@Michsior14 I believe your concern is tracked in #10940 - feel free to add your thoughts there. Generally, you should get basic |
UPDATE: There was a bug in the http instrumentation that caused the transactionName update not to be applied correctly. See @mydea's response below (rest of my response still stays valid) @MattIPv4 the The change here primarily is that you need the |
Actually, we just figured out that we are not setting the transaction name correctly in http-only mode without performance instrumentation. See #12071, this should be fixed in the next version! |
Hey folks, We have since shipped some updates to this:
You should now be able to have a good experience with just the http integration, when only using Sentry for errors! |
Transaction name seems to be set correctly now!
sentry-javascript/packages/core/src/integrations/requestdata.ts Lines 10 to 24 in f3c8a86
sentry-javascript/packages/core/src/integrations/requestdata.ts Lines 118 to 124 in f3c8a86
sentry-javascript/packages/utils/src/requestdata.ts Lines 277 to 286 in f3c8a86
sentry-javascript/packages/utils/src/requestdata.ts Lines 120 to 136 in f3c8a86
Scratch that, looks like this is no longer showing up in production either, filed a general issue for the Sentry UI: getsentry/sentry#71305 |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you remove the label "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
Problem Statement
I'm trying to upgrade to v8 of
@sentry/node
. By and large, the migration instructions at https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.mdand https://docs.sentry.io/platforms/javascript/migration/v7-to-v8 have done a good job explaining how to upgrade. However, there's no mention of the fact that theHandlers
export was removed, or what APIs have replacedHandlers.requestHandler()
,Handlers.tracingHandler()
, orHandlers.errorHandler()
. The only relevant mention of handlers in either doc is under "Removal ofSentry.Handlers.trpcMiddleware()
in favor ofSentry.trpcMiddleware()
".Solution Brainstorm
I'd expect the v8 migration instructions to contain documentation on replacement APIs for
Handlers.requestHandler()
,Handlers.tracingHandler()
, andHandlers.errorHandler()
.The text was updated successfully, but these errors were encountered: