Open trentm opened 7 months ago
Fastify ESM support is slightly limited. The current import style in "opentelemetry-js-contrib/plugins/node/opentelemetry-instrumentation-fastify/test/fixtures/use-fastify.mjs" works, but this fails:
...
import * as mod from 'fastify';
console.log('mod: ', mod);
const app = mod.fastify();
...
Here mod.default
is instrumented, but mod.fastify
is not.
This is probably an exceedingly rare way to import and use fastify. Still,
this is why I haven't checked fastify above.
According to this post, the following already work, based likely on luck:
graphql
@grpc/grpc-js
Your checklist only supports binary display - either fully working or not working at all. How about adding emojis to the list to signal the current implementation status? States could be:
🎉 I found a working solution here! My project is using esm and I switched my runtime from node
to jiti
and NOW EVERYTHING JUST WORKS!!!!!! I'm using http, express and pg instrumentations. Works on node18 and node20
If we are living in a simulation then this is a complete cheat code 🥷🏼
Your checklist only supports binary display ...
Heh. I don't object to more info being included in each bullet point. I'd like to keep the checkboxes. To me "checked" will mean "we've done a first pass on ESM instrumentation for this module". When everything is checked, we can close this issue. There could be separate follow-up issues for particular limitations.
This is a meta issue to coordinate doing a first pass at ECMAScript module (ESM) support and a test for every node.js instrumentation. (This is about working with the
import-in-the-middle
-based hook so is not relevant to browser instrumentations.) I'm not necessarily volunteering to do all these :), but I'll certainly help.Hopefully this can also be useful for support/help requests for why instrumentation might not be working for ESM-using code. If the module/instrumentation in question is not checked off here, then ESM instrumentation is not expected to work (it might be luck).
dev notes
Run the following to show which (contrib-repo) instrumentations have an ESM-related test. This shows usage of the required experimental-loader hook to support hooking ESM modules.
Guide on adding ESM support and an ESM test to an instrumentation
TODO(trentm)
runTestFixture