-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Integrations not working for Bun #14202
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
Comments
@AbhiPrasad should fetch client instrumentation work for bun work? |
Hi @doepnern, thanks for filing this. Unfortunately this is still an issue upstream in bun, see oven-sh/bun#13165. You should filter out the http integration for the time being. import * as Sentry from '@sentry/bun';
Sentry.init({
dsn: '__MY_DSN__',
integrations: function (integrations) {
// integrations will be all default integrations
return integrations.filter(function (integration) {
return integration.name !== "Http";
});
},
tracesSampleRate: 1.0,
}); |
From what I can tell, I'm supposed to get automatic instrumentation with PostgreSQL, Redis, and more. Yet I am not seeing the data for this stuff being received. |
@MatthewAry are you running your app with CJS or ESM? ESM might be causing issues here for instrumentation. |
@AbhiPrasad Well, it's Bun. And we use ESM for a long list of DX reasons. Do you have guidance on how to make this stuff work with ESM? |
ESM instrumentation gets complicated (I did a talk about this here), which is why I asked. In our instructions for Node.js apps, we recommend using a The equivalent to this in Bun is Let's try the following. First create a instrumentation.mjs file where your sentry instrumentation code lives: import * as Sentry from "@sentry/bun";
// Ensure to call this before importing any other modules!
Sentry.init({
dsn: "YOUR_DSN_HERE",
// Add Tracing by setting tracesSampleRate
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
// enable debug logs so we see what instrumentation isn't getting initialized properly.
debug: true,
}); Then could you run your app with |
Okay. Was finally able to get around to this. I watched your video and I tried running it like you suggested. Here was my result:
I have truncated some of the redundant outputs. What's interesting to me is that it says that it's running in CommonJS mode (which doesn't seem to be in alignment with what you said in your presentation), and after that it says that it's skipping sending events because the buffer is full... So it's not able to drain the buffer and its not sending events? I'm investigating the buffer bit but I'm interested on your thoughts about it starting in CommonJS mode. I did find this sentry-javascript/packages/node/src/sdk/initOtel.ts Lines 41 to 66 in bcb15ba
sentry-javascript/packages/node/src/utils/commonjs.ts Lines 2 to 4 in 64308ce
You can confirm on your end but it seems to me that Sentry would only be able to work on Node with ESM right now because I think that Sentry's package for Bun is leaning too hard on the logic used for Node because Bun's Sentry Package ultimately uses the Node's init method sentry-javascript/packages/node/src/sdk/index.ts Lines 105 to 165 in bcb15ba
|
The log output looks good (except for the CJS log).
|
As `require` is supported in ESM as well from [Node 20.19.0](https://nodejs.org/en/blog/release/v20.19.0) onwards, the check does not work anymore. However, `module` is not available in ESM. Also mentioned in this comment: #14202 (comment) [Node: Compatibility with CommonJS](https://nodejs.org/docs/latest-v15.x/api/esm.html#esm_interoperability_with_commonjs) [Bun: Using require](https://bun.sh/docs/runtime/modules#using-require)
|
Okay, well it would be nice to see this work before Sentry starts charging us for using the profiling feature after it becomes GA. I think that for bun projects, it might be appropriate to keep the billing turned off until it's for sure working. |
So I'm seeing auto-telemetry working for |
Have you tried upgrading Bun and the Sentry SDK to the latest versions? The PR linked by Sigrid was merged and we adapted our SDK in the latest release.
I haven't followed this conversation in detail but Profiling has GA'd quite a while ago. If you feel like we charged you for something incorrectly please contact support so that our support staff can refund you. |
@Lms24 Yeah, I tried it out. I am seeing that I am able to reliably get telemetry only from |
Hi, sorry for the late reply (easter holidays and all...)!
Just to confirm, are you using the packages Assuming yes, I think Sigrid is right that In the meantime: I see the last time you posted debug logs and your Sentry setup is quite a while ago. Did anything change in since then? We'd greatly appreciate a minimal reproduction or alternatively any updates in debug log output or setup. Thanks! |
We're using While making a minimal reproduction I was able to get I was able to track down the issue with how I was setting the Here is my minimal reproduction https://github.com/MatthewAry/sentry-bun |
Update: I don't think query traces are working I'm able to use vanilla Update: There's a stale PR on Neon's driver to add OTEL support neondatabase/serverless#102 |
Thanks for the reproduction, we're taking a look! |
Adding Node 21 to the accepted version range for `module.register` as it is already supported (https://nodejs.org/docs/v21.0.0/api/module.html). This also causes the customization hook not to call register (maybe a reason why some packages in issue #14202 are not instrumented): https://github.com/getsentry/sentry-javascript/blob/59094afb6ab53ac33b87b83f70eea9d13e4c2291/packages/node/src/sdk/initOtel.ts#L45-L65 --- Additionally, the above mentioned issue #14202 shows the following warning although it's using v21: ``` [Sentry] You are using Node.js in ESM mode ("import syntax"). The Sentry Node.js SDK is not compatible with ESM in Node.js versions before 18.19.0 or before 20.6.0. Please either build your application with CommonJS ("require() syntax"), or upgrade your Node.js version. ```
In an internal chat Jarred Sumner mentioned that |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/bun
SDK Version
8.37.1
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
Hey,
which integrations should I expect to work in bun? So far only manual instrumentation seems to be working.
Is this expected behavior? If so, a few more notes on that would be appreciated in the documentation.
Bun
Steps to Reproduce
https://github.com/doepnern/sentry-node-bun-comparison
Expected Result
Expected http instrumentation to work, according to docs (See result for node below)
https://docs.sentry.io/platforms/javascript/guides/bun/configuration/integrations/http/
Actual Result
error handling is noted as not working in the npm package page, so i guess that is to be expected
The text was updated successfully, but these errors were encountered: