Skip to content
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

Feature Request: Bun Support #3749

Open
diavrank opened this issue Oct 28, 2023 · 5 comments
Open

Feature Request: Bun Support #3749

diavrank opened this issue Oct 28, 2023 · 5 comments

Comments

@diavrank
Copy link

Hi, I'm trying to run my app with Bun but I'm getting this error and it seems the root cause is the package of dd-trace. I know this is not your responsibility to fix this kind of issues, however, I wonder if there's any chance you take a look in case you can support the Bun project by fixing the problem from your side or giving feedback about what is the incompatibility issue with this library and Bun.

Expected behaviour

Start the Nestjs server successfully with Bun.

NPM script:

"start": "NODE_ENV=localdev nest start --watch --exec "bun run"",

Actual behaviour

It's throwing the following error when starting a Nest.js app:

[2:20:07 AM] Starting compilation in watch mode...

[2:20:24 AM] Found 0 errors. Watching for file changes.



error: Cannot find module "./hooks" from "[object Object]"

Steps to reproduce

  1. Create a Nestjs app
  2. Install the dependency ddt-trace with Bun 1.0.8
  3. Execute bun start command:

Have the start script as:
"start": "NODE_ENV=localdev nest start --watch --exec "bun run"",

Environment

  • Operation system: Mac OS Sonoma
  • Node.js version: v18.16.1 (But it was run with Bun 1.0.8)
  • Tracer version: ^4.12.0" (Additionally, "nestjs-ddtrace": "^3.0.4",)
  • Agent version: what is this?
  • Relevant library versions: Bun 1.0.8
@diavrank diavrank added the bug Something isn't working label Oct 28, 2023
@diavrank
Copy link
Author

Btw, I also reported the same issue in Bun repo oven-sh/bun#6374

@tlhunter tlhunter changed the title error: Cannot find module "./hooks" from "[object Object]" Feature Request: Bun Support Dec 18, 2023
@tlhunter tlhunter added feature-request alternate-runtime and removed bug Something isn't working labels Dec 18, 2023
@Koka
Copy link

Koka commented Mar 12, 2024

For anyone looking for a way to enable DD tracing in a Bun runtime - there's a (hacky) way to do so (see gist https://gist.github.com/Koka/f1801289b526eeb5853894cc4e3e747d)

Short summary - I had to monkey patch dogstatsd.CustomMetrics to avoid sending metrics through UDP (not supported by Bun runtime yet) and add a shim BlockList to node net module (blocklist is not supported by Bun runtime yet and shim is built in but detection doesn't play well with Bun)

Using this technique you can run functional APM tracing without any metrics being sent, and without any integrations, so you have to call tracer.trace manually

@Jarred-Sumner
Copy link

dd-trace should work in Bun as of Bun v1.1.6 (current: Bun v1.1.10)

image

Relevant PRs:

We manually tested it works when using Express and CommonJS. I don't think it supports tracing ESM imports, as we haven't implemented the Node.js loader API (though we do support a module loader API which works both with CommonJS & ESM without extra work to support both)

@hpx7
Copy link

hpx7 commented May 30, 2024

Is there an issue for tracking support for tracing ESM imports?

@chin2km
Copy link

chin2km commented Aug 1, 2024

dd-trace should work in Bun as of Bun v1.1.6 (current: Bun v1.1.10)

image

Relevant PRs:

We manually tested it works when using Express and CommonJS. I don't think it supports tracing ESM imports, as we haven't implemented the Node.js loader API (though we do support a module loader API which works both with CommonJS & ESM without extra work to support both)

Is there an example for this integration somewhere you could share please?

I followed the different options from the official Datadog documentation here, but no luck so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants