Coder Social home page Coder Social logo

Comments (4)

jahands avatar jahands commented on June 20, 2024

This package has a hard dependency on the nodejs_compat compatibility flag. Without it, it would not be feasible to create auto instrumentation. There are no current plans to try to remove the nodejs_compat requirement.

from otel-cf-workers.

jesseditson avatar jesseditson commented on June 20, 2024

Out of curiosity, why is this a hard dependency? I can also look at code but I only see mention of the requirement, not the reason why, in the documentation. I'd love to use this library but it's important to me that my workers are as lightweight as possible. No worries if that's not an eventual goal of this lib, but want to make sure it's not roadmap material before exploring other options.

from otel-cf-workers.

DaniFoldi avatar DaniFoldi commented on June 20, 2024

Hey @jesseditson,

You're probably getting confused between node_compat build option and nodejs_compat compatibility flag. See the screenshot above, these two are mutually exclusive ways to make nodejs code work on Workers.

The former adds polyfills/shims at build time so imports from fs and path won't fail, while the latter enables some extra modules in the runtime, no code added to your worker. The hard dependency is on async local storage, which the library uses for context propagation. The native js solution to that is currently in stage 1, so it'll be a while before we can remove the dependency. The rest (event emitter, buffer) are used in the opentelemetry libraries, so to avoid increasing your worker bundle size, we rely on the runtime's native modules for those as well.

In short: your worker is as lightweight as it can be with nodejs_compat compatibility flag.

See docs here (and feel free to ask on the Cloudflare Discord if you're curious to know more): https://developers.cloudflare.com/workers/runtime-apis/nodejs/#nodejs-compatibility
and https://developers.cloudflare.com/workers/wrangler/configuration/#add-polyfills-using-wrangler

from otel-cf-workers.

jesseditson avatar jesseditson commented on June 20, 2024

That is extremely helpful! I wasn't clear on the difference between those flags and this makes sense. Thank you!

from otel-cf-workers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.