Nodejs instrumentation for scoped packages fails to install itself on Windows #4402
Labels
bug
Something isn't working
priority:p2
Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect
What happened?
Steps to Reproduce
Prerequisite: Windows environment
Redis is used as an example, should be reproducible for any scoped package (
@redis/client
package is instrumented internally in this case).Expected Result
Redis is instrumented and redis-related spans are visible in traces.
Actual Result
Redis is not instrumented.
Additional Details
This happens for scoped packages due to differences in path separator between Windows and Unix system.
Internally,
@opentelemetry/instrumentation-redis-4
package tries to instrument@redis/client/dist/lib/commander.js
which on windows gets paths normalized to@redis\\client\\dist\\lib\\commander.js
in the InstrumentationNodeModuleFile).However, when
require-in-the-middle
hook resolves internal files, normalization only happens for the file path, and not for the module name itself. E.g. in this case@redis/client\\dist\\lib\\commander.js
(source) is returned.Due to this mismatch instrumentation is not applied - name comparison doesn't account for this.
Possible workaround - path normalization can be applied to the name returned from
require-in-the-middle
hook. The following fix worked for my setup:OpenTelemetry Setup Code
package.json
Relevant log output
No response
The text was updated successfully, but these errors were encountered: