-
Notifications
You must be signed in to change notification settings - Fork 837
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
fs instrumentation not working correctly with TypeScript path aliases #3450
Comments
Weird... When I change the So maybe the problem lies in the |
Hmm it is quite possible that it is. The OTLP exporters are quite complex and rely on generated code. It is quite weird that it causes problems in other seemingly unrelated parts of your code though. I'm going to label this as p3 since it causes problems in your code, but is not a production runtime crash but rather a compile time issue. I don't see anything in your stacktraces that point to anything specific to OTLP expoters, but i'll try to reproduce this today. |
With 75% confidence (I did it weeks ago, but only read a notification from you @dyladan) I believe that the same errors were present when using |
Well, I did this to debug the issue (and I'm not sure if mine is the same as yours, but this is the only issue I could find on the topic): const fs = require('fs');
const _fsStatSync = fs.statSync.bind(fs);
fs.statSync = (...args) => {
if (args[0].includes('node_modules')) return _fsStatSync(...args);
const err = new Error();
console.log(args, err);
return _fsStatSync(...args);
}; Which indeed resulted in millions of calls to
Disabling instrumentations: [
getNodeAutoInstrumentations({
'@opentelemetry/instrumentation-fs': {
enabled: false,
},
}),
], I guess proper fix would be to hook |
Also there is |
A weird behavior we encounter is, that if we do use a path alias to import the |
I am also seeing many I read that it's overall recommended to turn fs instrumentation off (open-telemetry/opentelemetry-js-contrib#1344 (comment)) but not sure how to do it via otel operator (open-telemetry/opentelemetry-operator#1283 (comment)) |
What happened?
Steps to Reproduce
A typescript app repository with
tsconfig.json
includingpaths
, for example:Expected Result
Tracing works correctly
Actual Result
Tracing contains mostly
fs.existsSync
andfs.statSync
entries, many of them are errors. SeeExample stacktrace when running the app via
ts-node-dev
: [log output 1]Different stacktrace when running the app via
node
(withtsconfig-paths/register
): [log output 2]FYI, I'm pasting 2 different errors. There are many more related to various files and libraries. Wanted to paste both ts-node-dev and node stacktraces to see any differences between the file paths, but I did not see any.
Additional Details
It looks like there's either a problem with my setup or the monkey-patching does not work like it should.
I'm running the node command like this:
TS_NODE_PROJECT=tsconfig-js.json node --require tsconfig-paths/register --require ./dist/src/tracing.js ./dist/src/main.js"
and the ts-node-dev command like this:
OpenTelemetry Setup Code
package.json
Relevant log output
2:
The text was updated successfully, but these errors were encountered: