-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Integrations not working for Bun #14202
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)
|
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)
Alright. I gave it a shot on my local env and I saw it run in ESM mode. I will try to get it to run like this in the QA env but so far, I am not seeing any additional telemetry for the DB and so on. Perhaps I am doing something wrong. I am using ElysiaJS and I was able to connect Sentry to it using Elysia's OTEL plugin... The thing is I am only seeing data from http.server and not much else. Is there more I need to do? |
In Node with ESM, the instrumentation file needs to be added with the CLI flag We still need to add docs for this in bun, but I think you can do the same with Does this work? |
As noted in my conversation with @AbhiPrasad I have already done that and I was able to get it to run now in ESM mode. I'm asking about the rest of the auto instrumentation such as postgres, or redis. I'm not seeing any data coming in from that stuff which I am using. |
It could be that Bun does not work correctly with We still need to test it out to find the root cause. |
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: