-
-
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
[Sentry] Express is not instrumented. This is likely because you required/imported express before calling Sentry.init()
#12056
Comments
Strange... I did some code refactoring, and didn't touch this part I shared at all.. somehow I'm not having this error anymore. I will close this issue for a bit, if I encounter it again, I'll reopen it |
Isse came back again, I have no idea why. I didn't change anything. tried to update to latest Sentry, didn't help. Tried to nuke node_modules. lock file and everything, still didn't work. This is some weird mystery... |
Hi there, Things changed in v8 a bit, most integrations are now automatically added and you no longer have to take care of those (with the exception of We recommend going through the migration guide here. You can use In your particular example, could you try removing |
hey, thanks for getting back @andreiborza! I did follow the migration guide, and used As you suggested, i removed |
If it helps, you may check my comment on another similar issue that was opened 2 days ago: |
If that help,s we can have a short screensharing call so u can get the context you need |
Have you updated to Could you please provide
I see a |
yes, updated just yesterday. And yes, same result.
Regarding bundler: I'm using @nx/esbuild, as it comes as built-in bundler in NX. Here is part of my NX project (this microservice) config: {
"name": "auth-service",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/auth-service/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nx/esbuild:esbuild",
"outputs": ["{projectRoot}/build"],
"defaultConfiguration": "production",
"options": {
"platform": "node",
"outputPath": "{projectRoot}/build",
"format": ["cjs"],
"bundle": true,
"main": "apps/auth-service/src/main.ts",
"tsConfig": "apps/auth-service/tsconfig.app.json",
"assets": ["apps/auth-service/src/assets"],
"generatePackageJson": true,
"esbuildOptions": {
"sourcemap": true,
"outExtension": {
".js": ".js"
}
}
},
"configurations": {
"development": {},
"production": {
"generateLockfile": true,
"esbuildOptions": {
"sourcemap": false,
"outExtension": {
".js": ".js"
}
}
}
}
}, |
I figured why I stopped having this issue at that time, I removed sentry.setupExpressErrorHandler(app), that's why I didn't get that message. But the problem was still there, although I didn't see it in the console. So this issue is persistent |
So you should def. not remove the error handler :D Do you know if your app is being run as a CommonJS or ESM app? Basically, if you look into your build/dist folder, are the files in there using |
it's CJS, for sure :) |
could you please post snippets of |
Hi, I'm also seeing:
in my application logs despite following the sentry onboarding guide for express apps. Errors are still sent to sentry and everything seems to work fine though. Here's the code that I'm running: |
Are you not using performance? This is a bug in the current version, that it will show this warning if performance is disabled - it's safe to ignore it! In 8.3.0 (which should be out soon) this warning will be fixed/removed. |
Is this only happening in Jest tests? This is not really something we support (well) right now, because the Jest environment is not a proper/full Node environment, so stuff may not be working there properly 🤔 |
I don't know if it's happening correctly in prod / stage. I couldn't generate the correct events in test, so I didn't go further. @lforst , I just used my tests as an easy way to generate events for Sentry (normally I would turn off events from local / test). First time I've used Sentry with Node. I'll try running it for real and see what happens. |
@mydea / @lforst : I guess I should apologize since I can see events in my sentry account when I just run it normally. We're moving really fast here, but I should have tried this before logging a ticket. My bad. If Sentry doesn't work within a Jest context, perhaps Sentry can test for this and log a warning to the console for a better developer experience? Not sure if that's easy to detect or not. Anyways, glad we can get up and running with the product! |
🙏 all good, that's great to hear! I think we could potentially add a check for |
@mydea / @lforst : I'm not entirely sure what's happened, but I managed to get some events, but I'm also still getting the warning and most of the events are not happening. It's intermittent. I think it's because we are using express v5.0.0-beta.3 on most of our services. I downgraded to 4, and I don't see the Sentry warning. But I'm not convinced this is 100% it. Also, I get this error consistently.
|
We'll continue to look into this next week as this week is Hackweek at Sentry. |
@gdbjohnson That is very likely the cause as the OpenTelemetry express instrumentation is version-locked to version 4: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/de7a6cb77e643ed0de82e514510089fba5ae0405/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts#L62 |
We should add an option to opt-out of these warnings, IMHO. I opened an issue for this: #13471 In this case it is true/correct that express will not be properly performance instrumented. But there is nothing you can do about this as a user, and error monitoring should still work, so you can safely ignore this warning - you'll get basic (un-parametrized) http.server spans through the http instrumentation, but no express-specific tracing data, sadly. I think it is unlikely that OpenTelemetry support will be added before v5 of express is out of beta (which, who nows if/when this will happen :O ) |
@mydea if Sentry will simply not work with Express v5, you really need to put that on your documentation. This page would be a good spot. I reviewed it and I didn't see any block indicating express version that Sentry is compatible with. https://docs.sentry.io/platforms/javascript/guides/express/ Tooling with express is a critical requirement for what we need, so I have a hard choice to either downgrade express or find a different provider for error capture. |
So error monitoring should still work, I believe. As long as middlewares have not changed, ours should still be compatible. Only tracing (performance monitoring) will not work in detail, as mentioned above - meaning you will still get traces, only without parametrisation, and no middleware spans. But there should still be enough details to see what's generally going on! Generally we do not support beta-level releases, unless otherwise stated. When express v5 goes stable, we will make sure to support it as soon as possible. From what I see from release notes etc. middlewares should not (?) have changed, so you can ignore the warning that instrumentation did not work for now. Alternatively, if you really want to get rid of the warning, you can also manually add the middleware like this: import * as Sentry from '@sentry/node';
app.use(Sentry.expressErrorHandler()); |
Issue with Feathers FrameworkIn case anyone finds this issue and uses feathers with express: The warning is generated because the function Solution/WorkaroundSkip the check. function setupExpressErrorHandler(
app,
options,
) {
app.use(expressErrorHandler(options));
ensureIsWrapped(app.use, 'express');
} Therefore, you can simply replace |
I removed this error middleware: and instead used this one: The [Sentry] Express is not instrumented warning went away. |
Hi, I wouldn't recommend removing the #13471 will provide you an option to silence these warnings once it is merged and released (soon). |
FYI you can now configure see #13693 |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.0.0
Framework Version
express@^4.18.1, @nx/express": "18.2.2
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
I did right as you suggested it in your docs. Imprted and initialised Sentry first thing first. But still, it's not working
Expected Result
Do not have [Sentry] Express is not instrumented. This is likely because you required/imported express before calling
Sentry.init()
message, andActual Result
Having error message: [Sentry] Express is not instrumented. This is likely because you required/imported express before calling
Sentry.init()
message, andThe text was updated successfully, but these errors were encountered: